Showing posts with label Core Integration Series. Show all posts
Showing posts with label Core Integration Series. Show all posts

Wednesday, June 3, 2026

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


In the previous article, we connected Ollama to n8n and confirmed that our local AI stack was working correctly.

At this point, we have:

✓ Ollama running locally

✓ Phi-3 installed and responding to prompts

✓ n8n connected to Ollama

✓ A functioning local AI environment

Now it's time to build our first real workflow.

The goal of this project is simple:

Create a chat workflow where users can send messages through n8n, have Phi-3 process them locally, and receive AI-generated responses.

While this may seem basic, the workflow we build today forms the foundation for every AI agent we create later in the series.


What We're Building

The workflow will look like this:

User Message
↓
n8n Chat Trigger
↓
AI Agent
↓
Phi-3 (via Ollama)
↓
Response
↓
User

This creates a fully local AI chatbot powered by Phi-3.

Unlike cloud-based AI systems, all processing happens on your own machine.

No external APIs.

No usage limits.

No per-token charges.


Why Start with a Chat Workflow?

Before building autonomous agents, it's important to understand how information flows through the system.

A chat workflow teaches the fundamentals:

  • accepting input

  • sending prompts

  • receiving AI responses

  • managing context

  • controlling model behavior

Once you understand these concepts, more advanced workflows become much easier to build.


Step 1: Create a New Workflow

Open n8n.

Create a new workflow and give it a name such as:

Local AI Chatbot

This workflow will become our testing environment for future AI experiments.


Step 2: Add a Chat Trigger

Add a:

Chat Trigger

node.

The Chat Trigger allows users to send messages directly into the workflow.

Think of it as the entry point for conversations.

Whenever a user submits a message, the workflow begins executing.


Step 3: Add an AI Agent Node

Next, add:

AI Agent

Connect it to the Chat Trigger.

The AI Agent node acts as the orchestrator for conversations.

It receives user messages and forwards them to the language model.


Step 4: Configure the Ollama Chat Model

Inside the AI Agent configuration:

Add a model connection.

Choose:

Ollama Chat Model

Configure the endpoint:

http://localhost:11434

Select the model:

phi3

Now n8n knows where to send prompts.


Step 5: Create a System Prompt

System prompts define how the AI behaves.

Example:

You are a helpful local AI assistant.
Answer clearly and concisely.
When unsure, explain your reasoning.

This instruction becomes the personality and operating guideline for your chatbot.

System prompts are extremely important because they shape the model's responses.


Step 6: Test the Workflow

Save the workflow.

Click:

Execute Workflow

Open the chat interface.

Try sending:

What is workflow automation?

Phi-3 should respond through n8n.

Congratulations—you've built your first local AI chat workflow.


Understanding the Flow

When you send a message, several things happen behind the scenes.

User Message
↓
Chat Trigger
↓
AI Agent
↓
Ollama API
↓
Phi-3
↓
Generated Response
↓
User

Although simple, this architecture is surprisingly powerful.

Every future AI agent in this series will follow a similar pattern.


Experimenting with Different Prompts

Try asking Phi-3 different types of questions.

Explanations

Explain machine learning in simple terms.

Coding

Write a Python function to calculate factorials.

Summarization

Summarize the benefits of local AI.

Brainstorming

Suggest automation ideas for a small business.

These tests help you understand the model's strengths and limitations.


Improving Response Quality

Small models like Phi-3 perform best when prompts are specific.

Instead of:

Tell me about programming.

Try:

Explain the difference between Python and JavaScript for beginners.

The more context you provide, the better the response tends to be.


Customizing Your AI Assistant

You can modify the system prompt to create specialized assistants.

Programming Assistant

You are a software engineering assistant.
Focus on clean code and practical examples.

Research Assistant

You summarize information and highlight key insights.

Business Assistant

You help improve workflows, productivity, and operations.

This flexibility allows a single model to serve many different purposes.


The Limitations of a Simple Chat Workflow

While useful, our chatbot still has limitations.

It cannot:

  • access files

  • read emails

  • call external APIs

  • move documents

  • make workflow decisions

Right now it only responds to messages.

To create a true AI agent, we must connect the model to real-world data and actions.

That is the next step in our journey.


Why This Workflow Matters

Many newcomers underestimate the importance of this stage.

The chat workflow teaches the core relationship between:

  • n8n

  • Ollama

  • Phi-3

Understanding this interaction is essential before adding complexity.

Once you're comfortable with this workflow, you'll be able to build systems that:

  • classify files

  • process documents

  • automate business tasks

  • manage information

  • perform multi-step reasoning

All using the same foundation.


Looking Ahead

Our AI can now hold conversations.

The next challenge is giving it a purpose.

Instead of simply answering questions, we'll begin building workflows that interact with the real world.

We'll start with one of the most practical beginner projects:

Designing Your First Local AI Agent Architecture

In that article, we'll learn how AI agents are structured, how they make decisions, and how to design workflows that move beyond chat into automation.

This is where our local AI system begins evolving into a true digital assistant.


Conclusion

