Skip to content
BotServBotServ
n8nWorkflowAutomationOllamaAI WorkflowSelf-HostingNode-RED

Connect n8n with Local AI

Get started with n8n and local AI: build workflows, integrate Ollama, automate tasks.

S

schutzgeist

2 min read
Connect n8n with Local AI

Connect n8n with Local AI

What this article covers

  • What n8n is and why you’d use it.
  • How to install n8n locally.
  • How to connect Ollama via HTTP request nodes.
  • What a simple AI workflow looks like.

Introduction: n8n with local AI

n8n is an open-source workflow automation tool that lets you connect services, APIs, and scripts. Unlike many cloud solutions, n8n can run on your own infrastructure. That makes it ideal when your workflows need to use AI models running locally.

With n8n, you might generate a daily summary from local files, classify emails, or analyze RSS feeds with AI. The key is connecting to a local model like Ollama.

What do you need?

To get started:

  • A server, mini PC, or desktop where n8n runs continuously.
  • Docker or Node.js for installation.
  • A running Ollama instance.
  • A locally accessible model such as Llama 3.2 or similar.

Docker is the simplest approach. You’ll have n8n running in just a few minutes.

Install n8n locally

Docker makes it quick to start n8n. Create a directory for the database first so your workflows persist:

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

Once it starts, access the interface at http://localhost:5678. On first launch, you’ll create a user account.

For persistent operation, use a docker-compose.yml to start n8n automatically.

Call Ollama from your workflow

n8n includes an HTTP Request node that can call any API. It works perfectly with Ollama. The endpoint is:

POST http://localhost:11434/api/generate

Send this JSON in the request body:

{
  "model": "llama3.2",
  "prompt": "Create a summary: {{$json.text}}",
  "stream": false
}

You can pull the prompt from earlier workflow steps, like an incoming email, file, or webhook.

A simple AI workflow

Consider this flow:

  1. A webhook receives a message.
  2. An HTTP Request node sends the text to Ollama.
  3. Ollama returns a classification.
  4. Based on the category, n8n routes the message to different channels.

This workflow uses no cloud service. The text, decision, and routing all happen on your hardware.

Tips for local AI in n8n

  • Mind the timeout: Local models may take a few seconds depending on your hardware. Set your workflow timeout accordingly.
  • Avoid prompt injection: Validate external inputs before sending them to Ollama.
  • Choose model size carefully: Smaller models respond faster; larger ones produce better results.
  • Limit context: Long prompts increase response time and memory usage.

Alternatives

If you prefer Node-RED, you can achieve similar results. Node-RED offers more flexibility for hardware and MQTT integration, while n8n is more comfortable with SaaS APIs and often prepares data faster. Either way, connecting to local Ollama is straightforward over simple HTTP requests.

Summary: n8n with local AI

n8n is excellent for integrating local AI into workflows. Install it with Docker, use the HTTP Request node to talk to Ollama, and automate text processing, classification, or notifications through workflows. Because everything runs locally, your data stays under your control.

Back to Blog
Share:

Related Posts