Wednesday, June 3, 2026

Connecting Ollama to n8n for Local AI Workflows


In the previous articles, we installed Ollama, downloaded Phi-3, and introduced n8n as the automation engine that transforms a language model into an AI-powered workflow system.

Now it's time to connect these pieces together.

By the end of this guide, n8n will be able to communicate directly with Phi-3 through Ollama, allowing your workflows to use AI for reasoning, summarization, classification, content generation, and decision-making.

This is the moment when our local AI stack becomes a functional platform for building AI agents.


The Architecture We're Building

Before we begin, let's understand how the components fit together.

n8n
│
▼
Ollama API
│
▼
Phi-3
│
▼
Response
│
▼
Workflow Action

Each component has a specific role:

n8n

Handles automation and workflow orchestration.

Ollama

Hosts and serves the language model.

Phi-3

Provides intelligence and reasoning.

Together, they form the foundation of a local AI agent.


Prerequisites

Before proceeding, ensure that:

✓ Ollama is installed

✓ Phi-3 is installed

✓ n8n is installed

✓ Ollama is running

✓ n8n is accessible through your browser

If you haven't completed these steps, revisit the previous articles before continuing.


Step 1: Verify Ollama is Running

Open Command Prompt and execute:

ollama list

You should see something similar to:

NAME      SIZE
phi3      ...

Next, verify that the Ollama API server is available.

Open your browser and navigate to:

http://localhost:11434

If Ollama is running correctly, the endpoint should respond.

This confirms that the AI service is available to other applications.


Step 2: Launch n8n

Start n8n if it isn't already running.

Open your browser and navigate to:

http://localhost:5678

You should see the n8n dashboard.

Create a new workflow.

We'll use this workflow to test communication with Phi-3.


Step 3: Create a Simple AI Workflow

For our first integration test, we'll create a basic workflow.

Add the following nodes:

Manual Trigger
↓
AI Agent

The Manual Trigger allows us to execute the workflow on demand while testing.


Step 4: Add an Ollama Chat Model

Inside the AI Agent node:

  1. Select a chat model.

  2. Choose Ollama Chat Model.

  3. Create a new Ollama credential.

You will need to specify the Ollama endpoint.

Use:

http://localhost:11434

This tells n8n where to find the local AI service.


Step 5: Select Phi-3

Within the Ollama configuration:

Choose:

phi3

from the available models.

If Phi-3 does not appear:

ollama list

to confirm the model is installed.


Step 6: Configure a System Prompt

Inside the AI Agent node, define a simple system instruction.

Example:

You are a local AI assistant helping users automate tasks.
Provide concise and accurate responses.

This acts as the agent's behavior template.

Every future interaction will be influenced by this instruction.


Step 7: Test the Connection

Execute the workflow.

Provide a test prompt such as:

Summarize the purpose of workflow automation.

If everything is configured correctly:

  1. n8n sends the request.

  2. Ollama receives it.

  3. Phi-3 generates a response.

  4. n8n receives the output.

You have successfully connected your local AI model to an automation platform.


Understanding What Just Happened

This workflow may appear simple, but something significant occurred behind the scenes.

Instead of manually opening a terminal and chatting with Phi-3, another application successfully used the model as a service.

The process looks like this:

Workflow Trigger
↓
n8n
↓
HTTP Request
↓
Ollama
↓
Phi-3
↓
Generated Response
↓
Workflow Continues

This is the fundamental building block of AI agents.


Why This Matters

Once connected, any workflow can use AI.

Examples include:

Email Processing

New Email
↓
Phi-3 Summarizes
↓
Send Notification

File Organization

New File
↓
Phi-3 Categorizes
↓
Move File

Report Generation

Database Update
↓
Phi-3 Creates Summary
↓
Generate Report

Customer Support

Support Ticket
↓
Phi-3 Drafts Reply
↓
Send to Agent

The possibilities expand dramatically once AI becomes a workflow component rather than a standalone chat interface.


Common Connection Problems

Error: Connection Refused

Verify:

http://localhost:11434

is accessible.

If not, restart Ollama.


Error: Model Not Found

Run:

ollama list

Confirm that Phi-3 is installed.

If necessary:

ollama pull phi3

Docker-Based n8n Installations

If n8n runs inside Docker, the Ollama endpoint may need to be:

http://host.docker.internal:11434

instead of localhost.

This is one of the most common configuration mistakes.


Beyond Simple Prompts

At this stage, we're only sending text prompts to Phi-3.

Later in the series we'll build workflows that:

  • process documents

  • analyze files

  • make routing decisions

  • maintain memory

  • interact with APIs

  • perform autonomous actions

The connection we established today makes all of that possible.


The Emerging AI Agent Stack

Our architecture is beginning to take shape.

Trigger
│
▼
n8n
│
▼
Ollama
│
▼
Phi-3
│
▼
Decision
│
▼
Action

This pattern appears repeatedly in modern AI automation systems.

Whether you're building a file organizer, research assistant, support bot, or autonomous workflow manager, the same basic architecture applies.


Conclusion

Connecting Ollama to n8n is one of the most important milestones in building a local AI system.

For the first time, our language model is no longer isolated in a terminal window.

Instead, it becomes a reusable service that can participate in automated workflows.

With this integration complete, we now have:

✓ Local AI inference through Phi-3

✓ Local model serving through Ollama

✓ Workflow orchestration through n8n

✓ End-to-end AI automation capability

The foundation is complete.


What's Next?

Now that n8n can communicate with Phi-3, it's time to build something useful.

In the next article, we'll create our first complete AI workflow and explore how to transform simple prompts into practical automations.

Our first project will be:

Building Your First AI Chat Workflow with Phi-3 and n8n

This is where we move from infrastructure into real-world AI applications.

No comments:

Post a Comment

AI-Powered Software Development with n8n, Ollama, and Phi-3

  Introduction Software development is changing rapidly with the rise of Artificial Intelligence. Tasks that once required hours of manual e...