Home / AI / Ollama / How to Use Ollama with n8n: Private AI Automation Workflows

How to Use Ollama with n8n: Private AI Automation Workflows

How to Use Ollama with n8n: Private AI Automation Workflows

n8n is an open-source workflow automation tool — think Zapier but self-hosted. Combined with Ollama, you can build private AI automation workflows that run entirely on your own hardware, with no data leaving your network. This guide covers how to connect the two and build useful automations.

Why Ollama + n8n?

Most AI automation tools rely on cloud APIs (OpenAI, Anthropic) which means your data passes through third-party servers and you pay per token. Running n8n with a local Ollama model gives you:

  • Full privacy — no data leaves your machine or network
  • No API costs — run unlimited automations without per-token billing
  • No rate limits — process as much as your hardware can handle
  • Works offline — automations continue running without internet access

What You Need

  • Ollama installed and running with at least one model pulled
  • n8n — either self-hosted (npx n8n or Docker) or n8n Cloud with your Ollama accessible via a URL

For self-hosted n8n with Docker:

docker run -it --rm --name n8n -p 5678:5678   -v ~/.n8n:/home/node/.n8n   n8nio/n8n

Connecting Ollama to n8n

n8n has an Ollama node built in. To configure it:

  1. In n8n, go to Credentials → New Credential → Ollama
  2. Set the base URL to http://localhost:11434 (or your server IP if running remotely)
  3. Save the credential

Alternatively, use the HTTP Request node to call Ollama’s OpenAI-compatible endpoint directly at http://localhost:11434/v1/chat/completions.

Practical Automation Examples

1. Summarise Incoming Emails

Trigger: Email received via Gmail or IMAP → Extract body text → Ollama node (summarise in 3 bullet points) → Send summary to Slack or save to Notion.

2. Classify and Route Support Tickets

Trigger: New row in Google Sheets or webhook → Ollama classifies the ticket type (billing, technical, general) → Route to different team channels or assign labels automatically.

3. Document Processing Pipeline

Trigger: New file in Google Drive or local folder → Extract text → Ollama summarises and extracts key information → Store structured output in a database or spreadsheet.

4. Daily News Digest

Schedule trigger (8am daily) → Fetch RSS feeds from multiple sources → Ollama summarises each article → Compile into a formatted email or Slack message → Send.

5. Local Chatbot Webhook

Webhook trigger → Receive message → Ollama generates response → Return response. Deploy this as a simple private chatbot endpoint for internal tools.

Basic n8n Workflow: Webhook to Ollama

Here is the simplest working pattern — a webhook that accepts a message and returns an Ollama response:

  1. Add a Webhook node — set method to POST
  2. Add an Ollama Chat Model node — connect your credential, select your model
  3. Add an AI Agent node or HTTP Request to send the webhook body to Ollama
  4. Return the response with a Respond to Webhook node

Using the OpenAI-Compatible Endpoint in n8n

If you prefer the OpenAI node in n8n (which has more options), use Ollama’s OpenAI-compatible endpoint:

  1. Create an OpenAI credential in n8n
  2. Set the base URL to http://localhost:11434/v1
  3. Set the API key to any non-empty string
  4. Use any Ollama model name in the model field

Tips for Production Use

  • Use a faster, smaller model for high-volume automations — Qwen2.5 3B or Llama 3.2 3B handle classification and summarisation well
  • Reserve larger models (Llama 3.3 70B, Llama 4) for complex reasoning tasks triggered infrequently
  • Set a system prompt in your Ollama calls to constrain output format — especially useful for classification tasks where you want a single word or JSON output
  • Use Ollama structured outputs for reliable JSON extraction in processing pipelines