Some links in this article are affiliate links. We earn a commission at no extra cost to you when you purchase through them. Full disclosure.
n8n is an open-source workflow automation tool. Ollama runs AI models locally. Together, they give you AI-powered automation with zero data leaving your network β no API keys, no cloud dependencies, no GDPR concerns.
Setup with Docker Compose
# docker-compose.yml
services:
n8n:
image: n8nio/n8n
ports:
- "5678:5678"
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=changeme
volumes:
- n8n_data:/home/node/.n8n
ollama:
image: ollama/ollama
ports:
- "11434:11434"
volumes:
- ollama_data:/root/.ollama
# For GPU support, add:
# runtime: nvidia
# environment:
# - NVIDIA_VISIBLE_DEVICES=all
volumes:
n8n_data:
ollama_data:
docker compose up -d
# Pull a model
docker exec ollama ollama pull qwen3:8b
# Access n8n at http://localhost:5678
Connect n8n to Ollama
In n8n:
- Go to Settings β Credentials β Add Credential
- Select Ollama API
- Set Base URL:
http://ollama:11434(Docker service name, not localhost) - Test connection
Now you can use the Ollama Chat Model and Ollama Embeddings nodes in any workflow.
Example workflow: AI email classifier
Email Trigger β Ollama (classify) β Switch β
βββ "urgent" β Slack notification
βββ "support" β Create ticket in Linear
βββ "newsletter" β Archive
The Ollama node prompt:
Classify this email as one of: urgent, support, newsletter, spam.
Respond with only the category name.
Subject: {{$json.subject}}
Body: {{$json.body}}
This runs entirely on your infrastructure. No email content is sent to OpenAI or any external service.
Example workflow: AI code review on PR
GitHub Trigger (PR opened) β Get PR diff β Ollama (review) β Post comment on PR
Ollama prompt:
Review this code diff for:
1. Security vulnerabilities
2. Performance issues
3. Code style problems
Be specific and actionable. Format as a GitHub comment with markdown.
Diff:
{{$json.diff}}
Example workflow: Daily log summarizer
Schedule (9am) β Read log files β Ollama (summarize) β Slack message
This replaces a Claude Code Routine with a fully self-hosted alternative.
Which model to use in n8n
| Task | Model | Why |
|---|---|---|
| Classification | qwen3:8b | Fast, accurate for simple tasks |
| Summarization | qwen3:8b | Good balance of speed and quality |
| Code review | qwen3.5:27b | Better quality for complex analysis |
| Embeddings | nomic-embed-text | Purpose-built for embeddings |
For most automation tasks, qwen3:8b is sufficient. The tasks are usually simple (classify, summarize, extract) and donβt need frontier model quality.
n8n AI nodes reference
| Node | What it does |
|---|---|
| Ollama Chat Model | Send prompts, get responses |
| Ollama Embeddings | Generate vector embeddings |
| AI Agent | Multi-step reasoning with tools |
| AI Chain | Sequential LLM calls |
| Vector Store | Store and query embeddings |
| Text Splitter | Chunk documents for RAG |
Self-hosted vs Zapier/Make
| n8n + Ollama | Zapier | Make | |
|---|---|---|---|
| Data privacy | β Everything local | β Cloud | β Cloud |
| AI model choice | Any (local or API) | Built-in only | Limited |
| Cost | $0 (self-hosted) | $20-100/mo | $9-29/mo |
| App integrations | 400+ | 9,000+ | 1,800+ |
| Setup effort | Medium (Docker) | Low | Low |
The trade-off: n8n has fewer integrations but complete privacy and zero ongoing cost. For GDPR-sensitive workflows, itβs the only option that keeps all data on your infrastructure.
Hosting options
| Option | Cost | Best for |
|---|---|---|
| Your machine (Docker) | $0 | Development, testing |
| Contabo VPS | $5-20/mo | Production, always-on |
| Vultr VPS | $5-20/mo | Production, global locations |
| Railway | $5-20/mo | Easiest deployment |
For production, a VPS with 8-16GB RAM runs both n8n and Ollama comfortably with an 8B model.
Related: Zapier vs n8n vs Make AI Β· Ollama Complete Guide Β· Self-Hosted AI for Enterprise Β· AI GDPR Guide Β· Claude Code Routines Β· Best Hosting for AI Projects