Blogguides

How to build an AI workflow with n8n (in under 15 minutes)

You don't need to write code to build an AI-powered automation. You need n8n and 15 minutes.

By the end of this guide, you'll have a working AI agent in n8n that you can trigger via chat, customize with tools, and extend into any workflow you can imagine. This is the starting point — not the finish line.

What you'll need

  • An n8n account (cloud or self-hosted — both work)
  • An OpenAI API key (or Anthropic, Google Gemini, or Ollama — your choice)
  • ~10–15 minutes

If you don't have an n8n account, start a 14-day free trial at n8n.io — no credit card required. Cloud spins up in under two minutes.

Disclosure: Some links on this page are affiliate links. If you sign up through them, I may earn a commission at no extra cost to you.


The two nodes that power every n8n AI workflow

Before touching the canvas, here's the mental model that makes everything click.

Every AI workflow in n8n is built on two core nodes: a trigger and an AI Agent.

The trigger decides when your workflow runs — on a schedule, when you send a chat message, when an email arrives, when a webhook fires. The AI Agent decides what happens — it takes an input, sends it to a language model, and returns a response.

Those two nodes are all you need for a working AI workflow. Everything else — memory, tools, sub-agents — is optional.

Step 1: Create a new workflow

Open n8n and click + New Workflow in the top left.

You'll land on a blank canvas. Don't let the empty space intimidate you — you're three clicks from a working AI agent.

Step 2: Add a Chat Trigger node

Click the + button in the center of the canvas to open the node panel.

Search for "Chat Trigger" and select it. This node creates a simple chat interface that lets you send messages directly into your workflow — perfect for testing.

Once added, you'll see it appear on the canvas. This is your trigger. Every time you send a chat message, this node fires and passes your message to the next node in the chain.

Step 3: Add an AI Agent node

Click the + button to the right of the Chat Trigger node to open the node panel again.

Search for "AI Agent" and select it. Connect it to your Chat Trigger.

The AI Agent node is where the intelligence lives. When you open its settings, you'll see three sub-node slots:

  • Chat Model — required. This is the LLM that processes the input.
  • Memory — optional. Gives the agent conversation history.
  • Tools — optional. Lets the agent take actions (search the web, run queries, send emails).

You need exactly one thing right now: the Chat Model.

Step 4: Connect your AI model

Inside the AI Agent node, click + next to Chat Model.

You'll see a list of supported models. The most commonly used options in 2026:

  • OpenAI → GPT-4o or GPT-4o-mini (most cost-effective for first workflows)
  • Anthropic → Claude 3.5 Sonnet or Claude 3 Haiku
  • Google Gemini → Gemini 1.5 Pro
  • Ollama → any local model (for self-hosted setups)

Select your preferred provider. n8n will ask you for credentials.

Adding your API key

Click Create new credential. Paste your API key into the field and click Save.

For OpenAI: get your key at platform.openai.com → API Keys → Create new secret key. GPT-4o-mini costs roughly $0.15 per 1M input tokens — you'll spend cents, not dollars, testing this.

Once credentials are saved, select the model from the dropdown (GPT-4o-mini is fine for this), and close the Chat Model settings.

Step 5: Test your workflow

Click Chat in the bottom-left corner of the canvas. A chat window opens.

Type any message: "What are the three most common uses of AI workflow automation?"

Hit send. In 2–5 seconds, the AI Agent responds.

You just built your first AI workflow.

The catch — and there's always a catch — is that this agent has no memory. Ask it "what did I just say?" and it won't know. That's what Memory nodes are for. But for a first test, this works exactly as intended.

Step 6: Give the agent a system prompt (optional, but worth it)

By default, the AI Agent has no context about what it's supposed to do. Add one.

Open the AI Agent node. In the System Message field, describe the agent's role:

"You are a helpful assistant for [your use case]. Be concise, accurate, and direct. Do not repeat information already given in the conversation."

This one change makes a noticeable difference in output quality. Specific prompts produce specific, useful answers. Vague prompts produce generic AI output.

Step 7: Activate your workflow

When you're ready to use this beyond testing, click Activate in the top-right corner.

The workflow is now live. For cloud users, n8n hosts the webhook endpoint — anything that can trigger it (a form, a Slack message, a cron job) will fire the agent and return a response.

For self-hosted users, your endpoint lives at your server's URL. Same behavior, zero per-execution cost.


What to build next

A working AI agent that responds to chat messages is the foundation. Here's where most people take it from here.

Add memory. Go back into the AI Agent node, click + next to Memory, and add a Window Buffer Memory node. Now the agent remembers the last N messages in the conversation. Useful for multi-turn workflows where context matters.

Add tools. Tools let the agent do things, not just respond. Common first tools: a web search tool, a Google Sheets read node, or a database query. Connect a Tool node and the agent will use it when the user's question calls for it.

Replace the Chat Trigger. The Chat Trigger is for testing. In production, swap it for whatever makes sense: an email trigger (runs when a new email arrives), a webhook trigger (runs when a form is submitted), a schedule trigger (runs every morning at 8am). Same agent, different entry points.

Chain multiple agents. One AI Agent can call another. This is how you build multi-step AI pipelines — an agent that drafts a response, another that checks it for tone, another that formats it for your CRM.


Common problems (and fixes)

The agent doesn't respond / workflow errors out. Check your credentials first. API key authentication failures are the most common cause of silent errors. Open the credential, paste the key again, and re-run.

The response is generic and unhelpful. The system prompt is either missing or too vague. Write a specific one that names the agent's role, the type of questions it should expect, and the format of its responses.

I'm getting "Execution failed" with no obvious reason. Open the execution log (the clock icon, top right). n8n logs every node's input and output. Click through each node to find where the chain broke. Usually it's a malformed variable reference or an API rate limit.


The realistic starting point

This is a minimal working AI workflow. It's not the most powerful thing n8n can do — it's the smallest thing worth building.

From here, the complexity ladder is: single agent → agent with memory → agent with tools → chained agents → full automation pipeline with triggers, agents, and external actions. Each rung takes one session to add.

n8n's AI capabilities run on LangChain under the hood, which means the building blocks are well-understood and the patterns transfer to other systems. What you learn here applies beyond n8n.

Try n8n free for 14 days — the Starter plan at ~$28/month covers 2,500 executions, which is more than enough to build and iterate on your first real workflow. Self-hosted is always an option if you'd rather pay for a server than a subscription.

Build the first one. The second one takes half the time.

This post may contain affiliate links. I earn a commission if you purchase through a link, at no extra cost to you. I only recommend tools I've honestly assessed.

← Back to all posts