TL;DR — n8n is one of the best tools available for building real AI — not a single "ask AI" step, but agents that reason, retrieve, remember and act. This playbook covers how to use it at full capacity: the AI-Agent node and its LangChain foundation, choosing a vector store (Pinecone, Qdrant, Supabase), building RAG with citations, tool-using and multi-agent patterns, conversational memory, model choice and cost math, the guardrails that keep it safe, and how to test it. The two things that make n8n special: you bring your own model and key (full control and provenance), and you can self-host so sensitive data never leaves your infrastructure.
Why n8n for AI
Most automation tools bolt on a single LLM action: send text, get text back. n8n treats AI as a first-class framework. Its AI-Agent node, built on a deeply integrated LangChain foundation, lets you assemble an agent that reasons about a goal, uses tools (any of your other nodes, an HTTP call, a database query, even another workflow) to gather what it needs, and loops until it's done — all on the visual canvas, with a code node available wherever you need finer control[1]. Around it sit the pieces serious AI needs: embedding nodes, memory, output parsers, and direct vector-store integrations for Pinecone, Qdrant and Supabase[1].
Two design choices set n8n apart. First, you bring your own model and key — OpenAI, Anthropic, an open-weight model, even one you host yourself — so you know exactly what runs, what it costs, and what data it sees. Second, self-hosting means the whole pipeline can run on your own infrastructure, so regulated or sensitive data never touches a third party. For AI on real business data, that combination is genuinely hard to find elsewhere.
The building blocks
Before the playbooks, the vocabulary you'll use:
- AI-Agent node — the orchestrator: give it a goal, a model, a set of tools and (optionally) memory, and it decides what to do.
- Tools — anything the agent can call: an HTTP request, a database node, a search, a document retriever, or an entire sub-workflow exposed as a tool.
- Vector store — where your knowledge lives as embeddings (Pinecone, Qdrant or Supabase), so the agent finds the relevant passage instead of stuffing everything into the prompt.
- Embeddings & text-splitter — turn documents into chunks and then vectors; chunk size and overlap decide retrieval quality.
- Memory — lets a conversational agent remember earlier turns.
- Output parser — forces the model's answer into a structure (e.g. JSON) so downstream nodes can act on it reliably.
- Code node — your escape hatch for pre-processing prompts, post-processing output, or enforcing rules the no-code path can't.
Choosing your vector store
RAG lives or dies on the vector store, and n8n gives you three first-class options — the right one depends on your stack:
- Pinecone — fully managed and the easiest to start with; you don't run anything. Best when you want zero database ops and are happy with a hosted service.
- Qdrant — open-source and self-hostable; the natural match if you're already self-hosting n8n and want the whole pipeline (data included) on your own infrastructure.
- Supabase (pgvector) — Postgres with vector search; ideal if you already use Supabase or Postgres, so your embeddings live beside your other data.
The rule of thumb: self-hosting n8n for privacy? Pair it with Qdrant or Supabase so nothing leaves your servers. Want the least setup? Pinecone. All three attach to the AI-Agent node the same way — as a retriever tool.
Playbook 1 — a RAG knowledge assistant with citations
This is the highest-value AI build for most businesses: employees ask a question and get an answer grounded in your documents, with citations — not a confident hallucination. In n8n it's two workflows[1].
The ingestion workflow (run when documents change):
- Trigger on a document source — e.g., a Google Drive folder.
- Split each document into chunks with a text-splitter. Chunk size and overlap matter: too large and retrieval is vague, too small and it loses context — a few hundred tokens with modest overlap is a sane starting point.
- Embed the chunks with your embedding model.
- Write the vectors to your store (Qdrant, Pinecone or Supabase).
The query workflow (run when someone asks):
- Trigger — a Slack message, chat input or webhook.
- AI-Agent node with the vector store attached as a retriever tool: it runs a similarity search, pulls the most relevant chunks, and answers from them.
- Output parser to extract citation IDs, so the reply says where the answer came from.
- Respond with the answer and its sources.
The result is an internal assistant that answers from your wikis and policies with receipts — the pattern behind knowledge assistants, compliance checks and contract review that teams are shipping in production today[1]. Re-run ingestion on a schedule or on file changes so the knowledge stays current.
Playbook 2 — a tool-using agent that acts
RAG answers questions; a tool-using agent does things. Give the AI-Agent node a goal and a toolbox, and it chooses which tool to call.
Example — lead enrichment and first touch: the agent receives a new lead, uses an HTTP tool to look up the company, a search tool for context, scores intent, drafts a tailored opener, and calls your CRM node to create the contact and task. Example — support triage: the agent reads a ticket, classifies it, checks the knowledge base (a retriever tool), then either drafts a grounded reply, escalates to a human, or opens an issue in your tracker.
A powerful n8n-specific move: expose an entire workflow as a tool. Build a reliable "create invoice" or "look up order" workflow once, then hand it to the agent as a single tool — the agent gets a tested, deterministic capability instead of improvising the steps. This is also the foundation of multi-agent setups, where a coordinator agent delegates to specialist sub-agents (each its own workflow) for research, drafting or validation.
Playbook 3 — the deterministic AI-in-the-loop workflow
Not everything needs an autonomous agent. Often the safest, cheapest pattern is a fixed workflow with one AI step doing the judgment: trigger → free filter to drop noise → AI node classifies or extracts → a switch routes on the result → deterministic actions run. You get AI where it adds value (the judgment) and predictable, debuggable logic everywhere else. Start here for anything consequential, and graduate to full agents only when the task genuinely needs open-ended tool use.
Conversational agents and memory
If you're building a chatbot — a Slack assistant, a support bot, an internal helper — the agent needs to remember the conversation. n8n's memory attaches to the AI-Agent node so it carries context across turns; a windowed buffer keeps the last N exchanges, and on self-hosted you can back memory with Postgres so it survives restarts and scales across workers. Pair memory with a chat trigger and a retriever tool and you have a grounded, stateful assistant — the difference between a bot that forgets your last message and one that actually holds a conversation.
Choosing (and paying for) the model
Because you bring your own key, model choice is yours — and so is the bill. Practical guidance:
- Match the model to the job. Use a cheap, fast model for classification, extraction and routing; reserve a frontier model for hard reasoning or customer-facing drafting. Mixing models across nodes is trivial in n8n and is the single biggest cost lever.
- Do the cost math. An agent that calls the model five times per run, across 2,000 runs a month, is ~10,000 model calls — multiply by your provider's per-call token cost to get the real figure. On n8n Cloud that's on top of execution cost (see the pricing guide); on self-hosted, n8n itself is free but the model provider still bills.
- Self-host the model for private or high-volume AI. Running an open-weight model on your own hardware (with self-hosted n8n) can drive per-call cost to near-zero and keep data fully in-house — the strongest privacy posture in the category.
Guardrails that keep it safe
AI that acts needs boundaries. Six habits, all straightforward in n8n:
- Strip sensitive data before the model. Use a code node to remove PII or secrets from anything sent to an external model — or self-host the model so nothing leaves.
- Keep a human on consequential actions. Route anything customer-facing or irreversible through an approval step (a wait/approval node) — let the agent draft, let a person approve.
- Constrain the tools. An agent can only do what its tools allow — give it the minimum, and prefer read-only tools until you trust it.
- Cap iterations. Set a maximum number of agent steps (and timeouts) so a confused agent can't loop indefinitely and run up the model bill.
- Force structure. Use an output parser to require JSON, and validate it before downstream nodes act — models drift, and a schema catches it.
- Log everything. Record what the agent decided and did, so an odd result weeks later is traceable. Start agents on low-stakes, reversible tasks and widen autonomy as trust builds.
Testing and evaluating your AI
AI workflows are non-deterministic, so treat testing differently from ordinary automations. Keep a set of pinned test inputs — real examples with known good outputs — and run them through the workflow after any change to the prompt, model or tools; n8n's execution view lets you inspect exactly what each node received and returned, which is invaluable for seeing why the agent chose a tool or produced a bad answer. When you switch models to save cost, re-run the same test set and compare — a cheaper model that passes your cases is free money; one that quietly fails them is a false economy you'll only catch if you measured.
Common mistakes to avoid
Putting the AI step inside a loop unnecessarily. Calling the model per item in a 100-item loop is 100 calls and 100 charges — batch the work or enrich outside the loop where you can. Skipping retrieval and stuffing the prompt. Dumping whole documents into the context is expensive and less accurate than a proper vector-store retriever. Trusting output shape. Use an output parser and validate before downstream nodes act. No human gate on the first deploy. Ship the review step first; remove it only once the agent has earned trust on real traffic. Ignoring chunking. Bad chunk sizes are the most common reason a RAG assistant gives vague answers — tune them before blaming the model.
The bottom line
n8n's AI is a genuine reason to choose it: a real agent framework with LangChain, first-class RAG via Pinecone/Qdrant/Supabase, tool-using and multi-agent patterns, conversational memory, and — uniquely valuable — your own model with the option to keep everything in-house by self-hosting. Start with a deterministic AI-in-the-loop workflow, add RAG when you need grounded answers, layer in memory for conversation, and graduate to autonomous, tool-using agents with tight guardrails once you trust the pattern. For the full evaluation, see our n8n review; to understand what it costs, the pricing guide covers both n8n executions and the separate model bill.