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 Feature | What It Enables |
|---|---|
| LLM selection | Choose from OpenAI, Anthropic, Google Gemini, Ollama, or any LangChain-compatible provider |
| Tool binding | Attach HTTP requests, database queries, or custom function nodes as agent tools |
| Memory | Persist conversation context across runs using n8n's built-in memory or external vector stores |
| Sub-agents | Delegate tasks to child agents with their own LLM and tool sets |
| System prompt | Full control over the agent's instructions, tone, and constraints |
| Output parsing | Structure 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:
- HTTP Request — call any REST API (web search, CRM lookup, payment processing)
- Code — run JavaScript or Python snippets for data transformation
- Google Sheets — read and write spreadsheet rows
- Postgres / MySQL — query databases directly
- Custom Function — write a JavaScript function that the agent can call
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:
- Window Buffer Memory — keeps the last N messages in context (default, no setup required)
- Buffer Window Memory — similar but with a configurable token window
- Vector Store Memory — uses an embeddings store for long-term retrieval (requires a vector DB like Pinecone, Qdrant, or Chroma)
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
- How to Build an AI Agent Without Coding - Platform comparison and architecture overview
- No-Code AI Agent Builder for Gmail - Inbox automation with Gmail triggers
- No-Code AI Agent Templates - Importable workflows for Make, Zapier, and LangFlow
- Free No-Code AI Agent Builder Comparison - Free vs paid platform breakdown
- What Is MCP in AI Explained Simply - Protocol for connecting agents to tools
- Best AI for Remote Work Productivity 2026 - Remote agent deployment
- No-Code AI Agent and Automation Tools Hub - Complete pillar guide
Reviewed by the AI Agent Tools team on August 2, 2026.