How to Build AI Workflows with n8n and OpenAI
Learn how to build AI workflows with n8n and OpenAI to automate tasks, enhance productivity, and create intelligent business processes.
May 28, 2025
To build an AI workflow in n8n, add a Chat Trigger, connect an AI Agent node, attach an OpenAI Chat Model with your API key, test it in the chat panel, then add a system message and memory. Those five steps are below. On n8n's hosted cloud, the Starter plan costs EUR20 a month billed annually for 2,500 workflow executions and Pro costs EUR50 a month billed annually for 10,000, with unlimited workflows on both (read on n8n.io/pricing, 16 October 2026). For comparison, Zapier lists its Professional plan as starting from $19.99 a month, billing basis not stated (read on zapier.com/pricing, 16 October 2026). OpenAI model usage on your own API key is billed by OpenAI on top.
What makes this an AI workflow rather than a chatbot is tool use: the AI Agent node can call other n8n nodes (a CRM, a spreadsheet, an inbox) and act on what comes back, where a language model on its own only returns text.
n8n ships built-in nodes for common business apps plus an HTTP Request node for any system with an API, so the AI step can read from and write to the tools a 10 to 100 person business already runs.
New users can try n8n without any upfront costs through its free trial program. We'll show you how to build your first AI workflow using n8n and OpenAI, and help you optimize it step by step.
Understanding AI Workflows in n8n
AI workflows bridge traditional automation with intelligent systems that make decisions. Let's see how n8n creates powerful connections with OpenAI.
What is an AI Agent in n8n?
An AI agent in n8n works as an autonomous system that receives data, makes rational decisions and acts within its environment to achieve specific goals. The system builds upon Large Language Models (LLMs) by adding goal-oriented functionality.
Standard LLMs just process input to generate text output. AI agents go beyond this basic function and can:
- Use tools to access external resources
- Process the outputs of those tools
- Make decisions to complete tasks and solve problems
A key difference sets them apart. LLMs might generate a paragraph of text, but AI agents perform complex tasks like scheduling appointments and analyze various inputs such as images and audio.
How n8n connects with OpenAI?
N8n blends with OpenAI through its built-in nodes. The connection process needs you to:
- Add an OpenAI node to your workflow
- Authenticate with your OpenAI account using API credentials
- Select from supported actions or make custom API calls
The AI Agent node in n8n must connect to a chat model, such as OpenAI's GPT models. This connection creates the foundation of your AI workflow that allows the agent to process incoming prompts and generate intelligent responses.
Setting up authentication works simply. You need an API key from your OpenAI account that you can generate from OpenAI's website and add to n8n as credentials.
When to use AI in workflows
AI doesn't fit every automation task. AI agents work best in your workflows when you:
- Handle complex tasks that need reasoning or context understanding
- Process communication content (emails, messages)
- Work with various inputs like images or audio
- Need decisions based on unstructured data
Simple tasks like email address validation work better with traditional programming methods.
N8n combines AI-driven steps with traditional programming by adding AI agents as nodes. This creates powerful workflows that achieve what neither could accomplish alone.

