n8n is an open-source workflow automation tool with native LLM support. This guide covers self-hosting n8n, connecting it to OpenAI or a local Ollama model, and building an AI-powered automation workflow.
n8n connects LLMs to real-world triggers and actions without writing glue code. A webhook can trigger an LLM to summarise incoming Slack messages, a cron job can run a daily research digest, or a new CRM record can trigger an AI to draft a personalised email — all through a visual workflow editor.
Unlike Zapier or Make, n8n can be fully self-hosted and is free for self-hosted instances. It also supports long-running workflows, loops, and conditional logic that simpler tools lack.
The easiest way to self-host n8n is with Docker: `docker run -it --rm -p 5678:5678 -v ~/.n8n:/home/node/.n8n n8nio/n8n`. Open `http://localhost:5678` in your browser to access the editor.
For a permanent install with persistence, use docker-compose or the npm package: `npm install -g n8n && n8n start`. n8n stores workflows and credentials in `~/.n8n` by default.
In n8n, go to Settings → Credentials → Add Credential. Search for 'OpenAI' and paste your API key. This credential can then be used in any AI node in your workflows.
To use a local Ollama model instead, add an 'OpenAI' credential but set the Base URL to `http://host.docker.internal:11434/v1` (on Docker) or `http://localhost:11434/v1` (if n8n is running directly), with any placeholder API key. Ollama's OpenAI-compatible endpoint will handle the rest.
Create a new workflow. Add a Cron trigger set to run every morning at 8am. Connect it to a Slack node that fetches messages from a specific channel. Pipe the messages into an AI Message node using your connected LLM credential. Prompt: 'Summarise the key decisions, action items, and blockers from these Slack messages in bullet points.'
Add a final Slack node that posts the summary back to a digest channel. The whole workflow takes about 10 minutes to set up and runs automatically every morning.
n8n's AI Agent node runs a full ReAct loop. Connect tools as sub-nodes: a web search tool, a code execution node, a database query node. The agent decides which tools to call based on the incoming task.
For example: build a customer support agent that receives emails, uses a knowledge-base search tool to find relevant documentation, drafts a response, and sends it — all automatically. The AI Agent node handles the tool-calling loop; you just wire up the tools.
Hermes is NousResearch's open-source model family trained specifically for function calling and agentic workflows. This guide covers running Hermes locally, defining tools in JSON Schema, and building a basic tool-calling loop.
Read guideReAct (Reason + Act) is the foundational pattern for LLM agents. This guide builds a working ReAct agent from scratch using the OpenAI API and function calling, with a web search and calculator tool.
Read guide