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.

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