Want to know what this would take for your own process? Send the workflow: the platform you already pay for, the one workflow it cannot run, and roughly how many people or customers touch it. A senior engineer sends back a one-page scope within two working days: what the platform does, where it stops, what we would build, and the range. If the honest answer is "configure, do not build", you get that too. No call needed. Or get a first range in a minute from the AI development cost calculator.
Building AI-Powered Workflows with n8n and OpenAI
Let's build our first AI workflow with n8n and OpenAI step by step, now that we understand AI agents.
1. Set up your n8n environment
You need to decide between using the n8n cloud service or self-hosting. The cloud option comes with a free trial and needs no installation, which suits a first build. Self-hosting options include Docker with these environment variables:
N8N_EDITOR_BASE_URL: Your public access URLN8N_PORT: Default is 5678N8N_PROTOCOL: HTTP or HTTPS
Cloud version users can sign up and create a new workflow with the + icon in the upper-left corner.
2. Add a trigger node
Your workflow needs a starting point called trigger nodes in n8n. Here's how to add one:
- Select "Add first step" or press Tab to open the node menu
- Search for "Chat Trigger"
- Select it to add the node to your canvas
The Chat Trigger creates a text interface that lets you interact with your AI workflow. This gives you a simple entry point to send prompts to your OpenAI-powered workflow.
3. Connect the AI Agent node
The next step connects an AI Agent node to your trigger:
- Select the "Add node" connector on your trigger node
- Search for "AI Agent" and select it
- The AI Agent node adds AI capabilities as the workflow's brain
Your AI Agent receives data, makes decisions and uses various tools to complete tasks.
4. Link to OpenAI and add credentials
The AI Agent needs to connect to a language model:
- Click the plus button under "Chat Model" connection on the AI Agent
- Select "OpenAI Chat Model" from the list
- Add your OpenAI credentials (API key required)
Getting your API key is simple:
- Log in to your OpenAI account
- Go to API keys page
- Create a new secret key
- Copy and paste it into n8n
5. Test the basic workflow
The workflow testing process involves:
- Clicking the "Chat" button at the bottom of your canvas
- Type a message in the chat window
- Press Enter to see the AI response
The log window shows your inputs and outputs, which helps you understand how the AI processes your prompts. Your functional AI workflow is now ready for customization.
Customize and Improve Your Workflow
Your AI workflow becomes more powerful with these customizations.
Change the system prompt
The system prompt guides your AI model's behavior. N8n sets this to "You are a helpful assistant" by default. You can see this simple prompt in your workflow logs.
Here's how to modify the default behavior:
- Open your AI Agent node
- Scroll to the bottom and locate the "Options" section
- Click "Add Option" and select "System message"
- Replace the default text with your custom instructions
You could try something like "You are a brilliant poet who always replies in rhyming couplets" to change how your AI responds. The system message sets the AI's role, expertise and response format for your use case.
Add memory for context retention
Your AI workflow starts with a major limitation: it cannot remember previous interactions. You can test this:
- Ask the AI your name in the chat window
- Wait for a response
- Then ask "What's my name?"
The AI fails to answer because it has no memory. The solution is straightforward:
- Click on the "Memory" option at the bottom of your AI Agent node
- Select "Simple Memory" from the panel
- Keep the default setting of 5 interactions (or adjust as needed)
Your AI will now maintain context throughout conversations and remember details from previous messages. This feature creates natural, ongoing interactions.
Use logs to debug and optimize
Logs are a great way to get insights into your AI's information processing. You can access them:
- Click the "Chat" button at the canvas bottom to view logs alongside chat
- Or open the AI Agent node and select the Logs tab
The logs show exactly what goes to and comes from the AI model, including the complete system prompt, user messages, and AI responses. This information helps you spot formatting issues, missing context, or unexpected behavior.
The Executions tab lets you select "Debug in editor" to load problematic data into your workflow when executions fail.
When an n8n and OpenAI workflow needs an engineering team

KUMO is a software engineering studio that builds custom AI agents, workflow apps and portals for 10 to 100 person companies; its founders built Volopay's first production version as its founding engineers. It builds on n8n where n8n is the right fit, and writes custom code when a workflow needs approvals, audit records or access to data that n8n's nodes cannot reach cleanly.
A first production workflow or AI agent built by KUMO costs $15K to $50K; work that spans several systems costs $50K to $100K; ongoing engineering after launch costs $5K to $10K per month. See AI workflow automation for how those builds are scoped.
How the work runs:
- Start from the business problem and the systems it touches
- Agree the scope and the price band before any build starts
- Weekly demos on real data while the work progresses
- New systems work with your existing tools
Conclusion
n8n with an OpenAI model is a low-cost way to put an AI step into a business workflow: the hosted Starter plan is EUR20 a month billed annually (read 16 October 2026) and the basic build takes the five steps above. AI agents differ from a plain language model because they call tools and act on the results, which is why the system message and memory steps matter.
Customization options like changing system prompts and adding memory will improve your workflow's effectiveness. Simple AI workflows deliver immediate value. These refined techniques help your automations understand context and deliver customized results.
Debugging through logs are a great way to get information about your workflow's operation. This practice helps you spot problems before they impact your production systems and guides optimization efforts for better performance.
n8n with OpenAI suits a first AI workflow whether you are new to automation or an experienced developer. When the workflow has to touch billing, approvals or customer records, get a range for that build from the cost calculator before committing to either route.
The numbers in one file. The Build vs Buy Price Book, October 2026 has the published prices of 40 business tools read in October 2026, what they cost a 40-person company, and the four tests that say whether a custom build is worth it. Download the PDF (8 pages, free, no form).
Next step
If you are deciding between an off-the-shelf tool and something built around your operation, KUMO builds AI workflow automation and works with n8n where n8n is the right fit. See how Farro Capital approached it, get a range from the cost calculator, or book a free 30-minute call.