n8n Automations with Claude Code: Practical Guide
The Missing Link in Your AI Stack
You have Claude Code for development, Claude API for reasoning, and a dozen SaaS tools running your business. The problem is everything lives in silos. A form arrives, you process it manually, copy data to the CRM, send an email, log it in a spreadsheet. Every step: you.
n8n is the glue between Claude and the rest of your stack. A visual workflow where each node does one thing: receive a webhook, call Claude's API, write to Notion, send to Slack. All with real code when the logic demands it.
What makes the n8n + Claude Code combination special isn't just that they work together. It's that you can use Claude Code to build the n8n workflows themselves — generate configuration JSON, debug node errors, and design entire automation architectures from the terminal.
What Is n8n and Why Choose It Over Zapier or Make
n8n is an open-source, self-hostable workflow automation platform. Unlike Zapier or Make, you can install it on your own server and run flows without operation limits or per-execution costs.
Key advantages for AI projects:
- Native HTTP Request node: call any API including Anthropic's, without special integrations
- JavaScript/Python code in any node: complex logic exactly where you need it
- Unlimited triggers: webhooks, cron, email, database changes, GitHub events...
- Self-hosting: your data never leaves your infrastructure — critical for sensitive projects
- Active community: over 1,000 native integrations already built
To install locally or on a VPS:
# With Docker (recommended)
docker run -d \
--name n8n \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
n8nio/n8n
# Or with npm
npm install n8n -g
n8n start
Once running, access it at http://localhost:5678. The interface is visual: drag nodes, connect them, configure each one.
Claude API as a Node in n8n
n8n doesn't have a native Anthropic node yet (though the community is working on it), but the HTTP Request node is more than enough to call Claude's API with full control.
HTTP Request Node Config for Claude
{
"method": "POST",
"url": "https://api.anthropic.com/v1/messages",
"headers": {
"x-api-key": "={{ $env.ANTHROPIC_API_KEY }}",
"anthropic-version": "2023-06-01",
"content-type": "application/json"
},
"body": {
"model": "claude-opus-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "={{ $json.prompt }}"
}
]
}
}
$json.prompt is the variable coming from the previous node in your workflow. You can build dynamic prompts by concatenating data from the trigger: the text of an email, form content, a commit diff.
Claude's response arrives at $json.content[0].text. From there, the next node can write it to Notion, send it via Slack, store it in a database, or trigger another workflow.
Use Case 1: Intelligent Content Publishing Pipeline
This workflow automates the review and publication of new blog content:
- Trigger: webhook fires when there's a new commit to
content/blog/ - HTTP Node (GitHub API): fetches the diff of the new MDX file
- HTTP Node (Claude API): analyzes the content and generates a Twitter/X thread and a LinkedIn post
- If Node: if the article's SEO score is ≥ 80, publishes immediately; otherwise creates a Notion task for manual review
- Slack Node: notifies the team with the summary and generated links
The critical step is the prompt you send to Claude. A real example:
You are the community manager for a frontend and AI tech blog.
Here is a new article:
TITLE: {{ $json.title }}
DESCRIPTION: {{ $json.description }}
EXCERPT: {{ $json.excerpt }}
Generate:
1. A 3-tweet thread in English, technical and approachable tone
2. A 150-word LinkedIn post with emojis and hashtags
Return JSON with keys "twitter_thread" (array) and "linkedin_post" (string).
The key is requesting structured JSON. The next node can parse the response and route each piece to the right channel.
Use Case 2: AI-Powered Lead Qualification
A contact form arrives with name, company, role, and project description. Instead of reading it yourself and deciding if it merits a call, Claude does the first pass:
Workflow: Form → Claude → CRM + Slack
The qualification prompt:
Analyze this lead and score it based on these criteria:
COMPANY: {{ $json.company }}
ROLE: {{ $json.role }}
PROJECT: {{ $json.project_description }}
BUDGET: {{ $json.budget }}
Return JSON with:
- score: number from 1 to 10 (10 = ideal lead)
- reasoning: 2 sentences explaining the score
- priority: "high" | "medium" | "low"
- suggested_response: personalized reply draft (max 100 words)
With a score ≥ 7, the workflow automatically creates a deal in HubSpot or Pipedrive, sends the response draft to Slack for one-click review and approval, and schedules a follow-up reminder. Leads scoring < 4 receive a polite automated reply and land in a nurturing list.
Well-calibrated, this type of automation can eliminate 70% of manual qualification work without missing a single important lead.
Building n8n Workflows with Claude Code from Scratch
n8n exports and imports its workflows as JSON. That means you can ask Claude Code to generate the complete JSON for a workflow from a natural language description — without opening the n8n visual interface at all.
Step 1: Describe the workflow in your terminal
claude "Create the JSON for an n8n workflow with these nodes:
1. Schedule Trigger: every day at 9am
2. Read Binary File: reads the file content/blog/last-post.md
3. HTTP Request POST to https://api.anthropic.com/v1/messages with the Claude API,
sending the file content as a prompt to generate a 3-point summary
4. Slack: sends the summary to the #blog-updates channel
Use $env.ANTHROPIC_API_KEY and $env.SLACK_WEBHOOK_URL for credentials.
Return only the workflow JSON, ready to import into n8n."
Step 2: Review the generated JSON
Claude Code returns something like this (simplified for clarity):
{
"name": "Daily Blog Summary",
"nodes": [
{
"name": "Schedule Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"parameters": {
"rule": { "interval": [{ "field": "hours", "hoursInterval": 24 }] },
"triggerAtHour": 9
},
"position": [250, 300]
},
{
"name": "Read Blog Post",
"type": "n8n-nodes-base.readBinaryFile",
"parameters": {
"filePath": "content/blog/last-post.md"
},
"position": [450, 300]
},
{
"name": "Claude Summarize",
"type": "n8n-nodes-base.httpRequest",
"parameters": {
"method": "POST",
"url": "https://api.anthropic.com/v1/messages",
"headers": {
"values": [
{ "name": "x-api-key", "value": "={{ $env.ANTHROPIC_API_KEY }}" },
{ "name": "anthropic-version", "value": "2023-06-01" }
]
},
"body": {
"model": "claude-sonnet-4-6",
"max_tokens": 512,
"messages": [{
"role": "user",
"content": "Summarize in 3 key points:\n\n={{ $binary.data.toString() }}"
}]
}
},
"position": [650, 300]
},
{
"name": "Slack Notify",
"type": "n8n-nodes-base.slack",
"parameters": {
"operation": "postMessage",
"channel": "#blog-updates",
"text": "={{ $json.content[0].text }}"
},
"position": [850, 300]
}
],
"connections": {
"Schedule Trigger": { "main": [[{ "node": "Read Blog Post", "type": "main", "index": 0 }]] },
"Read Blog Post": { "main": [[{ "node": "Claude Summarize", "type": "main", "index": 0 }]] },
"Claude Summarize": { "main": [[{ "node": "Slack Notify", "type": "main", "index": 0 }]] }
}
}
Step 3: Import into n8n
- Save the JSON to a file:
workflow-blog-summary.json - In n8n: hamburger menu → Import from File → select the file
- The workflow appears in the interface with all nodes already connected
- Click each node to verify parameters and add credentials from n8n's vault
- Activate the workflow with the toggle in the top-right corner
In under 5 minutes you have a working workflow without having dragged a single node manually.
Iterating with Claude Code when something's off
If after testing you see the Slack node isn't receiving the right format, describe the problem to Claude Code directly:
claude "The Slack node in my n8n workflow receives text from Claude
but includes the full JSON response instead of just the text.
Claude's response has this structure:
{ content: [{ type: 'text', text: '...' }] }
How do I adjust the Slack node's 'text' field to extract only the text?"
Claude Code returns the correct expression: ={{ $json.content[0].text }} and explains why it works. No need to browse the n8n docs — describe the problem in plain language and get the fix.
Debugging Existing Workflows with Claude Code
When an existing workflow fails, export the complete JSON (workflow menu → Download) and hand it to Claude Code with the error message:
claude "This n8n workflow fails with:
'Cannot read properties of undefined (reading content)'
at node 'Process Claude Response'.
Here is the workflow JSON: [paste JSON]
Identify the problem and give me the corrected JSON."
Claude Code reads the workflow structure, detects that content[0].text fails when the API returns an error instead of a valid response, and proposes adding an IF node before it that checks whether $json.error exists, routing errors to a separate log.
Recommended Architecture for Production
For using n8n + Claude in real production, here are the architecture decisions we make in our AI integration projects:
| Decision | Option A | Option B |
|---|---|---|
| n8n Hosting | n8n Cloud (managed) | Docker on VPS (full control) |
| API Keys | Environment vars in n8n ($env.KEY) | External secret manager |
| Claude Model | claude-sonnet-4-6 (cost/quality balance) | claude-opus-4-6 for critical tasks |
| Rate limiting | Wait node between Claude calls | Queue with RabbitMQ for high volume |
| Logging | n8n execution history | Export to Datadog / Grafana |
To get started, n8n Cloud's free plan (up to 5 active workflows) with claude-sonnet-4-6 is enough to validate most automations. Once the ROI is clear, you migrate to self-hosted and control costs.
Conclusion
n8n + Claude Code dramatically reduces the cost of implementing intelligent automations in real businesses. n8n provides the visual infrastructure and integrations; Claude provides the reasoning; Claude Code helps you build and debug workflows without needing to be an n8n expert.
The result: flows that previously required weeks of custom development can now be prototyped in hours and put into production in days.
If you want to implement these kinds of automations in your business or project, tell me what processes you want to automate and we'll design it together:
Let's talk about automating your business with n8n and Claude →