Skip to content

Tool Guide · Automation

n8n Guide

The definitive guide to n8n for AI workflows — self-host vs cloud, agent nodes, LLM chaining, code escape hatches, and when to pick it over Zapier or Make.

12 min readOpen-source self-host (free) + n8n Cloud from ~$20/mo (per-execution pricing)Updated Jun 2026
n8nAutomationAI WorkflowsAgentsSelf-HostNo-Code
Visit official site
Edited by The AIKnowHub team · Editorial team

Key takeaways

  • 1Visual workflow canvas with 400+ integrations and growing
  • 2Native AI agent nodes — tool loops, memory, and multi-step LLM reasoning
  • 3LangChain-style chains — prompt → model → parser → next step without leaving the canvas
  • 4Code nodes — JavaScript and Python escape hatch for custom logic
  • 5Sub-workflows — reusable RAG, triage, and enrichment pipelines
  • 6Self-hostable — Docker, Kubernetes, or n8n Cloud managed
  • 7Webhook triggers — turn any HTTP call into an automation entry point
  • 8Execution logs per node — debug AI failures step by step
  • 9Credentials vault — API keys stored encrypted, referenced by nodes
  • 10Community nodes — extend with custom connectors including emerging MCP patterns

Best for

  • AI agent workflows with tool use, retries, and branching
  • Self-hosted automations where data must stay in your VPC
  • High-volume runs (50k+/month) where Zapier task pricing hurts
  • Complex multi-step pipelines — fetch → classify → LLM → CRM write-back
  • Teams comfortable with light DevOps (Docker, env vars, backups)
  • Prototyping automations before dropping to full code

Not for

  • Non-technical teams that need zero setup — use Zapier
  • Connect Gmail to Notion in 20 minutes — Zapier is faster
  • Sub-100ms latency requirements — use code
  • Git-versioned logic with unit tests — use a real codebase
  • Teams allergic to maintaining a server

What it is

n8n is open-source workflow automation — a visual canvas where you connect triggers, actions, and logic into pipelines. Think Zapier, but you can self-host it, write code inside flows, and chain LLMs with real agent loops.

In 2026, n8n's differentiator for AI builders is the AI agent node: tool use, memory, retries, and multi-step reasoning without leaving the no-code canvas. That's why it anchors the AI Automation Engineer Roadmap.

Self-host vs n8n Cloud

Self-hostn8n Cloud
CostVPS (~$10–40/mo) + your time~$20/mo+ per execution tiers
DataStays in your VPCn8n's infrastructure
OpsYou manage Docker, Postgres, backupsZero
ScaleLimited by your serverManaged scaling
Best forAI-heavy, high-volume, complianceFast start, small teams

Self-host quick path: Docker Compose with Postgres, set N8N_ENCRYPTION_KEY, expose behind HTTPS, back up the database weekly. Production checklist lives in n8n docs.

When Cloud makes sense: you're validating an automation idea, team has no DevOps appetite, or volume is under ~5k runs/month.

Core concepts

Triggers

Every workflow starts with a trigger: webhook, schedule (cron), email, form submission, or app event. For AI pipelines, webhooks and schedules are the workhorses — ingest data on demand or run batch jobs nightly.

Nodes

Each step is a node: HTTP request, Slack message, OpenAI chat, code block, IF branch. Data flows left-to-right (or top-to-bottom); each node's output becomes the next node's input.

AI-specific nodes

  • LLM Chain — linear prompt → model → output. Good for classification, summarization, extraction.
  • AI Agent — loop with tools. The model decides which tool to call, observes the result, continues until done. This maps directly to how agents work in code.
  • Vector store / memory nodes — persist context across agent steps for RAG-style workflows.

Code nodes

When the visual layer isn't enough, drop a Code node (JavaScript or Python): sanitize PII, transform JSON, call an undocumented API, implement custom routing. This is n8n's killer feature vs Zapier — you're never truly stuck.

Sub-workflows

Extract a reusable chunk (e.g., "embed document → store in Qdrant → retrieve top-k") into a sub-workflow. Call it from multiple parent flows. Keeps complex canvases readable.

Building your first AI workflow

A proven starter pattern — support ticket triage:

  1. Trigger: Webhook or Zendesk/Intercom node on new ticket.
  2. Code node: Strip PII if sending to external LLM.
  3. LLM Chain: Classify category + urgency (JSON output).
  4. IF node: Route by category.
  5. AI Agent: Search knowledge base, draft reply for high-confidence cases.
  6. Action: Update CRM, post to Slack for human review on low confidence.

