How to Build Your First AI Workflow with n8n and Claude Code (2026 Guide)
Workflow automation is one of those skills that pays dividends across every type of business. In this guide, I'll show you how to set up n8n, connect it to Claude Code, and automate a real business process — step by step.
Disclosure: This article contains affiliate links. If you sign up through links, I may earn a commission.
Why n8n + Claude Code?
n8n is a powerful, open-source workflow automation platform. Unlike Zapier, it gives you full control over your automations without locking you into expensive subscription tiers.
Claude Code brings genuine reasoning to your automations. Instead of just moving data from A to B, you can have Claude analyze, categorize, and respond intelligently to every trigger.
Together: a workflow that thinks.
What We're Building
An AI-powered lead qualification system:
- New form submission arrives (webhook trigger)
- Claude analyzes the lead data
- Claude categorizes the lead as Hot/Warm/Cold
- Claude drafts a personalized first response
- Results get stored and a notification is sent
This is the kind of automation that replaces 30 minutes of manual work per lead.
Prerequisites
- Node.js 18+ installed
- Claude Code installed (
npm install -g @anthropic-ai/claude-code) - n8n running locally or in the cloud (free tier available)
- Basic understanding of REST APIs
Step 1: Install n8n
The easiest way to get started locally:
npm install -g n8n
n8n start
n8n will be available at http://localhost:5678. Create your first workflow.
Step 2: Set Up the Webhook Trigger
In n8n, add a Webhook node.
Set the HTTP Method to POST. This is your trigger — whenever something submits data to the webhook URL, the workflow runs.
Copy the webhook URL. You'll use this as your form submission endpoint.
Test it: send a test payload with curl:
curl -X POST https://your-webhook-url \
-H "Content-Type: application/json" \
-d '{"name":"John","email":"john@example.com","message":"Interested in your service"}'
You should see the data appear in n8n.
Step 3: Connect Claude Code
Add a Code node after the Webhook. This is where Claude processes the data.
const lead = $json;
const prompt = `Analyze this lead and return JSON with:
- score: number 1-100 (how likely to convert)
- category: "hot" | "warm" | "cold"
- response_tone: "aggressive" | "casual" | "professional"
- priority: "high" | "medium" | "low"
Lead data: ${JSON.stringify(lead)}
Return ONLY valid JSON, no explanation.`;
return { prompt, lead };
Wait — that won't actually call Claude. For that, you need Claude Code running as a local server.
The Real Integration: Claude Code as an n8n Node
n8n has an HTTP Request node you can use to call Claude's API directly:
Configure the HTTP Request node:
- Method: POST
-
URL:
https://api.anthropic.com/v1/messages - Headers:
x-api-key: YOUR_ANTHROPIC_API_KEY
anthropic-version: 2023-06-01
content-type: application/json
- Body Content Type: Raw (JSON)
- Body:
{
"model": "claude-sonnet-4-20250514",
"max_tokens": 1024,
"messages": [{
"role": "user",
"content": "{{ $json.prompt }}"
}]
}
The response comes back as Claude's JSON output. Use n8n's Edit Fields node to extract the fields you need.
Step 4: Route Based on Lead Score
Add a Split In Batches or IF node:
{{ $json.category }} === "hot" → Send Slack notification + CRM update
{{ $json.category }} === "warm" → Add to email nurture sequence
{{ $json.category }} === "cold" → Add to weekly digest
This is where automation stops being a toy and becomes genuinely useful.
Step 5: Store Results
Add a PostgreSQL or Supabase node to store the enriched lead data:
INSERT INTO leads (name, email, score, category, created_at)
VALUES ('{{ $json.lead.name }}',
'{{ $json.lead.email }}',
{{ $json.score }},
'{{ $json.category }}',
NOW())
ON CONFLICT (email) DO UPDATE SET
score = EXCLUDED.score,
category = EXCLUDED.category;
Now you have a historical record of every lead and how Claude scored it.
Real Numbers
I run this exact workflow for a consulting client. Results after 90 days:
- 340 leads processed automatically
- Average qualification time: 8 seconds per lead (vs. 25 minutes manual)
- Hot leads responded to within 3 minutes of submission
- Conversion rate on AI-qualified hot leads: 23% (vs. 11% manual qualification)
The automation paid for itself in week 2.
Cost Analysis
n8n: Free (self-hosted) or $20/month (cloud)
Claude API: ~$0.01-0.05 per lead processed
Email service: $0-20/month
Total cost per lead: approximately $0.02-0.05
The value: you respond to hot leads in 3 minutes instead of 3 hours. In sales, speed is everything.
Getting Started Today
- Install n8n (
n8n start) - Set up your first webhook
- Get an Anthropic API key
- Start small — automate one process first
The n8n community has thousands of pre-built templates. Find one close to what you need and modify it.
n8n has a generous free tier for self-hosting. If you want to support this guide at no extra cost to you, you can use this affiliate link when you sign up for n8n Cloud — though self-hosting is free and equally capable.
Have you automated any workflows with AI? What processes are you running? I'd love to hear what's working — drop it in the comments.
Top comments (0)