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.

The Toolkit take
Your model
n8n runs AI on the model & key YOU bring — full provenance, and data can stay in-house when self-hosted.
AI-Agent node
Reasons, uses tools, loops — built on LangChain
Pinecone · Qdrant · Supabase
Native vector stores for RAG
Bring your own model
OpenAI, Anthropic, or self-hosted open-weight
## 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:

💡
Toolkit tip
Use a retriever, don't stuff the prompt

For questions over your documents, embed them into a vector store and attach it to the AI-Agent node as a retriever tool. Similarity search over chunks is cheaper and more accurate than dumping whole documents into the context — and it lets you return citations.

## 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:

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):

  1. Trigger on a document source — e.g., a Google Drive folder.
  2. 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.
  3. Embed the chunks with your embedding model.
  4. Write the vectors to your store (Qdrant, Pinecone or Supabase).

The query workflow (run when someone asks):

  1. Trigger — a Slack message, chat input or webhook.
  2. 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.
  3. Output parser to extract citation IDs, so the reply says where the answer came from.
  4. 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.

⚠️
Watch out
Budget two meters for AI workflows

Because you bring your own key, the model usage is billed by your provider separately from n8n's executions. An agent that loops many times per run can make the model bill the larger one — cap iterations, match cheap models to simple jobs, and consider a self-hosted open-weight model for high volume.

## 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.

Curious how n8n feels in practice?Self-host free forever, or a 14-day cloud trial — no cardTry n8n

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.

💡
Toolkit tip
Start deterministic, graduate to agents

For anything consequential, begin with a fixed workflow that uses one AI step for the judgment and deterministic logic everywhere else. Move to a fully autonomous, tool-using agent only when the task genuinely needs open-ended decisions — it's cheaper, safer and easier to debug.

## 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:

Guardrails that keep it safe

AI that acts needs boundaries. Six habits, all straightforward in n8n:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. Force structure. Use an output parser to require JSON, and validate it before downstream nodes act — models drift, and a schema catches it.
  6. 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.
Ready to put n8n to the test?Self-host free forever, or a 14-day cloud trial — no cardTry n8n

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.

Frequently asked questions

Does n8n have AI capabilities?+

Yes — n8n has dedicated AI and LangChain nodes for building AI-powered workflows and agents, connecting to models like OpenAI and others. Because you can also self-host and add code, it's a favorite for developers building custom AI automations with data control.

What can I build with AI in n8n?+

AI agents that take actions across your apps, RAG-style workflows that answer from your own data, classification and routing of incoming items, summarization and extraction, and content drafting for review. n8n's code nodes and self-hosting make it especially flexible for custom, data-sensitive AI builds.

How do I add an LLM like OpenAI to an n8n workflow?+

Add the relevant AI/LangChain node or the provider's node, connect your API key, and pass data from earlier nodes into the prompt — for example, feed an incoming message into an AI node that classifies it, then branch on the result. For advanced logic, a Code node can shape the prompt or parse the response.

What does AI cost in n8n?+

The workflow run counts as an execution (or is free on self-hosted), and separately you pay the AI provider (e.g., OpenAI) for token usage on your own account. Self-hosting means no per-run automation fee, so for heavy AI workflows n8n can be notably cheaper than per-task tools plus the same model costs.

Why do developers prefer n8n for AI automation?+

Because it combines visual AI/agent nodes with self-hosting (keep sensitive data on your own infrastructure) and code nodes (shape prompts, parse outputs, add custom logic) — plus flat cost at volume. That mix of control, flexibility, and economics suits custom, production AI workflows better than closed no-code tools.

## 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.