Today we built our first complete AI workflow using Phi-3, Ollama, and n8n.

The workflow may be simple, but it introduces the core pattern behind nearly every AI-powered automation system:

Input
↓
AI Processing
↓
Output

With this foundation in place, we're ready to build something far more powerful than a chatbot.

We're ready to build agents.

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.

Introduction to n8n: The Automation Engine for AI Agents

Up to this point in the series, we've built the foundation of a local AI system.

We started by understanding the benefits of local AI, installed Ollama, downloaded Phi-3, and learned how local language models can operate entirely on our own machines.

But while Phi-3 can answer questions and generate text, it still has one major limitation:

It only acts when we manually prompt it.

To create a true AI agent, we need something that can:

  • watch for events

  • gather information

  • send prompts automatically

  • make decisions

  • trigger actions

This is where n8n comes in.

n8n is the automation layer that transforms a language model from a chatbot into an intelligent workflow engine.

In this article, we'll explore what n8n is, why it matters, and how it fits into our local AI architecture.


What is n8n?

n8n is an open-source workflow automation platform that allows you to connect applications, APIs, databases, files, and AI models through visual workflows.

Instead of writing hundreds of lines of code, you can create automation using a drag-and-drop interface.

A workflow in n8n consists of:

  • Triggers

  • Actions

  • Logic

  • Data transformations

Each component is represented as a node connected together visually.

Think of it as a programmable automation engine that can connect virtually anything.


Why AI Needs Automation

A language model by itself is reactive.

It waits for a prompt.

For example:

User → Ask Question
AI → Generate Answer

Useful, but limited.

An AI agent requires a workflow around the model.

Something must:

  • detect events

  • collect context

  • send instructions

  • process outputs

  • execute actions

Without automation, AI remains a conversation tool.

With automation, AI becomes part of a system.


The Missing Piece in Most AI Projects

Many people focus entirely on the model.

They spend weeks comparing:

  • model sizes

  • benchmarks

  • quantization methods

  • hardware requirements

But in practice, the most important question is:

What should the AI actually do?

The answer usually involves workflows.

For example:

  • Organize files

  • Process emails

  • Generate reports

  • Monitor folders

  • Respond to webhooks

  • Handle support tickets

These tasks require automation.

That's where n8n becomes the most important component in the stack.


How n8n Works

Every workflow begins with a trigger.

For example:

New File Created

That trigger launches a workflow.

The workflow might:

Read File
↓
Send Content to Phi-3
↓
Analyze File
↓
Move File to Category Folder

No manual intervention required.

The entire process happens automatically.

This is the essence of an AI agent.


Why n8n is Perfect for Local AI

Many automation platforms exist.

However, n8n offers several advantages for local AI development.

Self-Hosted

You can run n8n on your own machine.

This keeps your automation private and under your control.

Visual Workflow Builder

Complex logic can be created without writing large amounts of code.

API-Friendly

n8n can communicate directly with:

  • Ollama

  • REST APIs

  • Databases

  • Local services

Extensible

If you need custom functionality, you can still write JavaScript or connect external tools.

AI Integration

Recent versions of n8n include dedicated AI nodes that make working with local language models significantly easier.


Understanding the Local AI Stack

At this stage, our architecture looks like this:

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

Each component has a specific responsibility.

Phi-3

Provides reasoning and language capabilities.

Ollama

Runs and serves the model locally.

n8n

Coordinates everything and performs actions.

Together, they create a complete AI automation system.


Real-World Examples

Let's look at a few practical use cases.

AI File Organizer

New File
↓
Phi-3 Categorizes
↓
n8n Moves File

Email Summarizer

Incoming Email
↓
Phi-3 Summarizes
↓
n8n Sends Notification

Research Assistant

Document Added
↓
Phi-3 Extracts Key Points
↓
n8n Stores Results

Customer Support Assistant

New Support Request
↓
Phi-3 Drafts Response
↓
n8n Creates Ticket

These workflows illustrate how AI becomes useful when connected to real-world processes.


Why n8n Matters More Than Most People Realize

Many newcomers view AI as the centerpiece of an automation system.

In reality, AI is often just one node inside a larger workflow.

The workflow itself determines:

  • when the AI runs

  • what information it receives

  • how results are used

  • what actions are taken

Without orchestration, even the most advanced model has limited practical value.

n8n provides that orchestration.


What We'll Build Later in This Series

Now that we've introduced n8n, the next articles will focus on implementation.

We'll learn how to:

  • Install n8n locally

  • Configure it for AI workflows

  • Connect it to Ollama

  • Use Phi-3 inside workflows

  • Build our first AI-powered automations

Eventually, we'll create complete local AI agents capable of performing useful tasks automatically.


Conclusion

Phi-3 provides intelligence.

Ollama provides model execution.

n8n provides automation.

Individually, these tools are useful.

Together, they form the foundation of a powerful local AI ecosystem capable of running entirely on your own hardware.

This is where the project begins to move beyond experimentation and toward practical AI automation.

In the next article, we'll install n8n on Windows and prepare our local automation environment for integration with Ollama and Phi-3.

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...