M
MJK.Supplies
Home / n8n / n8n Claude Integration: Automate with Anthropic'…
n8n

n8n Claude Integration: Automate with Anthropic's Most Powerful AI

Combining n8n's automation power with Claude's AI reasoning creates one of the most capable AI workflow stacks available. n8n handles triggers, data routing, and integrations; Claude handles intelligence, reasoning, and generation. This guide is the complete technical reference for integrating Claude into n8n workflows.

M
MJK Supplies · Jun 8, 2026 · 12 min read
ShareXinf↗
n8n Claude Integration: Automate with Anthropic's Most Powerful AI

Setting Up the Claude API Connection

n8n doesn't have a native Claude node, but the HTTP Request node handles everything:

Step 1: Store your API key In n8n settings → Credentials → Create new credential → HTTP Header Auth:

  • Name: x-api-key
  • Value: your Anthropic API key (sk-ant-...)

Step 2: HTTP Request node configuration

  • Method: POST
  • URL: https://api.anthropic.com/v1/messages
  • Authentication: Header Auth → your created credential
  • Headers (add these manually):

- anthropic-version: 2023-06-01 - content-type: application/json

  • Body: JSON (raw)

Step 3: Request body template

{ "model": "claude-sonnet-4-6", "max_tokens": 1024, "messages": [ { "role": "user", "content": "={{ $json.inputText }}" } ] }

The ={{ }} syntax in n8n makes the field an expression that references data from previous nodes.

Adding a System Prompt

For consistent Claude behavior across workflow runs:

{ "model": "claude-sonnet-4-6", "max_tokens": 1024, "system": "You are an email classifier. Respond with exactly one of these categories: support, sales, billing, spam. No other text.", "messages": [ { "role": "user", "content": "Subject: {{ $json.emailSubject }}\n\nBody: {{ $json.emailBody }}" } ] }

Extracting Claude's Response

After the HTTP Request node, add a Code node to extract Claude's text:

// Code node — extract Claude response const response = $input.first().json; // Extract text from Claude's response structure const text = response.content[0].text; return [{ json: { claudeResponse: text, inputUsage: response.usage.input_tokens, outputUsage: response.usage.output_tokens } }];

Parsing Structured JSON Responses

For workflows that need structured data from Claude, instruct it to respond in JSON:

System prompt:

You are a lead classifier. For each lead description, return a JSON object with this exact structure: { "category": "hot|warm|cold", "score": 1-10, "primary_pain": "one sentence description", "recommended_action": "specific next action" } Return only the JSON, no other text.

Code node to parse:

const response = $input.first().json; const text = response.content[0].text; // Parse the JSON Claude returned const parsed = JSON.parse(text.trim()); return [{ json: parsed }];

Dynamic Prompts from Workflow Data

The most powerful pattern: building Claude prompts from upstream workflow data.

Code node (Build Prompt):

const contact = $input.first().json; const companyData = $node["Clearbit Lookup"].json; const prompt = `Write a personalised cold email for this prospect: Name: ${contact.firstName} ${contact.lastName} Title: ${contact.jobTitle} Company: ${contact.company} Company size: ${companyData.metrics?.employees || 'unknown'} Recent company news: ${companyData.company?.description || 'none found'} Our product: [Product name] helps [ICP] to [value prop]. Write a 5-sentence cold email that references their specific company context. Be specific, not generic. No greetings like "I hope this email finds you well." End with a single, specific CTA.`; return [{ json: { prompt } }];

Then this prompt field feeds into the Claude HTTP node body.

Multi-Step AI Workflows

Chain multiple Claude calls for complex tasks:

Blog post generation workflow:

Node 1: Schedule trigger (Monday 9am) Node 2: Airtable (get this week's article topics) Node 3: Loop (process each topic) Node 4: HTTP → Claude (generate detailed outline) Node 5: HTTP → Claude (expand outline to full article) Node 6: HTTP → Claude (review and suggest improvements) Node 7: HTTP → Claude (apply improvements) Node 8: WordPress API (create draft) Node 9: Slack (notify content team)

Each Claude node builds on the previous. The review-revise cycle significantly improves output quality.

Error Handling

AI API calls can fail. Add error handling to Claude workflows in n8n:

Add an Error Trigger node: Connect it to the HTTP Request node. If Claude call fails, it routes here.

Retry logic in Code node:

// Before Claude call, check if we're retrying const retryCount = $input.first().json.retryCount || 0; if (retryCount > 3) { throw new Error('Max retries exceeded for Claude call'); } return [{ json: { ...$input.first().json, retryCount: retryCount + 1 } }];

Rate limit handling: Claude API returns 429 for rate limits. Add a Wait node before retry:

  • Add IF node: if response status 429 → Wait (60 seconds) → retry
  • Otherwise → continue normally

Recommended Tools

  • n8n — The automation platform
  • Claude API — AI reasoning and generation
  • Airtable — Data management layer
  • HubSpot — CRM integration
  • Clearbit — Lead enrichment in n8n + Claude workflows
#n8n#claude#anthropic#integration

Related articles

MJK Supplies · Automation Services

Want this built for you?

We design and ship custom AI agents and automation systems for teams that want results, not a backlog. Book a free 30-minute consult — no commitment, no pitch deck.