n8n + Claude API: Complete Automation Guide (2026)

n8n is an open-source workflow automation tool — think Zapier but self-hosted and developer-friendly. Claude handles the intelligence layer. Together they let you build automations that actually understand content, not just route it.


Prerequisites

  • n8n running locally or on a VPS (npx n8n or Docker)
  • Anthropic API key from console.anthropic.com
  • Basic familiarity with n8n’s node interface

Step 1: Add Claude via HTTP Request Node

n8n doesn’t have a native Claude node yet, but the HTTP Request node covers everything.

Configure it:

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 (JSON):
{
  "model": "claude-sonnet-4-6",
  "max_tokens": 1024,
  "messages": [
    { "role": "user", "content": "{{ $json.input_text }}" }
  ]
}

Extract the response text with: {{ $json.content[0].text }}


Workflow 1: Email Summarizer

Automatically summarize incoming emails and send a daily digest.

Nodes: Gmail Trigger → HTTP Request (Claude) → Aggregate → Schedule Trigger → Gmail send

Claude prompt:

{   "messages": [{     "role": "user",     "content": "Summarize in 2-3 bullet points. Focus on action items.\n\nSubject: {{ $json.subject }}\n\nBody: {{ $json.body }}"   }] }

Workflow 2: Content Classifier

Route incoming support tickets to the right team by category.

Nodes: Webhook → HTTP Request (Claude) → Switch → Slack/Email

Claude prompt:

{   "messages": [{     "role": "user",     "content": "Classify this ticket into exactly one category: billing, technical, general.\nRespond with only the category word.\n\nTicket: {{ $json.message }}"   }] }

Then use the Switch node on {{ $json.content[0].text.trim() }}.


Workflow 3: Blog Post SEO Optimizer

Automatically improve meta descriptions for new WordPress posts.

Nodes: WordPress Trigger → HTTP Request (Claude) → WordPress update

Claude prompt:

{   "messages": [{     "role": "user",     "content": "Write an SEO meta description (150-160 characters). Include the primary keyword naturally. Return only the description.\n\nTitle: {{ $json.title.rendered }}\n\nExcerpt: {{ $json.excerpt.rendered }}"   }] }

Handling Rate Limits

Add a Wait node (1–2 seconds) between Claude calls when processing batches.

For high-volume workflows, use Claude’s Batch API (50% discount, async processing):

POST https://api.anthropic.com/v1/messages/batches

Tips for Production

  • Store API key in n8n’s credential manager, not hardcoded
  • Add error handling: use an Error Trigger node to catch failures
  • Log inputs/outputs: write to a Google Sheet for debugging
  • Use system prompts: add a system field for consistent behavior

Prompt Caching in n8n

If your system prompt repeats across many workflow runs, enable caching to cut costs up to 90%:

{
  "system": [
    {
      "type": "text",
      "text": "You are an expert content editor...",
      "cache_control": {"type": "ephemeral"}
    }
  ],
  "messages": [{"role": "user", "content": "{{ $json.article }}"}]
}

n8n + Claude is one of the most practical stacks for solo developers. You get the flexibility of code with the speed of a visual builder — and Claude handles anything that requires actual understanding.


Originally published at kalyna.pro