How to Build Self-Hosted AI Workflows with n8n and Ollama (2026 Guide)

Published March 24, 2026 · 12 min read

Table of Contents

Why Self-Hosted AI Matters in 2026

The AI automation landscape has shifted dramatically. While cloud AI APIs like OpenAI and Anthropic remain popular, a growing number of teams are moving to self-hosted solutions. The reasons are compelling:

The cost difference is real. A team running 1,000 AI-powered automations per day on GPT-4 spends ~$300-600/month on API calls alone. The same workload on a self-hosted Llama 3 model? $0/month after the one-time hardware cost.

Setting Up n8n + Ollama (15 Minutes)

The stack is simple: n8n handles the workflow automation (triggers, routing, integrations with 400+ apps), and Ollama runs the AI models locally.

Step 1: Install Ollama

# Linux/macOS
curl -fsSL https://ollama.ai/install.sh | sh

# Pull a model (Llama 3 8B is a great starting point)
ollama pull llama3:8b

# Verify it's running
curl http://localhost:11434/api/tags

Step 2: Install n8n

# Using Docker (recommended)
docker run -d --name n8n \
  -p 5678:5678 \
  -v n8n_data:/home/node/.n8n \
  --add-host=host.docker.internal:host-gateway \
  n8nio/n8n

# Or using npm
npm install n8n -g
n8n start

Open http://localhost:5678 in your browser. That's it — you're ready to build AI workflows.

Step 3: Connect n8n to Ollama

n8n communicates with Ollama via HTTP. Every AI step in your workflow is simply an HTTP Request node pointing to http://localhost:11434/api/generate (or http://host.docker.internal:11434/api/generate if n8n runs in Docker).

Your First AI Workflow: Blog Post Generator

Let's build a practical workflow that generates a blog post from a topic. This workflow uses a 4-stage pipeline that mimics a real editorial process:

  1. Research — AI identifies key points, angles, and structure
  2. Outline — AI creates a detailed content outline
  3. Draft — AI writes the full post based on the outline
  4. Edit — AI polishes grammar, flow, and SEO

Each stage builds on the previous one, producing much better results than a single "write me a blog post" prompt.

Pro tip: Multi-stage workflows consistently outperform single-prompt approaches. The AI has focused context at each stage, leading to more coherent and polished output.

The Key Pattern: HTTP Request to Ollama

// In your n8n HTTP Request node:
URL: http://localhost:11434/api/generate
Method: POST
Body (JSON):
{
  "model": "llama3:8b",
  "prompt": "Your prompt here with {{ $json.variable }} interpolation",
  "stream": false,
  "options": {
    "temperature": 0.7,
    "num_predict": 2000
  }
}

10 Practical AI Workflow Use Cases

1. Content Generation Pipeline

Generate blog posts, social media content, and newsletters from a single topic input. A content repurposer workflow can turn one blog post into Twitter threads, LinkedIn posts, Reddit submissions, and Instagram captions.

2. Email Auto-Responder

Classify incoming emails by intent (support request, sales inquiry, spam), extract key information, and draft appropriate responses. The AI handles triage while you handle only the complex cases.

3. Lead Scoring

When a new lead comes in via your CRM or form, AI analyzes the company, role, and message to assign a priority score. Hot leads get instant notifications; cold leads enter a nurture sequence.

4. Document Summarization

Drop a long document, meeting transcript, or research paper into the workflow and get a structured summary with key takeaways, action items, and automatically generated Q&A pairs.

5. Support Ticket Router

Incoming support tickets get automatically categorized by department, priority, and sentiment. Urgent negative-sentiment tickets get escalated immediately.

6. Competitor Monitoring

Track competitor websites, blogs, and social media. AI summarizes changes and sends you a weekly intelligence briefing highlighting pricing changes, new features, and strategic moves.

7. Meeting Notes Processor

Feed in meeting transcripts (from Otter.ai, Fireflies, or any transcription tool) and get structured summaries with decisions made, action items with owners, and follow-up tasks.

8. Data Extraction

Extract structured JSON data from unstructured text — invoices, resumes, product descriptions, legal documents. Define your schema, and the AI extracts matching data consistently.

9. YouTube-to-Newsletter

Paste a YouTube URL, and the workflow fetches the transcript, summarizes key points, and formats everything as a ready-to-send email newsletter.

10. Social Media Content Generator

Enter a topic and brand voice, and get optimized content for Twitter, LinkedIn, Reddit, and Instagram. Includes an AI review pass for quality assurance.

Best Practices for n8n + Ollama Workflows

Choosing the Right Ollama Model

Model RAM Needed Best For
llama3:8b8 GBGeneral purpose, good balance of speed and quality
mistral:7b8 GBConcise outputs, fast, good for classification
mixtral:8x7b32 GBHigher quality, good for complex content
llama3:70b48 GBBest quality, comparable to cloud APIs

Skip the Setup: Ready-Made Templates

Building these workflows from scratch takes hours of prompt engineering and testing. If you want to skip straight to production-ready workflows, we've built a pack of 11 templates that cover all the use cases above.

Self-Hosted AI Workflow Pack

11 production-ready n8n workflows for Ollama. Content generation, email automation, lead scoring, document processing, and more. Import into n8n in 5 minutes.

$39 one-time — no subscriptions, no API costs

Get the Workflow Pack →

Or try a free sample first:


Published by WorkflowForge · Self-Hosted AI Workflow Pack