Full walkthrough: Support Ticket Triage workflow.

n8n vs Zapier vs Make

Don't re-read a full comparison here — see n8n vs Zapier vs Make. The one-line version:

  • n8n — AI agents, self-host, code escape hatches.
  • Zapier — 8,000 integrations, fastest setup.
  • Make — complex visual branching without self-host ops.

Pick n8n when AI logic is the hard part. Pick Zapier when integrations are the hard part.

Pairing with other tools

NeedPair with
Cheap classification modelGemini Flash via HTTP node
Local/private inferenceOllama — point HTTP node at localhost:11434
Custom tools for agentsMCP server or custom HTTP endpoints
RAG knowledge baseSelf-hosted Qdrant/Pinecone + embed step in sub-workflow

For MCP-native tool access beyond HTTP wrappers, you'll often drop to code or custom community nodes — see MCP Explained.

Production tips

  1. Version your workflows — export JSON to git. n8n doesn't give you PR-based review out of the box; treat exports as source of truth.
  2. Separate credentials per environment — dev/staging/prod API keys in n8n's credential vault, never hardcoded in nodes.
  3. Add error workflows — n8n can trigger a fallback flow on failure (alert Slack, retry with backoff).
  4. Log LLM inputs/outputs — execution logs help, but ship traces to your observability stack for production. See LLM Observability.
  5. Rate-limit webhooks — public webhook URLs get scanned. Add auth headers or IP allowlists.
  6. Test with real data — pin 10 representative inputs and run manually before enabling the schedule.

When to graduate from n8n

Signs you've outgrown the canvas:

  • Flows exceed 40 nodes and nobody can read the diagram.
  • You need git-native CI, unit tests, and typed interfaces.
  • Latency budget is under 200ms end-to-end.
  • You're building a product feature, not an internal automation.

Graduate to Python/TypeScript with Temporal, Inngest, or a plain API. Keep n8n for ops glue the team maintains without deploys.

The practical answer

Start with n8n Cloud and one real workflow — ticket triage, weekly intel, or email classification. Learn agent nodes on something that saves you time this week.

If volume or compliance pushes you to self-host, migrate when the math works — not before you've shipped workflow #1.

Pros and cons

Pros

  • Best-in-class AI agent nodes among no-code platforms in 2026
  • Self-host removes per-task pricing cliff at scale
  • Code nodes mean you never hit a hard ceiling on logic
  • Open source — inspect, fork, audit, air-gap
  • Strong execution debugging — see exactly which LLM step failed
  • Active community and AI workflow templates

Cons

  • Smaller integration library than Zapier (~400 vs 8,000)
  • Self-hosting means you own uptime, updates, and secrets rotation
  • UI gets cluttered on flows with 30+ nodes
  • n8n Cloud pricing can approach Make/Zapier at moderate volume
  • Steeper learning curve than Zapier for non-engineers
  • MCP support still emerging — often needs custom HTTP or code nodes

Real workflows using this tool

Prompt examples

Copy any of these, replace the placeholders, run.

LLM classification node system prompt

You classify incoming support tickets into exactly one category.

Categories: billing, technical, feature_request, account, other

Output JSON only:
{"category": "<category>", "confidence": 0.0-1.0, "summary": "<one sentence>"}

If unsure, use "other" and confidence below 0.6.

Agent node task description

You are a support triage agent. For each ticket:

1. Read the ticket subject and body.
2. Search the knowledge base tool for relevant articles.
3. Draft a reply if confidence is high; otherwise flag for human review.
4. Update the CRM with category and priority.

Never promise refunds or policy exceptions — escalate those.

Code node — sanitize before LLM

// Strip PII before sending to external LLM API
const text = $input.first().json.body;
const sanitized = text
  .replace(/\b[\w.-]+@[\w.-]+\.\w+\b/g, '[EMAIL]')
  .replace(/\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/g, '[PHONE]');
return [{ json: { sanitized, original_length: text.length } }];

Alternatives

ZapierMakePipedreamTemporal (code-first orchestration)Custom Python/TypeScript pipelines

Frequently asked questions

n8n for agent loops, branching, and self-host. Zapier for fastest setup and broadest SaaS coverage. Full comparison: [n8n vs Zapier vs Make](/comparisons/n8n-vs-zapier-vs-make). Most automation engineers learn both.

Watch

Hand-picked videos from official + trusted channels. Opens in a new tab.