n8n Fundamentals: Visual Workflow Automation with AI
What n8n is, how its node-based workflows actually work, how to wire in LLMs and AI agents, and why teams self-host it.
n8n · automation · workflows · ai-agents · no-code
What is n8n?
n8n (pronounced “n-eight-n”) is a workflow automation tool: you wire together apps, APIs and logic on a visual canvas instead of writing glue code by hand. Think Zapier or Make — but source-available and self-hostable, so your data and credentials stay on your own infrastructure.
It is fair-code licensed: free to self-host, the full source is open, and it ships 400+ ready-made integrations plus an escape hatch to raw code whenever the visual nodes aren’t enough.
The mental model: nodes, items, connections
A workflow is a graph of nodes. Each node receives data, does one thing, and passes data on. Data travels between nodes as a list of items — plain JSON objects — so the output of one node is the input of the next.
Master three words and n8n clicks: node (a step), item (one JSON record flowing through), connection (the wire that carries items).
Triggers: how a workflow starts
Every workflow begins with a trigger node. The common ones:
- Webhook — an HTTP endpoint; fire the workflow from anything that can POST.
- Schedule — cron-style (“every day at 07:00”).
- App triggers — react to events (new email, new row, new message).
- Chat / Form — turn a workflow into a chatbot or a form handler.
Everything after the trigger is action and logic nodes that run in order for each incoming item.
The node landscape
Three families cover almost everything you’ll build:
- Integration nodes — 400+ apps (Gmail, Slack, Notion, Google Sheets, Postgres, HTTP Request for any REST API).
- Logic / core nodes —
IF,Switch,Merge,Filter,Set/Edit Fields,Loop Over Items,Aggregate. - Code nodes — drop into JavaScript or Python when a step needs real logic; reusable sub-workflows keep big builds tidy.
Data & expressions
You map data between nodes with expressions — JavaScript inside {{ }}:
{{ $json.email }} // a field on the current item
{{ $json.items.map(i => i.name).join(", ") }} // transform inline
{{ $node["Webhook"].json.body.query }} // pull from another node
{{ $now.minus({ days: 7 }).toISODate() }} // built-in date helpers$json is the current item, $node[...] reaches any earlier node, and helpers
like $now save you from date math. This is where “no-code” quietly becomes
“a little code”.
n8n + LLMs
n8n ships first-class AI nodes (built on LangChain). The base building block is a Chat Model node feeding an LLM Chain:
- Chat Model — Anthropic (Claude), OpenAI, Google Gemini, Mistral, or a local Ollama model. Swap providers without rewiring the workflow.
- Basic LLM Chain — prompt in, structured or free text out.
Chat Model (claude-opus-4-8) → LLM Chain → parsed output → next nodeSo any workflow can summarise, classify, extract or rewrite — mid-pipeline, right next to your Slack and database nodes.
AI Agents & tools
The AI Agent node is where it gets powerful: give a model tools and memory, and it decides which tools to call to finish a task.
A “tool” is just another n8n node the agent is allowed to use. That turns n8n into an agent runtime with real-world side effects, not just a chat box.
RAG in n8n
Retrieval-Augmented Generation drops straight into a workflow. (New to RAG? See RAG Fundamentals.)
Ingest docs once (embed → vector store), then give the agent a retriever tool. n8n supports Qdrant, Pinecone, Supabase and Postgres/pgvector out of the box — so a private, self-hosted RAG bot is a weekend, not a quarter.
Build your first workflow
A “summarise my inbox” bot, end to end:
- Trigger — a Gmail/IMAP trigger (or a Schedule node that reads new mail).
- AI Agent / LLM Chain — Chat Model = Claude; prompt: “Summarise this email in two sentences and tag it urgent/normal.”
- Map data —
{{ $json.subject }}and{{ $json.body }}into the prompt. - Action — post the summary to Slack with an
IFon the urgency tag. - Test — click Execute, pin a sample email, iterate on the prompt.
- Activate — flip the workflow on; the trigger now runs it automatically.
Why teams choose n8n
The trade-off: you run the infrastructure. For anyone who values control and privacy over a fully managed SaaS, that’s the point — not the price.
Check your understanding
What makes the n8n AI Agent node more than a chatbot?
Takeaways
- n8n = visual workflows of nodes passing JSON items, self-hosted.
- Workflows start with a trigger, then action + logic nodes run per item.
- Expressions (
{{ }}) map data — no-code with a code escape hatch. - Chat Models → LLM Chains → AI Agents with tools make it AI-native.
- RAG, agents and private data are first-class — the reason to self-host.