DEV Community

Sangmin Lee
Sangmin Lee

Posted on • Originally published at claudeguide.io

Claude API + n8n: Build AI Workflows in 30 Minutes (2026)

Originally published at claudeguide.io/claude-api-n8n-automation

Claude API + n8n: Build AI Workflows in 30 Minutes (2026)

n8n is the most flexible workflow automation tool for connecting Claude API to your stack — Postgres, Slack, Gmail, Notion, Stripe, 400+ integrations. The HTTP Request node calls Claude in 3 fields, and you can build email triage, content generation, lead scoring, or RAG pipelines without writing code. Self-hosted n8n costs $0 (Docker), cloud starts at $20/month. With Claude Haiku at $1/M input tokens, full workflows cost $5-50/month for SMB usage. This guide covers connection setup, 5 production templates, error handling, and cost optimization.

For Claude API basics see the Python tutorial. For an alternative no-code option, the Vercel AI SDK is code-first but lower setup.


Why n8n vs Zapier vs Make

Dimension n8n Zapier Make
Free tier Self-host unlimited 100 tasks/mo 1,000 ops/mo
Pricing (10K runs) $20/mo cloud ~$70/mo ~$25/mo
AI integrations HTTP node + Claude/OpenAI nodes OpenAI native, Claude via webhook OpenAI native
Self-hostable Yes No No
JavaScript code Built-in Function nodes Limited Limited
Best for Devs, complex flows Marketers, simple flows Visual + JSON workflows

For Claude-heavy workflows, n8n wins on: free self-host, full HTTP control, JavaScript escape hatch.


Setup: Claude API in n8n (3 minutes)

Option A: HTTP Request node (universal)

  1. n8n → New workflow → Add HTTP Request node
  2. Method: POST
  3. URL: https://api.anthropic.com/v1/messages
  4. Authentication: Header Auth → Name: x-api-key, Value: {your-claude-key}
  5. Headers: add anthropic-version: 2023-06-01 and content-type: application/json
  6. Body Content Type: JSON
  7. JSON body:
{
  "model": "claude-sonnet-4-5",
  "max_tokens": 1024,
  "messages": [{"role": "user", "content": "{{ $json.prompt }}"}]
}
Enter fullscreen mode Exit fullscreen mode

Test → you get Claude's response in $json.content[0].text for downstream nodes.

Option B: Anthropic node (community)

The n8n-nodes-anthropic community node simplifies syntax. Install via:

npm install n8n-nodes-anthropic  # self-hosted only
Enter fullscreen mode Exit fullscreen mode

Then drag the Anthropic node, paste your API key once, select model from dropdown.


Template 1: Email Triage Pipeline

Trigger: Gmail new email → Claude classifies → Slack routes

Gmail Trigger → HTTP (Claude) → Switch → Slack (per category)
Enter fullscreen mode Exit fullscreen mode

Claude prompt:

Classify this email into ONE category:
- urgent_customer
- sales_lead
- billing_question
- spam
- other

Respond with just the category name.

Email subject: {{ $json.subject }}
Email body: {{ $json.body }}
Enter fullscreen mode Exit fullscreen mode

Switch node routes by Claude's output. Urgent → #support-urgent. Leads → #sales. Done in 8 nodes.

Cost: 500 emails/day × Haiku ($1/M tokens) = ~$0.15/day = $4.50/mo.


Template 2: Notion → Blog Post Generator

Trigger: Notion DB row created with status="Draft" → Claude writes post → Notion updates row

Notion Trigger → HTTP (Claude write) → HTTP (Claude SEO check) → Notion Update
Enter fullscreen mode Exit fullscreen mode

Claude prompt for writing:

Write a 1500-word blog post on this topic.

Topic: {{ $json.title }}
Keywords: {{ $json.keywords }}
Audience: {{ $json.audience }}

Output markdown only. Include H2 sections and FAQ at bottom.
Enter fullscreen mode Exit fullscreen mode

Second Claude call validates structure (H1+FAQ+data point). If pass, save to Notion as "Ready". If fail, save as "Needs revision" with feedback.

Cost: 1 post/day × Sonnet ($3/$15) for 4K tokens = ~$0.15/post = $4.50/mo.


Template 3: Lead Scoring + Enrichment

Trigger: Webhook (from form) → Claude scores → Postgres stores → Slack alerts high-score



Webhook → HTTP (Claude scoring) → Postgres Insert → IF (score
Enter fullscreen mode Exit fullscreen mode

Top comments (0)