tutorial

Building AI Agents with n8n in 2026: Tools, RAG, and Deployment

n8n is a fair-code workflow engine that ships a native AI Agent node wrapping LangChain tools, memory, and vector stores. This tutorial covers agent design patterns, retrieval-augmented generation with Pinecone or pgvector, deployment options (Cloud vs self-hosted), and operational guardrails as of May 2026.

Why n8n for AI Agents

n8n is a fair-code workflow engine, founded in 2019 and headquartered in Berlin, that pairs a visual editor with native code blocks. As of May 2026, n8n ships an AI Agent node that wraps LangChain primitives (tools, memory, output parsers) inside the standard workflow canvas, allowing both visual and JavaScript construction of agentic flows. The combination matters because most production agent work is glue: parsing inputs, calling models, branching on outputs, persisting state, retrying on failure, and notifying humans on exception. n8n already provides those primitives.

The AI Agent Node

The AI Agent node accepts a chat model, an optional vector store, and a list of "tools" (which are themselves n8n sub-workflows or HTTP requests). Internally it runs a ReAct or function-calling loop until the model emits a stop signal or hits a step cap. As of May 2026, supported model providers include OpenAI, Anthropic, Mistral, Google Vertex AI, Ollama (for local models), and any OpenAI-compatible endpoint via the generic node.

Practical agent patterns implemented inside this node include:

  • A research agent that searches the web (SerpAPI tool), reads pages (HTTP Request tool), and writes a summary to Notion
  • A triage agent that reads a Zendesk ticket, classifies it (function-calling), and either replies, escalates, or creates a Linear issue
  • A scheduling agent that reads a calendar invite, extracts attendees and intent, and books follow-ups

Retrieval-Augmented Generation (RAG)

n8n integrates with Pinecone, Weaviate, Qdrant, Supabase pgvector, Postgres pgvector, and Milvus through dedicated vector store nodes. A typical RAG pipeline looks like:

  1. Ingest: a workflow watches a Drive folder or webhook, splits documents with the Recursive Character Text Splitter node, embeds with OpenAI or Cohere, and writes vectors to the chosen store.
  2. Query: the AI Agent node loads the same vector store as a retriever tool, so the model can fetch relevant chunks at inference time.
  3. Citations: an output parser extracts citation IDs that the workflow then resolves back to source URLs before returning the answer.

Document chunk sizes of 512-1024 tokens with 64-128 token overlap perform well for support and policy corpora. Larger chunks reduce retrieval calls but increase context cost.

Memory and State

For multi-turn agents, n8n offers Window Buffer Memory (last N messages), Summary Memory (rolling summary), and external memory backed by Redis or Postgres. Long-running agents typically use a Postgres table keyed by session ID with messages stored as JSONB plus a summary column updated every K turns.

Deployment Options

n8n Cloud (Starter $24/month, Pro $60/month, Enterprise custom as of May 2026) provides a managed runtime with execution-based pricing. The free Community Edition runs on Docker, Kubernetes, or a single binary on any Linux host. For agent workloads specifically, self-hosting is often preferred because:

  • Long-running model calls (10-60 seconds) consume cloud execution time
  • Vector store latency depends on co-location with the n8n runtime
  • Local models via Ollama require a self-hosted node with a GPU

A common production topology is n8n + Postgres + Redis + Qdrant on a single Kubernetes namespace, with the AI Agent node calling Anthropic or OpenAI for the heavy reasoning model and a local Ollama deployment for cheap embedding and classification calls.

Operational Considerations

Three failure modes dominate agent workloads in production: model timeouts, tool errors, and infinite loops. n8n addresses each with built-in mechanisms:

  • The AI Agent node exposes a max iterations parameter (default 10) that hard-caps the ReAct loop
  • Tool calls inherit standard n8n retry policies (exponential backoff, max attempts)
  • Workflow timeouts can be set globally and per-execution via the Wait node

For observability, the n8n Execution Log records each tool call, model output, and intermediate state. Pairing this with Langfuse or Helicone via the HTTP Request node gives a per-conversation trace including token cost, latency, and tool error rates.

When n8n Is and Is Not the Right Fit

n8n suits agent workloads where the agent is one node inside a broader business workflow (CRM updates, ticket routing, internal tools). It is less ideal as a standalone consumer chat surface; for that, frameworks like LangGraph or CrewAI plus a dedicated frontend offer more control over the conversation loop. For internal automation with audit trails, integrated triggers, and a UI accessible to non-engineers, n8n is consistently faster to build and easier to operate than code-only alternatives.

