How do you set up AI agents in n8n?
Quick Answer: AI agents are built in n8n using the AI Agent node (based on LangChain), which combines an LLM, tools, and memory. Connect an LLM node (OpenAI, Anthropic, or Ollama), add tool nodes for capabilities (HTTP requests, database queries, calendar), attach memory (buffer or vector store), and trigger via chat, webhook, or schedule. The AI Agent reasons over user input and calls tools as needed.
Setting Up AI Agents in n8n
n8n added native LangChain integration in 2024, with the AI Agent node enabling function-calling agents that use tools to accomplish multi-step tasks. As of April 2026, n8n is one of the most widely used self-hosted AI agent platforms.
Core Nodes
- AI Agent: Orchestrator that plans and calls tools
- Chat Model (sub-node): OpenAI Chat Model, Anthropic, Ollama, Google Gemini
- Memory (sub-node): Window Buffer Memory, Vector Store Memory, Motorhead
- Tools (sub-nodes): HTTP Request, Calculator, Wikipedia, custom workflow tools
Step-by-Step Setup
1. Trigger
Choose a trigger for the agent:
- Chat Trigger: Built-in chat UI for testing
- Webhook: HTTP endpoint for integration
- Schedule Trigger: Run on interval
- Telegram/Slack Trigger: Accept messages from chat platforms
2. Add AI Agent Node
The AI Agent node expects:
- Input: The user message or task
- System Message: Instructions defining the agent's role
- Chat Model: Connected LLM node
- Memory: Optional conversation memory
- Tools: Array of connected tool nodes
3. Connect a Chat Model
As a sub-node, add:
- OpenAI Chat Model (gpt-4o, gpt-4o-mini, o1)
- Anthropic Chat Model (claude-3-7-sonnet, claude-4-sonnet)
- Ollama Chat Model (for local models like Llama, Mistral)
- Google Vertex Chat Model
4. Add Tools
Tools extend the agent's capabilities:
- HTTP Request Tool: Call any API
- Workflow Tool: Execute another n8n workflow as a tool
- Calculator: Math operations
- Code Tool: Execute JavaScript
- Wikipedia/SerpAPI: Web search
- Custom: Build tools from any n8n node
5. Configure Memory
- Window Buffer Memory: Keep last N messages
- Vector Store Memory: Semantic memory using embeddings (e.g., Pinecone, Qdrant)
- Motorhead: Summarization-based memory
Example: Customer Support Agent
Chat Trigger
→ AI Agent
- System: "You are a customer support agent..."
- Chat Model: OpenAI gpt-4o-mini
- Memory: Window Buffer (k=10)
- Tools:
- HTTP Request: Lookup order by ID
- Workflow Tool: Create support ticket
- SerpAPI: Search docs
Testing
Use the Chat Trigger for interactive testing:
- Open the workflow in editor
- Click the Chat Trigger node
- Open the chat window
- Send test messages and observe agent reasoning
Self-Hosted Considerations
- Local LLMs: Use Ollama for privacy-sensitive deployments
- Vector stores: Self-host Qdrant or use managed Pinecone
- Cost control: Log token usage to Airtable for monitoring
Production Tips
- Set max iterations (usually 5-10) to prevent infinite loops
- Use structured output for deterministic downstream workflows
- Monitor tool call failures and implement retries
- Version prompts in a dedicated node with environment variables
Related Questions
Related Tools
n8n
Workflow automation for technical teams
Workflow AutomationRelevance AI
No-code AI agent builder for business tasks with multi-step workflows, knowledge base integration, and team collaboration.
AI Agent PlatformsLindy
AI agent platform for building autonomous digital workers
AI Agent PlatformsGumloop
No-code AI workflow automation with visual node-based editor
AI Agent PlatformsRelated Rankings
Best Durable Workflow Engines for Production in 2026
A ranked list of the best durable workflow engines for production deployments in 2026. Durable workflow engines persist execution state to a database so that long-running workflows survive process restarts, deployments, and infrastructure failures. The ranking covers Temporal, Prefect, Apache Airflow, Camunda, Windmill, and n8n. Tools were evaluated on production reliability, developer experience, scalability, open-source health, and documentation quality. The shortlist intentionally mixes code-first engines (Temporal, Prefect, Airflow) with hybrid visual platforms (Camunda, Windmill, n8n) to reflect how production teams actually choose workflow engines in 2026.
Best No-Code Automation Platforms in 2026
A ranked list of no-code automation platforms in 2026. The ranking covers visual workflow builders that allow non-engineering teams to connect SaaS apps, route data, and add conditional logic without writing code. Entries cover proprietary cloud platforms (Zapier, Make, Pipedream, IFTTT) and open-source visual builders (n8n, Activepieces). Scoring reflects integration breadth, pricing accessibility, visual editor ease, reliability and error handling, and self-hosting availability.
Dive Deeper
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.
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.
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.