n8n AI Agent Node Tutorial

📝 Blog6 min read

n8n AI Agent Node Tutorial

n8n is an open-source workflow automation platform that has become a favorite among developers and no-code builders who want full control over their AI agent infrastructure. Its AI Agent node — introduced alongside n8n's LangChain integration — lets you assemble autonomous agents inside a visual drag-and-drop editor, connecting LLMs, memory, and custom tools without writing code. This tutorial walks through every step of building an AI agent with the n8n AI Agent node, from first workflow to production deployment.

What the n8n AI Agent Node Does

The AI Agent node is the centerpiece of n8n's agent-building toolkit. It wraps a LangChain agent under the hood and exposes a visual interface where you configure the LLM, attach tools, set memory, and define sub-agents — all as connected nodes on a canvas. Unlike platforms that hide the underlying logic behind a chat interface, n8n shows every component of the agent as a node you can inspect, rename, and reorder.

AI Agent Node FeatureWhat It Enables
LLM selectionChoose from OpenAI, Anthropic, Google Gemini, Ollama, or any LangChain-compatible provider
Tool bindingAttach HTTP requests, database queries, or custom function nodes as agent tools
MemoryPersist conversation context across runs using n8n's built-in memory or external vector stores
Sub-agentsDelegate tasks to child agents with their own LLM and tool sets
System promptFull control over the agent's instructions, tone, and constraints
Output parsingStructure the agent's final response as JSON, text, or a custom schema

Prerequisites Before You Start

You need three things to follow this tutorial: a running n8n instance (self-hosted via Docker or the cloud platform), an API key from your chosen LLM provider, and a clear idea of what the agent should do. n8n's AI Agent node is available in both the free self-hosted edition and the cloud platform, but some advanced features — like vector store memory and sub-agent orchestration — require the cloud tier or a recent self-hosted version.

Step 1: Create a New Workflow and Add the AI Agent Node

Open n8n and click New Workflow. Drag the AI Agent node from the node palette onto the canvas. The node appears with a default configuration: it has no LLM connected, no tools attached, and an empty system prompt. Click the node to open its settings panel.

Step 2: Connect an LLM Provider

In the AI Agent node settings, expand the LLM section and click Add LLM. n8n supports several providers out of the box: OpenAI (GPT-4, GPT-4o, GPT-3.5 Turbo), Anthropic (Claude), Google Gemini, and Ollama for local models. Select your provider, paste the API key, and choose a model. For testing, the free tier of OpenAI's GPT-4o-mini is sufficient and costs roughly $0.15 per 1 million input tokens.

Step 3: Attach Tools to the Agent

Tools are what make an agent actionable rather than conversational. Click Add Tool in the AI Agent node settings. n8n offers several built-in tool types:

For each tool, configure the inputs and outputs. The agent uses the tool name and description to decide when to call it. For example, an HTTP Request tool named "Search Knowledge Base" with the description "Searches the company wiki for information about products and policies" will be invoked when the user asks a product question.

Step 4: Configure Memory

Without memory, every agent run starts fresh — it has no context from previous interactions. In the AI Agent node settings, expand the Memory section and select a memory type. n8n supports:

For most tutorial use cases, Window Buffer Memory is sufficient. It keeps the last 10 messages by default and gives the agent continuity across a single session.

Step 5: Set the System Prompt

The system prompt defines the agent's identity, constraints, and behavior. Click the System Prompt field and write instructions like: "You are a customer support agent for a SaaS company. Answer questions about billing, features, and troubleshooting. If the user asks about a topic outside your scope, say you don't know and offer to escalate to a human agent." The system prompt is the single most important factor in agent quality — a well-crafted prompt reduces hallucinations and keeps the agent on task.

Step 6: Test and Iterate

Click the Execute button on the AI Agent node to run the workflow. n8n opens an interactive chat panel where you can send messages to the agent and see its reasoning in real time. You'll see which tools it calls, what arguments it passes, and how it synthesizes the final answer. If the agent makes mistakes, adjust the system prompt, rename tools for clarity, or add a new tool — then re-execute.

Real Example: A Lead Qualification Agent

A B2B startup built a lead qualification agent using n8n's AI Agent node with these components: an OpenAI GPT-4o-mini LLM, an HTTP Request tool that queries their CRM API, a Google Sheets tool that logs new leads, and a Code tool that calculates a lead score from the CRM response. The system prompt instructs the agent to extract the lead's company name, industry, and budget from the first message, query the CRM for existing records, score the lead 1–10, and either create a new CRM record or flag duplicates. The agent processes 30–50 inbound leads per day, each taking under 15 seconds, and the startup eliminated 4 hours of manual data entry per week.

n8n AI Agent Node vs Other Platforms

n8n's AI Agent node occupies a specific niche: it is the most transparent and developer-friendly option among no-code platforms. Zapier and Make abstract away the agent logic into pre-built templates, which is faster to start but harder to customize. LangFlow gives you more control over the LangChain graph but lacks n8n's built-in database and HTTP tool nodes. Replit Agent is the best choice if you need full-stack deployment in one platform. Choose n8n when you want to see every node, inspect every tool call, and keep your agent logic in a version-controlled workflow file.

Related AI Agent Resources

Reviewed by the AI Agent Tools team on August 2, 2026.

Frequently Asked Questions

No. The AI Agent node is a visual, drag-and-drop node in n8n's workflow editor. You configure the LLM, tools, memory, and system prompt through the node settings panel. However, you can add a Code node for custom JavaScript or Python logic if you need data transformations that the built-in tools don't cover.

n8n supports OpenAI (GPT-4, GPT-4o, GPT-3.5 Turbo), Anthropic (Claude), Google Gemini, and Ollama for local models out of the box. Because it uses LangChain under the hood, any LangChain-compatible LLM provider can be added through the generic LangChain LLM node.

Yes. n8n is open-source and self-hosted for free. The AI Agent node and all AI features are available in the self-hosted edition at no cost. The only paid aspect is the cloud platform, which removes the need to manage Docker infrastructure. LLM API costs (OpenAI, Anthropic, etc.) are separate and billed by the provider.

The AI Agent node uses LangChain's tool-calling mechanism. When the LLM determines a tool is needed, it generates a structured tool call with the tool name and arguments. n8n intercepts this call, executes the connected tool node (HTTP Request, Code, Google Sheets, etc.), and feeds the result back to the LLM for the next reasoning step.

Yes. n8n supports sub-agent orchestration where one AI Agent node delegates work to another AI Agent node. This is useful for complex workflows where a lead qualification agent hands off to a CRM sync agent, which then triggers a notification agent. Each sub-agent has its own LLM, tools, and memory configuration.

By default, n8n stores workflow execution data locally in its database (SQLite for self-hosted, or n8n's cloud database). For AI Agent memory, Window Buffer Memory keeps the last N messages in the node's in-memory context. For persistent long-term memory, you can configure a Vector Store memory type that connects to Pinecone, Qdrant, Chroma, or any other vector database n8n supports.

Advertisement

Related Articles