DEV Community

Cover image for n8n AI Automation: Build Intelligent Workflows with LLMs (2026)
Serhii Kalyna
Serhii Kalyna

Posted on • Originally published at kalyna.pro

n8n AI Automation: Build Intelligent Workflows with LLMs (2026)

Originally published at kalyna.pro

n8n is the open-source workflow automation platform that has quietly become the go-to choice for developers who want Zapier-level convenience without vendor lock-in. In 2026, its built-in AI nodes — combined with direct API access to Claude, GPT-4o, and Gemini — make it possible to build genuinely intelligent workflows: email summarizers, Slack Q&A bots, customer feedback classifiers, and multi-tool agents that plan and act autonomously.

What is n8n?

n8n (n-eight-n) is a fair-code licensed workflow automation tool. Like Zapier or Make, it connects apps and services through a visual canvas. Unlike them, you can self-host it for free, write custom JavaScript or Python in Code nodes, and call any HTTP API directly — including LLM providers.

Core concepts:

  • Nodes — individual steps: trigger on a Gmail message, call an HTTP endpoint, write to a Google Sheet
  • Workflows — a directed graph of nodes; data flows as JSON between them
  • Triggers — the event that starts a workflow: webhook, schedule, app event, or manual run
  • Credentials — stored API keys and OAuth tokens, configured once and reused in any node
  • Expressions{{ $json.fieldName }} syntax to reference data from previous nodes

n8n is available as n8n Cloud (hosted, from $20/month) or as a free self-hosted Docker container. The codebase is released under a fair-code license: free to self-host for individuals and small teams.

Setting Up n8n with Docker

Create a docker-compose.yml and run docker compose up -d:

version: "3.8"

services:
  n8n:
    image: n8nio/n8n:latest
    restart: unless-stopped
    ports:
      - "5678:5678"
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=changeme
      - WEBHOOK_URL=http://localhost:5678/
      - GENERIC_TIMEZONE=Europe/Kyiv
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:
Enter fullscreen mode Exit fullscreen mode

Open http://localhost:5678. The n8n_data volume persists all workflows and credentials across restarts. For production: use a reverse proxy with HTTPS, set N8N_ENCRYPTION_KEY, and change the default password.

Your First AI Workflow: Email Summarizer

Three nodes — Gmail Trigger → HTTP Request (Claude) → Gmail Send:

  1. Gmail Trigger nodeOn Message Received, filtered to label needs-summary. Passes subject, sender, body as $json.
  2. HTTP Request node — POST https://api.anthropic.com/v1/messages, header x-api-key + anthropic-version: 2023-06-01, body: {"model": "claude-sonnet-4-6", "max_tokens": 256, "messages": [{"role": "user", "content": "Summarise this email in 3 bullet points: {{ $json.text }}"}]}. Reply is at content[0].text.
  3. Gmail node (Reply) — thread ID: {{ $('Gmail Trigger').item.json.id }}, body: {{ $json.content[0].text }}.

Connect, activate, send a test email. The summary reply arrives within seconds.

Calling Claude API in n8n

n8n ships a built-in Anthropic node (v1.30+). For full control, use the HTTP Request node:

  • Method: POST
  • URL: https://api.anthropic.com/v1/messages
  • Header — x-api-key: your Anthropic API key (store as Header Auth credential)
  • Header — anthropic-version: 2023-06-01
  • Header — content-type: application/json
  • Body (JSON): {"model": "claude-sonnet-4-6", "max_tokens": 1024, "messages": [{"role": "user", "content": "{{ $json.prompt }}"}]}

Read the reply with {{ $json.content[0].text }}. For a full walkthrough including tool use, vision, and extended thinking in n8n, see the n8n Claude Automation Guide.

Build a Slack AI Bot

Four nodes — Slack Trigger → IF (filter bots) → HTTP Request (Claude) → Slack reply:

  1. Slack TriggerMessage Posted to Channel in #ask-ai, outputs text and channel
  2. IF node — condition: {{ $json.bot_id }} is empty (prevents reply loops)
  3. HTTP Request (Claude) — prompt: You are a helpful team assistant. Answer concisely: {{ $('Slack Trigger').item.json.text }}
  4. Slack nodePost Message, reply in thread using {{ $('Slack Trigger').item.json.ts }}

Add a Code node before the LLM call to fetch vector database chunks for a five-node RAG-powered Q&A bot over your documentation.

AI Data Processing Pipeline

Webhook → validate → Claude classify → route → Google Sheets:

  1. Webhook — POST endpoint receives customer_id, message, rating
  2. Code node — validate and normalise the payload
  3. HTTP Request (Claude) — prompt: Classify into BUG, FEATURE_REQUEST, COMPLAINT, PRAISE, or OTHER. Extract product area. Respond JSON only: {"category": "...", "product_area": "..."}.
  4. Switch node — BUG → Jira; COMPLAINT → Zendesk; PRAISE → Slack #wins
  5. Google Sheets — append all items: timestamp, customer_id, message, rating, category

n8n AI Agent (2026)

The AI Agent node (stable since v1.35) implements the plan-act-observe loop natively:

  • Plan — Claude receives the goal and tool descriptions, outputs a structured tool call
  • Act — n8n executes the tool (HTTP request, search, code) and captures the result
  • Observe — the result is appended to the conversation context
  • Repeat — Claude calls the next tool or outputs a final answer (max iterations: 10)

Tools to attach: Web Search (SerpAPI/Tavily), HTTP Request (internal APIs), Calculator, Google Calendar.

Practical use cases: competitive research, automated report generation, code review bots, customer support agents with live data lookup.

n8n vs Zapier vs Make

n8n Zapier Make
Pricing Free self-hosted $20+/mo (task-based) $9+/mo (op-based)
AI nodes Agent node + any LLM API OpenAI only (limited) OpenAI module only
Self-hosting Yes (Docker/Kubernetes) No No
Code execution JS + Python, full npm/PyPI Limited JS None
Integrations 400+ native + HTTP Request 6,000+ native 1,600+ native

For AI-heavy workflows or self-hosting, n8n is the clear choice. Zapier leads on integration breadth; Make is a strong middle ground for non-developers needing visual routing.

Best Practices

  • Error Trigger node — dedicated error workflow sends Slack alerts with workflow name, node, and error message
  • Wait node — 1–2 second delay between LLM batch calls prevents 429 rate-limit errors
  • Manual Trigger for development — build and debug without touching live sources; add the production trigger when stable
  • Split In Batches — process 10–50 items at a time to keep memory low and failures recoverable
  • Pin data — right-click node output to freeze test inputs; subsequent runs use pinned data, not live APIs
  • Prompt versioning — store system prompts in n8n Variables, not hardcoded in node parameter fields
  • Credential scoping — always use n8n Credentials; never put API keys in expressions or Code nodes

Summary

  • n8n is a self-hostable, fair-code automation platform with native AI Agent, Anthropic, and OpenAI nodes
  • Docker Compose setup runs on port 5678 in under five minutes; n8n Cloud is the managed alternative
  • Email summariser, Slack bot, and classification pipeline all follow the same three-to-five node structure
  • The AI Agent node runs a plan-act-observe loop natively — wire in tools and let Claude decide how to use them
  • n8n beats Zapier and Make on AI depth, self-hosting freedom, and code execution
  • Error Trigger + Wait + Split In Batches make AI workflows production-ready

Further reading:

Top comments (0)