Editor's Note: We deployed an n8n AI agent for a 60-person support team in early 2026 to triage inbound tickets. The setup ran on a single self-hosted n8n instance plus Qdrant for the knowledge-base retriever. After three weeks of tuning prompts and tool selection, the agent auto-resolved 31 percent of tier-one tickets and forwarded the rest to humans with a one-paragraph summary. The honest caveat: the win required iterating on the system prompt and the retriever twelve times, and the agent still occasionally hallucinates policy references when the underlying KB article is ambiguous, so a final human review step on auto-resolves remains essential.

Written & reviewed by Rafal Fila · Last updated:

Tools Mentioned

Related Guides

comparison

Keystroke vs n8n in 2026: Agent-Built TypeScript vs the Visual Canvas

Keystroke, launched in July 2026 by Y Combinator W24 company Sprint Labs, is a code-first automation platform where AI coding agents write workflows as TypeScript in the user's repository. n8n, founded in 2019, is the most widely deployed source-available visual workflow platform, with 200,000+ users and a $2.5 billion valuation. This comparison covers the agent-authored versus canvas building models, durable execution, licensing (Elastic License 2.0 vs the Sustainable Use License), verified July 2026 pricing including Keystroke's usage metering, and the maturity gap between a days-old platform and an established ecosystem.

comparison

QuantumBPM vs Camunda 2026: Single-Binary Challenger vs the BPMN Incumbent

QuantumBPM (launched 2026, Coroid s.r.o., Slovakia) packages a BPMN 2.0 runtime and DMN 1.5 decision engine into one Go binary backed by Temporal and PostgreSQL. Camunda (Berlin, founded 2013) is the category incumbent: Camunda 7 (Apache 2.0, in maintenance) and the Zeebe-based Camunda 8 platform. This comparison covers product structure, architecture, DMN TCK conformance with recording dates, deployment, pricing, and vendor maturity, verified July 2026.

case-study

Migrating 23 Make Scenarios to Self-Hosted n8n: a 3-Week Breakdown

Anonymized retrospective of a DTC ecommerce brand migrating 23 Make scenarios to a self-hosted n8n instance over three weeks. Tooling cost dropped from $348/month on Make Teams to roughly $12/month on a Hetzner VPS, but credential and webhook recreation consumed about 40% of total project time.

Related Rankings

Common Questions

What should teams do now that Relay.app is shutting down?

Relay.app announced on 16 July 2026 that it is shutting down. Free accounts and all their data are permanently deleted after 15 August 2026 at 23:59 PT, and paid accounts after 14 September 2026 at 23:59 PT, with paying customers keeping full access at no charge until that date. Export the workspace archive well before the deadline, because generation can take up to 24 hours and the emailed download link expires after 48; for the human-in-the-loop workflows Relay.app was usually bought for, Zapier and n8n are the only platforms evaluated here where a reviewer can edit an AI draft mid-run without custom development.

How much does Keystroke cost in 2026?

Keystroke offers three tiers as of July 2026: Hobby (free forever, with $1/month of included usage credit), Pro ($20/month, including $20/month of usage credit), and Organization (custom pricing with SSO, RBAC, and audit logs). Usage is metered on every tier: $0.01 per agent or workflow run, $0.005 per empty poll, $0.007 per web search, roughly $0.067 per hour of sandbox compute, and a 1.1x markup on AI model calls unless you bring your own API keys.

What is Keystroke?

Keystroke is a code-first workflow automation and AI agent platform, launched July 13, 2026 by Y Combinator-backed Sprint Labs, that positions itself as an n8n alternative built for AI coding agents. Workflows are written as typed TypeScript in the user's own repository, usually by agents such as Claude Code, Cursor, or Codex, and deployed to Keystroke's managed cloud or self-hosted under the source-available Elastic License 2.0.

Is Keystroke worth it in 2026?

Keystroke earns a provisional 6.5/10 in its July 2026 open alpha: the agent-native TypeScript model is genuinely differentiated and the free Hobby tier makes it safe to trial, but the platform is pre-1.0 (npm at v0.1.98, public repository published July 13, 2026), has no third-party production track record, and its Elastic License 2.0 restricts offering it as a hosted service. Worth trialing for teams that build through coding agents; too young for production-critical workflows.