Most AI automation tutorials fall into one of two traps: they either require writing hundreds of lines of Python, or they use Zapier with a "send to ChatGPT" step and call it "AI-powered." Neither is satisfying if you want real autonomous behavior — workflows that reason, classify, summarize, and make decisions.
n8n with Claude changes that equation. You get a visual workflow builder with 400+ integrations, combined with one of the most capable AI models available. The result: genuinely intelligent automations without fighting with Python environments, rate limits, or Zapier's 100-step task limits.
This guide builds three real workflows: an email assistant, a Slack classifier, and a content review pipeline. By the end, you'll have a working template for any workflow where an AI needs to make a decision or process text.
Try n8n Free
n8n offers a generous free tier for self-hosting and a cloud trial. No credit card required to start. The cloud version gets you going in minutes — self-hosting gives you full control and no per-task pricing.
Start with n8n →Why n8n + Claude Is the Right Combination
Before building, it's worth understanding why this pairing works better than alternatives.
n8n advantages over Zapier / Make
- Self-hostable: Your data never leaves your infrastructure if you use the Docker version
- Code nodes: When you need to do something custom, drop in JavaScript or Python — without leaving the workflow editor
- No per-task pricing: Self-hosted n8n has no execution limits; cloud tiers are generous
- Native HTTP nodes: Direct Claude API calls without waiting for an official integration
- Webhook triggers: Any external system can trigger a workflow instantly
Claude advantages for automation
- 200K context window: Process entire documents, email threads, or log files in a single call
- Instruction following: Claude reliably produces structured output (JSON, markdown tables) when you ask for it — critical for automation
- Reasoning before output: Claude naturally explains its classification or summary before giving the answer, making debugging easier
- Low hallucination rate on structured tasks: When you constrain output format tightly, Claude stays in bounds
claude-haiku-4-5 for high-volume,
simple classification tasks (fast, cheap) and claude-sonnet-4-6 for complex summarization
or drafting tasks (smarter, worth the cost).
Setup: n8n + Claude API in 10 Minutes
Step 1: Get your Claude API key
Go to console.anthropic.com, create an account, and generate an API key. Keep it somewhere secure — you'll paste it into n8n shortly.
Anthropic's usage-based pricing means small automations cost almost nothing. A Haiku call for classifying an email costs roughly $0.0001. Even running 1,000 email classifications per month stays under $1.
Step 2: Start n8n
Cloud (fastest start): Sign up at n8n.io — you get a trial instance immediately. No setup required.
Self-hosted with Docker (recommended for production):
docker run -it --rm \
--name n8n \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
n8nio/n8n
Open http://localhost:5678 and create your admin account. That's it — your n8n instance is running.
Step 3: Store your Claude API key in n8n
In n8n, go to Settings → Credentials → New Credential → Header Auth. Name it "Claude API" and add a header:
Name: x-api-key
Value: sk-ant-api03-YOUR_KEY_HERE
You'll reference this credential in every workflow's HTTP node that calls Claude.
Workflow 1: AI Email Assistant
This workflow triggers on incoming emails, summarizes them with Claude, classifies their urgency, and drafts a reply suggestion — all within 5 seconds.
The workflow nodes
Node 1: Gmail Trigger
Set to trigger on new emails in your inbox. Filter by label if you want to process only specific emails (e.g., "support").
Node 2: HTTP Request (Claude API)
This is the core node. Set it up as:
- Method: POST
- URL:
https://api.anthropic.com/v1/messages - Authentication: Header Auth (your Claude credential)
- Add header:
anthropic-version: 2023-06-01 - Body (JSON):
{
"model": "claude-haiku-4-5-20251001",
"max_tokens": 512,
"messages": [
{
"role": "user",
"content": "Analyze this email and respond with JSON only:\n\nEmail from: {{ $json.from }}\nSubject: {{ $json.subject }}\nBody: {{ $json.text }}\n\nRespond with:\n{\n \"summary\": \"2-sentence summary\",\n \"urgency\": \"high|medium|low\",\n \"category\": \"support|sales|info|spam\",\n \"suggested_reply\": \"brief reply draft\"\n}"
}
],
"system": "You are an email assistant. Always respond with valid JSON matching exactly the format requested. No extra text."
}
Node 3: Code Node (parse response)
Claude returns the response inside content[0].text. Parse it:
const response = $json.content[0].text;
const parsed = JSON.parse(response);
return [{ json: parsed }];
Node 4: IF Node (route by urgency)
Branch the workflow: high urgency → Slack alert + page on-call; medium → Slack summary; low → log to Notion.
Node 5: Slack node
Post the summary and suggested reply to your #email-triage channel.
Workflow 2: Slack Message Classifier
If your team uses Slack for customer support, this workflow monitors a channel, classifies incoming messages, and routes them to the right person or queue.
The classification prompt
Classification prompts work best when you give Claude a fixed taxonomy. Vague categories like "complaint" get inconsistent results; explicit ones work every time:
{
"model": "claude-haiku-4-5-20251001",
"max_tokens": 256,
"system": "You classify customer support messages. Always respond with exactly one JSON object. No other text.",
"messages": [
{
"role": "user",
"content": "Classify this message:\n\n\"{{ $json.text }}\"\n\nCategories:\n- BUG: User reporting something broken\n- FEATURE: Feature request or suggestion\n- BILLING: Payment, invoice, subscription question\n- HOWTO: How to use the product\n- OTHER: Doesn't fit the above\n\nRespond: {\"category\": \"...\", \"confidence\": 0.0-1.0, \"summary\": \"one sentence\"}"
}
]
}
Routing logic
After classification, use a Switch node to route:
- BUG → create GitHub issue, post to #bugs channel with Claude's one-line summary
- BILLING → create Stripe customer lookup, post to #billing with account link
- HOWTO → search your knowledge base (Notion, Confluence) and post the top result
- FEATURE → add to product feedback spreadsheet
confidence < 0.7, route to a human review queue
instead of auto-assigning. Claude is honest about uncertainty — use it.
Workflow 3: Content Review Pipeline
This is the most involved workflow — a full content approval pipeline where Claude reviews drafts, scores them against criteria, and either approves or requests revisions with specific feedback.
The review prompt
{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"system": "You are a content editor for a technical blog targeting developers. Be specific and actionable in feedback. Always respond with valid JSON.",
"messages": [
{
"role": "user",
"content": "Review this article draft and score it:\n\nTitle: {{ $json.title }}\n\n{{ $json.content }}\n\nEvaluate on:\n1. Technical accuracy (1-10)\n2. Clarity for target audience (1-10)\n3. Actionability — does the reader know what to do? (1-10)\n4. Code quality if present (1-10, or null)\n\nRespond:\n{\n \"scores\": {\"accuracy\": N, \"clarity\": N, \"actionability\": N, \"code\": N},\n \"average\": N,\n \"approved\": true/false,\n \"feedback\": [\"specific issue 1\", \"specific issue 2\"],\n \"top_strength\": \"what works best\"\n}"
}
]
}
Decision node
After parsing Claude's response:
// Approve if average score >= 7
if ($json.average >= 7) {
return [{ json: { ...$json, action: 'publish' } }];
} else {
return [{ json: { ...$json, action: 'revise' } }];
}
Approved drafts get published via your CMS API. Rejected drafts trigger an email with Claude's specific feedback list — not a generic "needs work" message.
Designing Prompts for n8n Workflows
Automation prompts are different from conversational prompts. You're not talking to Claude — you're using it as a structured data processor. These principles make the difference between workflows that break and ones that run for months:
1. Always demand JSON output in the system prompt
Put "Always respond with valid JSON" in the system prompt, not just the user message. This primes the model for every call, not just the first one.
2. Show the exact schema you want
Don't describe the format — show it. Include the actual JSON structure with placeholder values in your prompt. Claude will mirror it exactly.
// Bad prompt:
"Tell me the urgency, summary, and category."
// Good prompt:
"Respond with: {\"urgency\": \"high|medium|low\", \"summary\": \"...\", \"category\": \"...\"}"
3. Use a parsing safety net
Claude occasionally adds a sentence before or after the JSON. Wrap your parse in a try/catch and use a regex to extract the JSON block:
const text = $json.content[0].text;
// Extract JSON even if there's surrounding text
const match = text.match(/\{[\s\S]*\}/);
if (!match) throw new Error('No JSON found in response');
const parsed = JSON.parse(match[0]);
return [{ json: parsed }];
4. Set max_tokens conservatively
For classification: 128-256 tokens. For summaries: 256-512. For drafting: 1024-2048. Setting too high wastes money; setting too low truncates output. For JSON workflows, truncated JSON is worse than no JSON.
5. Test with edge cases before deploying
Run your workflow manually with: an empty input, an input in a language you didn't expect, an input that's 10x longer than usual, and an adversarial input trying to break the JSON format. Fix each one before going live.
Error Handling and Retries
Production workflows hit Claude API errors eventually — rate limits, temporary outages, malformed responses. n8n has built-in tools for all of these:
Rate limit handling
In your HTTP node settings, enable Retry on Fail with:
- Max tries: 3
- Wait between tries: 5000ms
For sustained high-volume workflows, add a Wait node (1-2 seconds) between batches to stay within Anthropic's rate limits.
JSON parse failures
When Claude returns malformed JSON, don't crash the workflow — log it and send a fallback:
try {
const parsed = JSON.parse($json.content[0].text);
return [{ json: { success: true, ...parsed } }];
} catch (e) {
// Log the raw response for debugging, return safe fallback
return [{
json: {
success: false,
raw_response: $json.content[0].text,
error: e.message,
// Safe defaults so downstream nodes don't crash
urgency: 'medium',
category: 'OTHER',
summary: 'Parse error — manual review needed'
}
}];
}
Dead letter queue
Add an Error Trigger workflow that catches any workflow failure and posts to a Slack #automation-errors channel with the full execution ID. This makes debugging production issues 10x faster.
Production Tips
Cost management
Set budget alerts in Anthropic Console. A runaway workflow that processes 10,000 documents instead of 100 can get expensive fast. Start with Haiku ($0.80/million input tokens) and only upgrade to Sonnet when you need richer output.
Caching for repeated inputs
If your workflow frequently processes the same content (e.g., a product description that gets reprocessed on every update), add a lookup step against a database before calling Claude. Cache the output — only call the API when the input has actually changed.
Logging everything
Store every Claude input and output to a database or spreadsheet. This lets you:
- Debug edge cases by replaying the exact input
- Spot prompt drift if outputs start changing unexpectedly
- Build a labeled dataset for future fine-tuning or evaluation
Versioning your prompts
Treat your Claude prompts like code. Store them in a configuration node or environment variable, not hardcoded in the HTTP body. When you update a prompt, increment a version number in your logs so you can correlate prompt changes with output quality changes.
{{ $json.field }}) can inject
user-provided content directly into your prompt. If your workflow processes untrusted input (emails,
form submissions), always sanitize — a malicious user could inject instructions that override your
system prompt. Wrap user content in XML tags to isolate it:
<user_content>{{ $json.body }}</user_content>
Getting Started
The fastest path from zero to a working AI workflow:
- Start n8n: Spin up a Docker instance or start a cloud trial at n8n.io. You'll be in the workflow editor in under 5 minutes.
- Get a Claude API key: Create an account at console.anthropic.com. Add $5 of credits to start — that's thousands of Haiku calls.
- Build Workflow 1 first: The email assistant is the simplest. It touches every pattern you'll use in more complex workflows: trigger, HTTP call to Claude, parse response, route.
- Add error handling before going live: Retry logic and a dead letter queue take 15 minutes to add and save hours of debugging later.
- Monitor costs: Set a spend alert on day one. Even with cheap models, high-volume workflows can surprise you.
Get Your Claude API Key
The Claude API powers every workflow in this guide. Anthropic's usage-based pricing starts at $0.80/million tokens with Haiku — a typical email automation workflow costs less than a dollar per month. Start with $5 of credits and scale from there.
Open Anthropic Console →What to Build Next
Once your first workflow is live, the patterns repeat: trigger, call Claude with a structured prompt, parse the JSON, route by the result. Here are high-value workflows to build next:
- Customer feedback analyzer: Process support tickets weekly, cluster by theme, surface the top 5 issues to your product team
- Automated changelog writer: Feed Claude your git commits, get a human-readable changelog for release notes
- Content moderation pipeline: Screen user-generated content before publication, with Claude providing the category and confidence score
- Meeting summarizer: Trigger on Zoom/Google Meet transcripts, produce action items and decisions in a shared Notion page
Each of these uses the same three-node pattern: trigger → Claude HTTP call → route on output. The complexity is in prompt design, not the workflow structure.
If you want to go deeper on the prompt engineering side — making Claude's output more structured and reliable for automation — read 10 Prompt Patterns for Reliable AI Agents. It covers the exact system prompt structures that make Claude behave consistently across thousands of automated calls.