Getting Started with n8n for AI Workflows

Updated May 2026

Step 1: Install n8n

The fastest path to a working n8n instance depends on your goals. For testing AI features without any infrastructure, start with n8n Cloud's 14-day free trial at app.n8n.cloud. No credit card required, and you get full access to all AI nodes. For local development with Ollama integration, use Docker Compose. Create a docker-compose.yml file with the n8n image, a PostgreSQL database, and optionally Ollama and Qdrant containers. Run docker compose up and n8n will be available at localhost:5678.

The Self-Hosted AI Starter Kit is the recommended path for AI-focused development. Clone the repository from GitHub, copy the .env.example file to .env, and run docker compose with your hardware profile (default for CPU, gpu-nvidia for NVIDIA GPU acceleration). This gives you n8n, Ollama, Qdrant, and PostgreSQL pre-configured to work together.

Step 2: Configure an LLM Provider

Before building AI workflows, you need credentials for at least one LLM provider. In n8n, go to Settings, then Credentials, then Add Credential. For OpenAI, paste your API key. For Anthropic, paste your API key. For Ollama (local), the credential is typically just the URL of your Ollama instance (http://ollama:11434 if using the starter kit, or http://localhost:11434 if running Ollama natively).

If using Ollama, make sure you have at least one model pulled. Open a terminal in the Ollama container (docker exec -it ollama bash) and run ollama pull llama3.1 for a general-purpose model, or ollama pull nomic-embed-text for embeddings in RAG pipelines.

Step 3: Create Your First AI Workflow

Click New Workflow in n8n. Your first AI workflow needs three nodes minimum: a Chat Trigger, an AI Agent, and a Model. Add the Chat Trigger node from the trigger menu. This provides a built-in chat interface for testing. Add an AI Agent node and connect the Chat Trigger output to it. Then add a Chat Model node (OpenAI Chat Model, Anthropic Chat Model, or Ollama Chat Model) and connect it to the AI Agent's model input.

Configure the AI Agent with a system prompt that defines the agent's role. Something simple like "You are a helpful assistant that answers questions accurately and concisely" is sufficient for testing. Set the model on the Chat Model node (gpt-4o for OpenAI, claude-sonnet-4-20250514 for Anthropic, llama3.1 for Ollama).

Click the Chat button in the top right to open the test chat interface. Type a message and verify that the agent responds. If it does, your basic AI workflow is working.

Step 4: Add Tools to Your Agent

Tools transform a basic chatbot into a capable agent. Add a Calculator node and connect it to the AI Agent's tools input. Now the agent can perform mathematical calculations when asked. Add an HTTP Request node configured to call a weather API, and the agent can answer weather questions. Add a PostgreSQL node connected to your database, and the agent can query real data.

Each tool needs a name and description that tells the agent what it does. The agent uses these descriptions to decide which tool to call for each user request. Write descriptions that are specific and unambiguous: "Query the orders database to find order status, shipping details, and order history for a given customer email" is better than "Database lookup."

Step 5: Add Memory for Conversations

Without memory, each message is processed independently with no knowledge of the conversation history. Add a Buffer Memory node (or Window Buffer Memory for longer conversations) and connect it to the AI Agent's memory input. This enables multi-turn conversations where the agent remembers what was discussed earlier in the conversation.

For memory that persists across workflow executions (so users can resume conversations later), use PostgreSQL Chat Memory or Redis Chat Memory instead of the in-memory buffer. Configure a session ID field that uniquely identifies each conversation, typically the user's ID or a conversation UUID.

Step 6: Test and Iterate

Use the built-in chat interface to test various scenarios. Try questions that require tool use, multi-turn conversations that reference earlier messages, and edge cases that might confuse the agent. Review the execution log for each conversation to see which tools the agent called, what responses it received, and how it formulated its final answer.

Common issues to address: the agent calling the wrong tool (improve tool descriptions), the agent providing inaccurate information (refine the system prompt with constraints), and the agent failing to use tools when it should (add explicit instructions in the system prompt about when to use tools). Each iteration improves the agent's behavior. Save working configurations as templates for future workflows.