Most businesses don't need a custom-built AI platform. They need their existing tools to talk to each other — with an LLM sitting in the middle to handle the messy, unstructured parts. That's exactly what n8n + Claude API gives you: a visual workflow engine that can orchestrate API calls, database queries, file processing, and AI reasoning in a single drag-and-drop canvas.
We've deployed this combination for clients handling everything from invoice processing to lead qualification to contract review. The pattern is remarkably consistent: a trigger fires, data flows through a few transformation nodes, Claude processes the unstructured content, and the structured output lands in whatever system needs it. No ML engineers required. No GPU infrastructure. Just workflows that run.
Why n8n Instead of Zapier or Make?
We're not anti-Zapier — it's great for simple integrations. But for AI workflows specifically, n8n has three decisive advantages:
- Self-hosted option. Your data never leaves your infrastructure. For clients handling PII, financial documents, or health records, this isn't optional — it's a compliance requirement. n8n runs on a single Docker container with a PostgreSQL backend.
- Code nodes. When you need to pre-process data before sending it to Claude — chunking a PDF, cleaning HTML, or assembling a dynamic prompt — n8n lets you write arbitrary JavaScript or Python directly in the workflow. Zapier and Make can't do this without awkward workarounds.
- No per-execution pricing at scale. n8n's self-hosted version has no execution limits. When you're processing 500 invoices a day through Claude, Zapier's per-task pricing becomes untenable. n8n's cost is your server ($20–50/month on AWS) plus your Claude API usage.
Architecture: The Standard AI Workflow Pattern
Nearly every AI workflow we build follows the same five-stage pattern:
- Trigger — A webhook, scheduled cron, email arrival, or file upload in S3/Google Drive.
- Extract — Pull the raw content. For PDFs, this means OCR or text extraction. For emails, it's parsing the body and attachments. For CRM records, it's an API call to Salesforce or HubSpot.
- Transform — Clean and structure the data into a prompt. This is where most workflows fail — garbage in, garbage out. We use Code nodes to strip formatting, truncate to token limits, and build system prompts with explicit output schemas.
- Reason — Send the structured prompt to Claude via the HTTP Request node. Parse the JSON response.
- Act — Route the output: create a CRM record, send a Slack notification, update a database row, generate a reply email, or flag for human review.
Example 1: Automated Invoice Processing
Here's a concrete workflow we built for a distribution company processing 200+ vendor invoices per week. Previously, a bookkeeper spent 15 hours/week manually entering invoice data into their accounting system.
The Workflow
Trigger: Email arrives at invoices@company.com (n8n IMAP trigger, polling every 5 minutes).
Extract: A Code node pulls PDF attachments and converts them to text using the pdf-parse npm library.
Transform + Reason: The extracted text goes to Claude with this prompt structure:
// n8n Code Node: Build the Claude API request
const invoiceText = $input.first().json.extractedText;
const response = await this.helpers.httpRequest({
method: 'POST',
url: 'https://api.anthropic.com/v1/messages',
headers: {
'x-api-key': $credentials.anthropicApi.apiKey,
'anthropic-version': '2023-06-01',
'content-type': 'application/json',
},
body: {
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
system: `You are an invoice data extraction system. Extract structured
data from the invoice text. Return ONLY valid JSON with no markdown.`,
messages: [{
role: 'user',
content: `Extract the following fields from this invoice:
- vendor_name (string)
- invoice_number (string)
- invoice_date (YYYY-MM-DD)
- due_date (YYYY-MM-DD)
- line_items (array of {description, quantity, unit_price, total})
- subtotal (number)
- tax (number)
- total (number)
- currency (3-letter code)
Invoice text:
${invoiceText}`
}]
}
});
const parsed = JSON.parse(response.content[0].text);
return [{ json: parsed }];
Act: The parsed JSON feeds into an Odoo API node that creates a draft vendor bill with all line items pre-populated. A Slack notification goes to the bookkeeper with a summary and a link to review.
Key insight: We don't try to make this 100% autonomous. The bookkeeper still reviews and posts each bill — but instead of 15 hours/week of data entry, they spend 3 hours/week on review and approval. That's an 80% time reduction at approximately $0.02 per invoice in Claude API costs.
Example 2: Lead Enrichment and Qualification
A B2B SaaS client wanted to qualify inbound leads before routing them to sales reps. Their form collected name, email, company, and a free-text "tell us about your needs" field. The sales team was wasting hours chasing unqualified leads.
The Workflow
Trigger: Webhook from their website form (HubSpot form submission).
Extract: An HTTP Request node pulls the company's LinkedIn data and website content. A second node checks Clearbit for firmographic data (employee count, industry, revenue estimate).
Reason: All the enriched data goes to Claude:
// System prompt for lead qualification
const systemPrompt = `You are a B2B lead qualification system for a SaaS
company selling project management software. Score each lead 1-100 and
classify as HOT, WARM, or COLD.
Scoring criteria:
- Company size 50-500 employees: +30 points
- Industry in [tech, consulting, agency, manufacturing]: +20 points
- Message mentions pain points [deadlines, visibility, collaboration]: +25 points
- Decision maker title [VP, Director, Head of, C-level]: +25 points
Return JSON: {score, classification, reasoning, suggested_talk_track}`;
// User message assembled from enriched data
const userMsg = `Lead submission:
Name: ${lead.name}
Title: ${lead.title}
Company: ${lead.company} (${firmographic.employees} employees,
${firmographic.industry}, est. revenue ${firmographic.revenue})
Message: "${lead.message}"
Website summary: ${websiteSummary}`;
Act: Based on Claude's classification:
- HOT (70+): Immediately create an opportunity in HubSpot, assign to senior rep, send Slack alert with Claude's suggested talk track.
- WARM (40–69): Add to nurture sequence, tag in CRM for follow-up within 48 hours.
- COLD (<40): Add to marketing email list, no sales action.
Result: the sales team's meeting-to-close rate improved by 35% in the first month because they were spending time on qualified leads instead of tire-kickers.
Setting Up n8n with Claude: The Practical Details
Here's how to get a production-ready n8n instance running with Claude API access.
Deployment
# docker-compose.yml for production n8n
version: '3.8'
services:
n8n:
image: n8nio/n8n:latest
restart: always
ports:
- "5678:5678"
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=${N8N_PASSWORD}
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
- N8N_ENCRYPTION_KEY=${ENCRYPTION_KEY}
- WEBHOOK_URL=https://n8n.yourdomain.com/
volumes:
- n8n_data:/home/node/.n8n
depends_on:
- postgres
postgres:
image: postgres:16-alpine
restart: always
environment:
- POSTGRES_DB=n8n
- POSTGRES_USER=n8n
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
n8n_data:
postgres_data:
Put this behind an Nginx reverse proxy with TLS (Let's Encrypt) and you're production-ready. Total infrastructure cost on a t3.small EC2 instance: about $20/month.
Claude API Credentials in n8n
n8n doesn't have a native Anthropic node yet, but the HTTP Request node works perfectly. Store your API key as a credential of type "Header Auth":
- Name:
x-api-key - Value: Your Anthropic API key
Then in every HTTP Request node that calls Claude, select this credential and add the anthropic-version: 2023-06-01 header manually.
Error Handling and Reliability
Production AI workflows need to handle failures gracefully. Here's what we always configure:
- Retry logic. Claude API occasionally returns 529 (overloaded) or 500 errors. Configure the HTTP Request node with 3 retries and exponential backoff (1s, 2s, 4s).
- JSON validation. Claude doesn't always return valid JSON, especially with complex schemas. Add a Code node after the API call that wraps
JSON.parse()in a try/catch. On failure, retry the API call with an appended message: "Your previous response was not valid JSON. Please return only the JSON object." - Token budget guards. Before sending content to Claude, estimate the token count (roughly 4 characters per token for English). If the input exceeds your budget, truncate or chunk it. We cap most workflows at 4,000 input tokens to keep costs predictable.
- Dead letter queue. Any workflow execution that fails after retries gets routed to a Slack channel and a database table for manual review. Never silently drop a failed execution.
Cost tip: Use claude-haiku-4-5-20251001 for simple extraction and classification tasks. Reserve claude-sonnet-4-20250514 for complex reasoning. A typical invoice extraction costs $0.001–0.003 with Haiku vs $0.008–0.015 with Sonnet. At 200 invoices/day, that's the difference between $6/month and $45/month.
Common Workflow Ideas to Get Started
Beyond the two examples above, here are workflows we've built for clients that take less than a day to implement:
- Support ticket classification: Email or form submission → Claude categorizes by department, urgency, and product area → routes to the right team in Zendesk/Freshdesk.
- Contract clause extraction: PDF upload to Google Drive → extract text → Claude identifies key terms (renewal dates, termination clauses, payment terms) → populate a Google Sheet for legal review.
- Meeting notes summary: Otter.ai or Whisper transcript → Claude generates structured summary with action items and owners → posts to Slack and creates tasks in Asana.
- Competitor monitoring: Scheduled RSS feed checks → Claude summarizes new competitor blog posts/product announcements → weekly digest email to the product team.
- Resume screening: Applicant tracking webhook → Claude scores against job requirements → populates a shortlist with reasoning for the hiring manager.
When Not to Use This Pattern
This approach isn't right for everything. Skip n8n + Claude when:
- You need sub-second latency. n8n adds overhead, and Claude API calls take 1–5 seconds. If you're building a real-time chatbot, use a direct API integration.
- Your workflow is purely deterministic. If every step is a simple API-to-API mapping with no unstructured data, n8n alone (without Claude) is sufficient and cheaper.
- You're processing millions of records. n8n handles hundreds of thousands of executions well, but at true Big Data scale, you need a proper data pipeline (Airflow, Step Functions) with Claude API calls embedded in your processing code.
Getting Started
The fastest path to production: pick your highest-volume manual task that involves reading unstructured content and producing structured output. Build the workflow in n8n with Claude. Run it in parallel with your manual process for two weeks. Measure the accuracy. If it's above 95%, flip the switch and let the human do review-only.
Most teams go from "we should try AI" to "this is saving us 20 hours a week" in under a month. The combination of n8n's integration library and Claude's reasoning capability makes it possible to automate workflows that would have required a full engineering team just two years ago.