n8n Essentials
> n8n is a source-available workflow automation tool that lets you wire up APIs, databases, and — increasingly — LLM agents as visual node graphs instead of glue code. This notebook covers what problem it solves, its core building blocks, and a compact example of an AI-powered workflow.
What is n8n?
n8n ("nodemation") is a workflow automation platform, similar in spirit to Zapier or Make, but self-hostable and built around a visual, node-based editor. Each node represents a step — trigger an event, call an API, transform data, branch on a condition — and you connect nodes into a workflow that runs on a schedule, a webhook, or a manual trigger.
What sets n8n apart from most no-code tools:
Self-hostable — run it on your own infrastructure, keeping data and credentials in-house
Code when you need it — a Function/Code node drops you into raw JavaScript (or Python) when a visual node isn't enough
400+ integrations — pre-built nodes for common SaaS tools, databases, and APIs, plus a generic HTTP Request node for anything else
Native AI nodes — LangChain-based nodes for chat models, agents, vector stores, and memory, so LLM workflows sit alongside your regular automations
Fair-code license — free to self-host; a paid cloud tier exists for managed hosting
Why n8n for AI Workflows?
LLM-powered automations usually need to touch several systems: read from a database, call an LLM, post to Slack, write back to a CRM. Writing that as a script is easy for a prototype but brittle to maintain — n8n gives it a visual shape, built-in retries/error handling, and a UI non-engineers can inspect or tweak.
It sits in an interesting middle ground:
Lower ceiling than LangGraph for complex, code-first agent control flow
Higher ceiling than pure no-code tools (Zapier) because you can drop into code nodes, self-host, and build genuinely complex branching logic
Faster to ship than a custom backend when the workflow is mostly "connect service A to service B, with an LLM step in between"
Core Concepts
Workflow — a canvas of connected nodes representing one automation, saved and versioned as JSON
Trigger node — the entry point: a webhook, a cron schedule, a form submission, or a manual click
Node — a single step (HTTP request, database query, LLM call, conditional branch, code execution)
Credentials — securely stored auth (API keys, OAuth tokens) shared across nodes and workflows
AI Agent node — a LangChain-based node that wraps an LLM with tools (other nodes exposed as callable tools) and optional memory, letting the agent decide which tool to call
Sub-workflow — a workflow called from another workflow, useful for reusing logic across automations
Common Use Cases
AI support agent — receive a message via webhook or chat trigger, look up context in a vector store, call an LLM, respond, and log the conversation
Content pipelines — pull data from an RSS feed or API, summarize it with an LLM, and post the result to Slack/Notion/a CMS
Lead qualification — new CRM entry triggers enrichment (scrape company info), an LLM scores the lead, and routes hot leads to sales
Document processing — a file lands in Drive/S3, gets parsed and embedded, and is indexed into a vector store for RAG
Ops automations without AI — sync data between tools, send alerts on failures, generate scheduled reports
Practical Example: An AI Agent Workflow
This sketch shows the shape of a webhook-triggered support agent: a chat message comes in, an AI Agent node with a couple of tools decides how to respond, and the reply is sent back.
[Webhook Trigger]
|
v
[AI Agent node]
- Chat Model: OpenAI GPT-4o
- Memory: Window Buffer Memory (last 10 messages)
- Tools:
- "Search Knowledge Base" -> HTTP Request node (vector store API)
- "Create Support Ticket" -> HTTP Request node (helpdesk API)
|
v
[Respond to Webhook]
- returns agent's final message as JSON
Configuration for the AI Agent node (conceptually, as set in the n8n editor):
{
"node": "AI Agent",
"parameters": {
"promptType": "define",
"systemMessage": "You are a support agent. Use the knowledge base tool before answering. Create a ticket only if the user explicitly asks for escalation.",
"tools": ["Search Knowledge Base", "Create Support Ticket"]
}
}
The webhook trigger gives you a URL immediately — you can point a chat widget, WhatsApp integration (via Twilio), or Slack app at it and the same agent workflow handles all of them.
Best Practices
Keep credentials in n8n's credential store, never hardcoded in a Code node or HTTP node body
Use sub-workflows to reuse common logic (e.g. "send Slack alert") instead of duplicating nodes across workflows
Add error-handling branches (Error Trigger node or per-node "Continue On Fail") for anything calling an external API
Pin node versions in production workflows so an n8n upgrade doesn't silently change node behavior
For AI Agent nodes, keep the tool list short and each tool's description precise — a vague description leads to the agent picking the wrong tool
When to Reach for n8n (and When Not To)
Good fit:
Connecting several existing SaaS tools/APIs with light logic in between
AI agents that mostly call existing REST APIs as tools, without needing custom agent-loop control
Teams that want workflows editable by both engineers and non-engineers
Overkill or a poor fit for:
Agent control flow with heavy branching, cycles, or custom state logic — LangGraph or a custom backend gives more control
High-throughput, latency-sensitive pipelines — n8n's node-by-node execution adds overhead a dedicated service wouldn't have
Workflows that need to be tested and deployed like normal application code (unit tests, code review on logic)
Key Takeaways
n8n turns "connect service A to service B, with logic in between" into a visual, self-hostable workflow instead of a bespoke script
Native AI Agent nodes let an LLM call other n8n nodes as tools, making it a viable lightweight agent runtime
It trades some control (versus code-first frameworks like LangGraph) for speed of building and visibility non-engineers can use
Reach for it when the bottleneck is integration glue, not complex agent reasoning
Resources
n8n docs: https://docs.n8n.io/
n8n AI/LangChain nodes: https://docs.n8n.io/advanced-ai/
n8n GitHub: https://github.com/n8n-io/n8n