# n8n AI Agent Tutorial: Build Your First Agent

> An n8n AI agent tutorial for beginners: chat trigger, AI Agent, OpenAI model, memory and a Google Sheets tool, built step by step and tested.

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

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

n8n · AI agents

To build your first [AI agent](https://learn.ynteractive.com/content/glossary/ai-agent) in n8n, you connect five nodes: an [On chat message](https://learn.ynteractive.com/content/glossary/chat-trigger) 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. This tutorial is for beginners with no coding background, and it follows the free [AI Social Media Idea Agent](https://learn.ynteractive.com/content/n8n-ai-agent-tutorial-google-sheets) lesson (69 steps, about 12 minutes), where the agent writes social media ideas and saves them to a Google Sheet.

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.

## 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:

PartNode in n8nWhat it doesTriggerOn chat messageLets you talk to the agentBrain and rulesAI Agent + System MessagePlans the work and follows your standing instructionsModelOpenAI Chat Model (gpt-5-mini)Does the thinking and writingMemorySimple MemoryRemembers the conversationToolGoogle Sheets ToolLets the agent act, here by adding rows

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.

## 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**, 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

**n8n AI Agent Tutorial: Save Social Media 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/path/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).

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

**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 is 69 short steps and about 12 minutes.

**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 (or you can self-host), and the OpenAI API is billed per request, separately from ChatGPT plans. Check current pricing.

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

- [n8n AI Agent Tutorial: Save Social Media 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…

## Related terms

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

[AI agent](https://learn.ynteractive.com/content/glossary/ai-agent) · [Chat Trigger](https://learn.ynteractive.com/content/glossary/chat-trigger) · [System prompt (system message)](https://learn.ynteractive.com/content/glossary/system-prompt) · [API key](https://learn.ynteractive.com/content/glossary/api-key) · [Append row](https://learn.ynteractive.com/content/glossary/append-row) · [Brand voice](https://learn.ynteractive.com/content/glossary/brand-voice) · [CRM](https://learn.ynteractive.com/content/glossary/crm) · [Large language model (LLM)](https://learn.ynteractive.com/content/glossary/large-language-model)

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

## Related prompts

- [Email subject lines prompt](https://learn.ynteractive.com/content/prompts/email-subject-lines-prompt): Get ten honest subject lines for a finished email, each with preview text and a character count, grouped by approach so you can…
- [Google Sheets columns plan prompt](https://learn.ynteractive.com/content/prompts/sheet-columns-plan-prompt): Plan the Google Sheets columns for an n8n automation: header names, what goes in each, who fills it, and which must match your…
- [Sales pipeline review prompt](https://learn.ynteractive.com/content/prompts/sales-pipeline-review-prompt): Paste your open deals and get a pipeline review for your sales meeting: stalled deals, missing next steps, past-due close dates…
- [Social post ideas prompt](https://learn.ynteractive.com/content/prompts/social-post-ideas-prompt): A four-part ChatGPT prompt for social post ideas built on your services and real customer questions: platform, hook and call to…

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

## 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/visual/5-steps-n8n-ai-agent-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.
- [Myth: An AI Model Looks Things Up Before It Answers](https://learn.ynteractive.com/content/visual/myth-ai-models-look-things-up): Myth vs fact: by default a large language model answers from its training plus your prompt. Web search or file lookup is a separate step.
- [What Is an AI Agent? A Visual Guide](https://learn.ynteractive.com/content/visual/term-ai-agent-explained): A visual guide to AI agents: AI that decides which steps to take and uses tools to take them, shown in a real n8n lesson, with tips to keep it safe.

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

## Keep reading

- [n8n Triggers Explained: Which One Starts Your Workflow?](https://learn.ynteractive.com/content/blog/n8n-triggers-explained): n8n triggers explained: schedule, Gmail, chat, webhook and form triggers, how to test each one, and how the trigger changes your AI Agent's prompt.
- [What Is n8n? A Plain-English Guide for Business Owners](https://learn.ynteractive.com/content/blog/what-is-n8n): What is n8n? A plain-English guide to workflows, nodes, triggers and credentials, with three real small-business examples and what n8n costs.
- [AI Lead Qualification from a Demo Request Form](https://learn.ynteractive.com/content/blog/ai-lead-qualification-form): AI lead qualification from a Book a demo form: an n8n agent rates each lead hot, warm or nurture, logs it and emails one fitting next step.

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