# How to Build Your First AI Agent in n8n: Tutorial

> How to build your first AI agent in n8n: five nodes (chat trigger, AI Agent, OpenAI model, memory, Google Sheets tool), step by step and tested.

Source: https://learn.ynteractive.com/content/blog/n8n-ai-agent-tutorial · Updated 2026-10-20 · Free from Stepthrough (https://learn.ynteractive.com)

Quick answer

**Short answer:** to build your first [AI agent](https://learn.ynteractive.com/content/glossary/ai-agent) in n8n, connect five nodes: an **On chat message** trigger, an **AI Agent** with a [System Message](https://learn.ynteractive.com/content/glossary#system-prompt), an **OpenAI Chat Model**, **Simple Memory** and a **Google Sheets Tool**. Write the System Message, add an [OpenAI API](https://learn.ynteractive.com/content/glossary#openai-api) key, test it in the chat window, and the agent writes ideas and saves them to a sheet. No code is needed; practice it free in the [AI Social Media Idea Agent](https://learn.ynteractive.com/content/n8n-ai-agent-tutorial-google-sheets) lesson.

Last updated October 20, 2026

[Take the free module →](https://learn.ynteractive.com/courses/intro-to-ai-automation/7)Module 7 of the free [Intro to AI Automation](https://learn.ynteractive.com/courses/intro-to-ai-automation) course, about 12 minutes. No account needed.

By [Robert Breen](https://learn.ynteractive.com/content/about/robert-breen) · Published October 1, 2026 · Updated October 20, 2026 · 9 min read

n8n · AI agents

This tutorial is for beginners with no coding background. It follows that lesson (about 12 minutes), where you practice the whole build in a copy of n8n before you touch your own account. Screens and plan details below are as of October 2026.

Most people use AI in a chat window and copy the answer somewhere by hand. An n8n AI agent skips the copying and puts the result where it belongs. If you have never opened n8n, the [free n8n course for beginners](https://learn.ynteractive.com/content/paths/n8n-beginner) covers the basics first.

## What does the n8n AI agent in this tutorial do?

The agent writes social media post ideas for BrightPath Marketing, a made-up digital marketing agency, and saves each idea as a row in a Google Sheet when you ask it to. Every n8n agent you build later uses the same five parts:

| Part | Node in n8n | What it does |
| --- | --- | --- |
| Trigger | On chat message | Lets you talk to the agent |
| Brain and rules | AI Agent + System Message | Plans the work and follows your standing instructions |
| Model | OpenAI Chat Model (gpt-5-mini) | Does the thinking and writing |
| Memory | Simple Memory | Remembers the conversation |
| Tool | Google Sheets Tool | Lets the agent act, here by adding rows |

## What are the steps to build your first AI agent in n8n?

There are seven steps, and each one is covered in its own section below.

1. **Get the accounts ready:** an n8n account and an OpenAI API key with a little credit.
2. **Add the trigger:** Create workflow, then **On chat message**.
3. **Add the brain:** connect an **AI Agent** node to the trigger.
4. **Write the System Message:** the business, the voice, the output format and the rules.
5. **Connect the model and memory:** **OpenAI Chat Model** with your key, then **Simple Memory**.
6. **Give it a tool:** a **Google Sheets Tool** set to **Append Row**, with every column filled by the model.
7. **Test it:** open the chat, ask for ideas, then ask it to save them.

If you're not sure you need an agent at all, [AI Agent vs Chatbot vs Automation](https://learn.ynteractive.com/content/blog/ai-agent-vs-chatbot-vs-automation) explains the difference.

## What do you need before you build an n8n AI agent?

You need an n8n account and an OpenAI API key with credit. The OpenAI API is pay-as-you-go and billed separately from any ChatGPT plan, so you add credit at platform.openai.com first (the lesson suggests $10), then create a secret key named "n8n agent" and copy it right away, because OpenAI only shows a key once. [OpenAI API vs ChatGPT Plus](https://learn.ynteractive.com/content/blog/openai-api-vs-chatgpt-plus) covers the billing and key safety in detail.

n8n Cloud has a free trial and then paid plans, or you can self-host n8n. The Stepthrough lesson runs in a practice copy, so you can learn the whole build before you sign up for anything. When you are ready, you can [get n8n](https://n8n.partnerlinks.io/2a7wq6ej1z0t) (affiliate link — I may earn a commission, at no cost to you).

## How do you add the chat trigger and the AI Agent?

Start with an **On chat message** trigger, then connect an **AI Agent** node to it. The steps in n8n:

1. Click **Create workflow**, then **Add first step...**
2. Pick **On chat message** near the bottom of the list and close the node with the **×**.
3. Click the **+** on the right edge of the trigger and choose **AI Agent**.

The AI Agent node makes a plan and carries it out with whatever tools you give it.

## What goes in the System Message?

The System Message is the standing instruction the AI Agent reads before every request: who it works for, how it should sound, what format to return and which rules to follow. Add it under Options with **+ Add Option**, then **System Message**. The lesson's BrightPath System Message:

- **Describes the business:** SEO, paid ads, social media and website design for small and midsize businesses.
- **Sets the audience and voice:** business owners and marketing managers; helpful, practical, professional and approachable.
- **Fixes the output format:** Platform, Post Topic, Hook, Short Description and Suggested Call to Action for each idea.
- **Sets the rules:** use the Google Sheets tool when the user asks to save the ideas, and don't invent statistics or make unsupported claims.

## How do you connect the OpenAI Chat Model and memory?

Click the **+** under **Chat Model**, pick **OpenAI Chat Model**, save your API key as a credential and choose **gpt-5-mini**; then click the **+** under **Memory** and pick **Simple Memory**. In detail:

1. Open **Credential to connect with**, click **+ Create new credential**, paste the key and click **Save**. n8n tests the connection and keeps the credential for every future workflow.
2. Open the **Model** dropdown and pick **gpt-5-mini** (the model the lesson uses as of October 2026), which is fast, cheap and plenty for writing post ideas.
3. Add **Simple Memory**, which keeps the recent conversation inside n8n with no database and no extra credentials.

Without Simple Memory, the agent wouldn't know which ideas "save those ideas" refers to. If memory later shows an error on a trigger that isn't a chat, [Fix "No session ID found" in n8n Simple Memory](https://learn.ynteractive.com/content/blog/n8n-no-session-id-found) explains the fix.

## How do you set up the Google Sheets Tool?

Create a sheet whose column headers match the System Message, then set the **Google Sheets Tool** to **Append Row** and let the model fill every column. First, in Google Sheets, create a spreadsheet called **Social Media Ideas** with five headers: Platform, Post Topic, Hook, Description and Call to Action. Then, in n8n:

1. Click the **+** under **Tool** and pick **Google Sheets Tool**.
2. Open **Credential**, click **+ Create new credential** and **Sign in with Google**. Approve the three permissions and click **Continue**.
3. Set **Operation** to **Append Row**.
4. Pick **Social Media Ideas** as the Document and **Sheet1** as the Sheet.
5. Under **Values to Send**, click the sparkle button (**✦**) next to each of the five columns.

The sparkle button sets a column to be filled automatically by the model, so you never map fields by hand.

## How do you test an n8n AI agent?

Click **Open chat** at the bottom of the canvas, ask for ideas, then ask the agent to save them. The lesson's first message:

Give me 3 social media post ideas about how small businesses can use ChatGPT to improve their advertising

The agent returns three ideas (LinkedIn, Instagram and Facebook), each with a hook, description and call to action. Then send:

Yes, save those ideas to the sheet

The agent decides to use the Google Sheets Tool and writes each idea as a row in Social Media Ideas.

## Try it free, step by step

**How to Create an AI Agent in n8n That Saves Ideas to Google Sheets**. Build an AI agent for BrightPath Marketing that generates social media post ideas and saves them to Google Sheets — chat trigger, AI Agent, system prompt, model, memory, and the Sheets tool. You do every step yourself in a practice copy of n8n, it checks your work as you go, and “Do it for me” finishes any step you get stuck on. Free, and nothing touches your real accounts.

[Start the free lesson](https://learn.ynteractive.com/modules/n8n-ai-agent)

[Or read the full step-by-step guide](https://learn.ynteractive.com/content/n8n-ai-agent-tutorial-google-sheets)

## What are common mistakes when building an n8n AI agent?

The common mistakes are mismatched headers, no memory and a leaked key.

- **Headers that don't match the prompt.** Five fields in the System Message need five matching columns in the sheet.
- **No memory.** "Save those" only works if the agent remembers what "those" are.
- **A leaked key.** An OpenAI API key can spend your money. Never paste it into a chat, a shared file or a screen recording.

## How do you reuse the same n8n agent for sales?

Change two things, the System Message and the sheet, and the same five nodes become a sales follow-up agent. The [AI Deal Follow-Up Agent](https://learn.ynteractive.com/content/n8n-ai-agent-sales-deal-follow-ups) lesson does exactly that for Northwind Scheduling Software, a made-up company that sells scheduling software to small service businesses.

1. **The System Message** makes the agent a sales follow-up assistant: friendly, plain, specific and brief, "a helpful rep, not a pushy salesperson." Each message matches the deal's stage, stays under 80 words, ends with one clear ask, and never invents prices, discounts or results.
2. **The sheet** is called **Deal Follow-Ups**, with five headers: Prospect, Company, Stage, Follow-up Message and Next Step.

You paste three open deals into the chat, and "Yes, save those follow-ups to the sheet" writes one row per deal for a rep to review and send. [AI Lead Qualification from a Demo Request Form](https://learn.ynteractive.com/content/blog/ai-lead-qualification-form) shows those deals and how this agent pairs with a demo request form. For the projects before and after this one, see the [n8n Jump Start](https://learn.ynteractive.com/content/paths/n8n-jump-start) path, [Learn n8n from Zero](https://learn.ynteractive.com/content/blog/learn-n8n-for-beginners) and all [n8n lessons](https://learn.ynteractive.com/content/tool/n8n). Still choosing a tool? [n8n vs Zapier vs Make for a small business](https://learn.ynteractive.com/content/compare/zapier-vs-make-vs-n8n) compares the three.

Want an agent like this built for your own team? I work as an [n8n developer for hire](https://ynteractive.com/hire-an-n8n-developer) on projects like this one.

## Key takeaways

- An n8n AI agent has five parts: a trigger, the AI Agent node with a System Message, a chat model, Simple Memory and at least one tool.
- The System Message holds the business details, tone, output format and rules, and its output fields should match the Google Sheet's column headers.
- The Google Sheets Tool set to Append Row, with the sparkle button on each column, lets the model fill the sheet without manual field mapping.
- Simple Memory is what lets a follow-up message like "save those ideas" refer back to earlier answers.
- Reusing an n8n agent for another job, like sales follow-ups, mostly means rewriting the System Message and the sheet's columns.

## Frequently asked questions

**What are the parts of an n8n AI agent?**

An n8n AI agent has a trigger (here, On chat message), the AI Agent node with a System Message, a chat model such as the OpenAI Chat Model, Simple Memory, and one or more tools, like the Google Sheets Tool.

**How do I build my first AI agent in n8n?**

Add an On chat message trigger, connect an AI Agent node, write its System Message, then attach an OpenAI Chat Model, Simple Memory and a Google Sheets Tool set to Append Row. Test it in the chat window. The free lesson walks through every click in about 12 minutes.

**Do I need to code to build an AI agent in n8n?**

No. Every node in the n8n AI agent is added by clicking, and the System Message is pasted in. The Stepthrough lesson takes about 12 minutes.

**Can I use Claude or Gemini instead of OpenAI in an n8n agent?**

Yes. The AI Agent node takes any chat model n8n has a node for, including Anthropic and Google Gemini chat models, each with its own API key and billing. The lesson uses the OpenAI Chat Model because one key covers every Stepthrough n8n lesson.

**What does the sparkle button in the n8n Google Sheets Tool do?**

The sparkle button sets a column to be filled automatically by the model. The agent reads the column headers and decides what goes in each one.

**Does an n8n AI agent cost money to run?**

The Stepthrough lesson is free. For real use, n8n Cloud is paid after a free trial (as of October 2026, Starter is listed at €20 a month billed annually for 2,500 executions), or you can self-host the free Community Edition. The OpenAI API is billed per request, separately from ChatGPT plans. Check current pricing before you build.

**Is BrightPath Marketing a real company?**

No. BrightPath Marketing and Northwind Scheduling Software are made-up examples used in the lessons.

## Free lessons in this post

- [How to Create an AI Agent in n8n That Saves Ideas to Google Sheets](https://learn.ynteractive.com/content/n8n-ai-agent-tutorial-google-sheets): Build an AI agent for BrightPath Marketing that generates social media post ideas and saves them to Google Sheets — chat trigger, AI Agent, system prompt, model…
- [Build an n8n AI Agent That Writes Deal Follow-Ups](https://learn.ynteractive.com/content/n8n-ai-agent-sales-deal-follow-ups): Build an AI agent for Northwind Scheduling Software that writes follow-up messages for your open deals and saves them to Google Sheets — chat trigger, AI Agent, system…

## Watch it in a free lesson: How to Use n8n to Build AI Agents: A Support Agent That Answers from Your Docs

### A Support Agent That Answers from Your Own Docs: video walkthrough

Full walkthrough · 2:23 · with captions

Turn an n8n chat agent into a support agent that answers only from your policies in a Google Doc, refuses what it should, and hands off to a person by email. The whole lesson narrated step by step, recorded in Stepthrough’s simulated practice environment.

[Watch it with chapters and the full transcript](https://learn.ynteractive.com/content/support-agent-answers-from-your-docs-n8n#watch)

From the free lesson [How to Use n8n to Build AI Agents: A Support Agent That Answers from Your Docs](https://learn.ynteractive.com/content/support-agent-answers-from-your-docs-n8n)

## Related terms

Plain-English definitions, each with an example from a free lesson.

[AI agent](https://learn.ynteractive.com/content/glossary/ai-agent) · [System prompt (system message)](https://learn.ynteractive.com/content/glossary#system-prompt) · [OpenAI API](https://learn.ynteractive.com/content/glossary#openai-api) · [A/B testing](https://learn.ynteractive.com/content/glossary) · [API key](https://learn.ynteractive.com/content/glossary#api-key) · [Append row](https://learn.ynteractive.com/content/glossary#append-row) · [Buyer persona](https://learn.ynteractive.com/content/glossary#buyer-persona) · [Call to action (CTA)](https://learn.ynteractive.com/content/glossary)

[The full AI glossary](https://learn.ynteractive.com/content/glossary)

## Related prompts

- [Case study interview questions prompt](https://learn.ynteractive.com/content/prompts/case-study-interview-questions-prompt): Plan a client interview that gets a case study's before, during and after story in their own words, with follow-up probes and…

[All free prompt templates](https://learn.ynteractive.com/content/prompts)

## More prompts on this topic


## Visual guides

The same ideas as quick visual guides: swipe through the slides, or read each one as text.

- [5 Steps to an n8n AI Agent That Saves to Google Sheets](https://learn.ynteractive.com/content/n8n-ai-agent-tutorial-google-sheets): A visual guide: build an n8n AI agent that writes social media ideas and saves each one as a Google Sheets row, in 5 steps from the free lesson.

[All visual guides](https://learn.ynteractive.com/content/visual)

## Keep reading

- [What Is Lead Scoring? Hot, Warm and Nurture with AI](https://learn.ynteractive.com/content/blog/what-is-lead-scoring): Lead scoring ranks new leads by fit and interest so your team calls the best ones first. What it is, a simple three-label version, and how AI applies it.
- [n8n Workflow Maintenance Checklist for the New Year](https://learn.ynteractive.com/content/blog/n8n-workflow-maintenance-checklist): An n8n workflow maintenance checklist: credentials, OpenAI credit, system message facts, sheet headers, staff emails, timezone, a test run and an owner.
- [10 n8n Beginner Mistakes and How to Fix Each One](https://learn.ynteractive.com/content/blog/n8n-beginner-mistakes): n8n beginner mistakes from real builds: the timezone, Append vs Get rows, one hard-coded address, a Gmail Tool left on send, the Test URL and more.

[All blog posts](https://learn.ynteractive.com/content/blog) · [All free tutorials](https://learn.ynteractive.com/content)
