Build Local AI Agents with n8n in Minutes
Welcome! In this tutorial, you'll learn how to build AI agents using n8nβa robust workflow automation platformβand run them locally using Docker. We'll cover what n8n is, how AI agents work, how to install n8n with Docker, and how to build your first intelligent automation with an AI agent and Airtable.
π What Is n8n?
n8n (pronounced "n-eight-n") is a visual workflow automation tool that connects apps, services, and custom logic into seamless automations. It's like Zapier or Makeβbut open-source and far more flexible.
π§ Why Use AI Agents?
- Workflows are linear automations with predefined paths.
- AI Agents use large language models (LLMs) like GPT to decide which tool to use dynamically, based on input and context.
- AI agents = smart automations that can search databases, make decisions, and evolve in conversation.
π» Step 1: Install n8n Locally Using Docker
To run n8n locally, you'll need:
- Docker
- A terminal (Command Prompt, PowerShell, or Terminal)
π§ Run n8n with Docker (Single Command):
docker run -it --rm \\
-p 5678:5678 \\
-v ~/.n8n:/home/node/.n8n \\
-e N8N_BASIC_AUTH_ACTIVE=true \\
-e N8N_BASIC_AUTH_USER=admin \\
-e N8N_BASIC_AUTH_PASSWORD=your_password \\
n8nio/n8n
Access it at: http://localhost:5678
Login: admin
Password: your_password
π‘ Pro Tip: For a persistent local service, consider using a
docker-compose.yml
file. Let me know if you'd like that too.
π§± Understand Node Types in n8n
Workflows in n8n are built using nodes, categorized as:
- Trigger Nodes: Start your workflow (e.g., chat message, webhook, schedule)
- Action Nodes: Take actions in apps (e.g., send email, update Airtable)
- Utility Nodes: Modify, transform, or route data
- Code Nodes: Run custom logic (JavaScript, HTTP requests)
- AI Agent Node: The smart brain powered by GPT or other LLMs
π¬ Build a Local AI Agent Workflow
Once n8n is running locally:
1. Create a New Workflow
In the n8n UI:
- Click "Create Workflow"

2. Add a Chat Trigger
- Use the "Chat Trigger" node
- This simulates a chatbot conversation in the UI

3. Add an AI Agent Node
- Go to Advanced AI β AI Agent

- Connect it to a model like GPT-4.0 from OpenAI

- You'll need to add your OpenAI API key (can be a free-tier for testing).
To get your API key:

- Visit: https://platform.openai.com/account/api-keys
- Generate and paste into n8n under Credentials
π§ Enable Memory for the Agent
Enable Window Buffer Memory in the AI Agent node to allow multi-turn conversation (e.g., track last five messages).

π Connect Your Agent to Airtable (Optional Tool Example)
Let's make the AI agent smarter by integrating Airtable:
Step 1: Build an Airtable Base
Columns to include:
- Item Name
- Quantity
- Order Threshold
Step 2: In n8n
Inside the AI Agent node:
- Add a Tool β Airtable
- Operation:
Search
orUpdate
- Authenticate with Airtable token (read/write/schema access)
- Tool description: "Searches my Airtable inventory."
Example query the agent can now handle:
"Is anything out of stock in my house?"
β Summary: What You've Built
- β n8n installed locally with Docker
- β A working AI agent powered by GPT
- β Memory-enabled conversation
- β Airtable integration for inventory
- β Foundation for agentic automation system
π Want to Go Further?
This is just the beginning. You can:
- Add tools (Google Sheets, Notion, Gmail, etc.)
- Use conditions, loops, filters, or vector search
- Connect to APIs or hardware (home automation)
Let me know and I can help generate those for you too.
What is your favourite large language model (LLM) that you have used?
Thanks for reading!
Enjoyed this article? Subscribe to the newsletter to get notified when new posts go live.