The Power of Local AI Automation

ChatGPT is a chat box. You type, it responds. That’s it. What if AI could work while you sleep? Read your emails, summarize documents, generate content, post to social media — all without you touching a keyboard?

That’s what n8n + Ollama gives you. n8n is an open-source workflow automation tool (like Zapier, but self-hosted and free). Ollama provides the local AI brain. Together, they create automated pipelines that run 24/7 on your hardware, with zero API costs.

What You Need

  • Ollama installed and running (see our beginner guide)
  • Docker for running n8n
  • 4GB RAM for n8n (on top of what Ollama uses)

Installing n8n

1
2
3
4
5
6
7
docker run -d \
  --name n8n \
  -p 5678:5678 \
  -v n8n_data:/home/node/.n8n \
  -e OLLAMA_HOST=http://host.docker.internal:11434 \
  --add-host=host.docker.internal:host-gateway \
  n8nio/n8n

Open http://localhost:5678 and create your admin account.

Without Docker

1
2
npm install -g n8n
n8n

Connecting n8n to Ollama

n8n has a built-in Ollama node that connects to your local Ollama instance.

Step 1: Add Ollama Credentials

  1. In n8n, go to CredentialsAdd Credential
  2. Search for Ollama API
  3. Set the base URL: http://host.docker.internal:11434 (if n8n is in Docker) or http://localhost:11434 (if running natively)
  4. Save — no API key needed, Ollama doesn’t require one

Step 2: Test the Connection

Create a simple workflow:

  1. Add a Manual Trigger node
  2. Add an Ollama node
  3. Configure: Model = llama3.1:8b, Prompt = Say hello
  4. Click Execute Workflow

If you see a response, you’re connected. Your local AI is now programmable.

Real Workflow Examples

Workflow 1: Automated Content Generation

Trigger: Schedule (daily at 9 AM) Steps:

  1. Schedule Trigger → fires daily
  2. Ollama node → generates 5 article topic ideas based on a niche prompt
  3. Ollama node → writes a full article from the best topic
  4. Write File node → saves to /content/articles/
  5. Slack/Telegram node → notifies you it’s done
1
[Schedule] → [Ollama: Generate Topics] → [Ollama: Write Article] → [Save File] → [Notify]

Workflow 2: Email Summarization

Trigger: New email (IMAP) Steps:

  1. IMAP Trigger → new email arrives
  2. Ollama node → summarizes the email in 3 bullet points
  3. Telegram node → sends summary to your phone
1
[IMAP] → [Ollama: Summarize] → [Telegram: Send]

Workflow 3: YouTube Video Pipeline (Our Actual Workflow)

Trigger: Manual or schedule Steps:

  1. Manual Trigger → enter video topic
  2. Ollama node → writes a 5-minute video script
  3. Ollama node → generates image prompts for each scene
  4. HTTP Request → sends prompts to ComfyUI API (image generation)
  5. HTTP Request → sends script to Kokoro TTS API (voice generation)
  6. Execute Command → FFmpeg combines audio + images into video
  7. Google Drive node → uploads finished video
1
[Trigger]  [Script]  [Image Prompts]  [ComfyUI]  [Kokoro TTS]  [FFmpeg]  [Upload]

This is the exact pipeline we use for our YouTube channel. One workflow trigger produces a finished video. Cost: $0.

Workflow 4: Document Q&A Chatbot

Trigger: Webhook (HTTP POST) Steps:

  1. Webhook → receives a question
  2. Read File node → loads relevant document
  3. Ollama node → answers the question based on the document
  4. Webhook Response → returns the answer

This gives you a private ChatGPT that knows your documents — no API costs, no data leaving your network.

Workflow 5: Automated Social Media Posts

Trigger: Schedule (3x per week) Steps:

  1. Schedule Trigger → fires Mon/Wed/Fri
  2. RSS Feed node → pulls latest AI news
  3. Ollama node → writes a social media post about the top story
  4. HTTP Request → posts to X/Twitter API
  5. Telegram node → sends you a preview
1
[Schedule] → [RSS] → [Ollama: Write Post] → [X API] → [Notify]

Tips for Reliable Workflows

1. Set Model Keep-Alive

Ollama unloads models after 5 minutes of inactivity by default. For automation, keep models warm:

1
2
# Set keep-alive to 20 minutes
OLLAMA_KEEP_ALIVE=20m ollama serve

Or per-request in n8n Ollama node:

1
2
3
4
5
{
  "options": {
    "keep_alive": "20m"
  }
}

2. Use the Right Model for Each Task

TaskRecommended ModelWhy
Creative writingllama3.1:8bGood prose quality
Code generationqwen2.5:7bStrong coding performance
Summarizationllama3.2:3bFast, good enough
Complex reasoningqwen2.5:14bBetter logic, slower
Tool calling/agentsglm4.7:9bDesigned for function calling

3. Handle Errors Gracefully

Add an Error Trigger node to catch failures:

1
[Error Trigger] → [Telegram: Alert "Workflow failed"]

4. Use Environment Variables

Store sensitive config in environment variables, not in workflow nodes:

1
2
-e TELEGRAM_BOT_TOKEN=your_token \
-e TWITTER_API_KEY=your_key \

5. Monitor with Built-in Logs

n8n logs all executions. Check Executions tab in the UI to debug failed runs.

Advanced: Multi-Model Workflows

You can chain multiple Ollama calls with different models in one workflow:

1
2
3
4
5
[Trigger] 
  → [Ollama: qwen2.5:14b — Analyze and plan] 
  → [Ollama: llama3.1:8b — Write content based on plan] 
  → [Ollama: llama3.2:3b — Generate title and tags] 
  → [Save + Publish]

The 14B model plans (slow but smart), the 8B model writes (balanced), and the 3B model generates metadata (fast). Each model plays to its strength.

Troubleshooting

“Connection refused” to Ollama

  • Ensure Ollama is running: ollama serve
  • Check the URL in n8n credentials
  • If n8n is in Docker, use host.docker.internal:11434, not localhost:11434

Workflow times out

  • Large models take time on CPU — increase the timeout in the Ollama node
  • Use a smaller model for automation (3B or 7B)

Model not found

  • Pull the model first: ollama pull llama3.1:8b
  • Check model name spelling (case-sensitive)

Next Steps


n8n is open source with a fair-code license. Self-hosting is free for individuals. Support them at n8n.io.