- Smarter with AI
- Posts
- MonDive#31: Building an AI agent
MonDive#31: Building an AI agent
An AI agent with n8n that manages data in Google Sheets

Welcome to the MonDive
Today in MonDive, we’re diving into n8n, a powerful no-code automation tool where you can build AI agents that understand natural language and take action across your favorite apps.
To demonstrate what’s possible, The agent we’re building today will track subscription expenses in Google Sheets. By understanding this tutorial, you’ll be able to build any AI agent you want using a similar workflow.
Alright, let’s dive into building your first AI agent with n8n.
Unlock the Power of n8n and See Advance AI Agents in Action LIVE
🚀 2-in-1 AI Masterclass on exclusive plug-n-play AI Agent : Inside the AI Lab
Step into the future of automation!
In this exclusive session, you’ll learn n8n — the no-code workflow tool powering next-gen automations — and explore 12+ Advanced Plug n Play AI Agents built for real-world roles like Sales, Branding, Consulting, and Support.
💡 What you’ll see inside:
✅ How AI Agents automate business tasks in minutes
✅ How n8n connects tools, APIs, and data — no coding required
✅ Live demos of pre-built Plug n Play Agents ready to customize
🎯 Join and experience how businesses are scaling with AI.
🧠 Why This Matters
AI is only useful when it can actually do work, not just generate text.
That’s where n8n stands out. It lets you build AI agents that don’t live inside a chat window. They connect to your real tools, follow your rules, and execute repeatable workflows.
For non-technical builders and busy teams, this is a major shift. You can create agents that support day-to-day operations, automate admin tasks, route information between apps, handle structured processes, and reduce the manual work that slows everything down.
The tutorial you’re about to follow isn’t just a one-off project. It’s the foundation. Once you understand the building blocks, you can start designing more powerful agents that fit your workflow and scale with your needs. like a lead tracker agent, a content ideas agent, or a task manager agent, all inside the same n8n canvas.
Starting with n8n
Go to n8n and click Get Started.
Fill in your details and complete the sign-up process. Once you log in, you’ll get a 14-day free trial, which is more than enough to build and test your AI agent.
Step 1: Create a Workflow and Add a Chat Trigger
Create a new workflow and start from scratch.
Once the workflow opens, add a Chat Trigger as the first node.
After selecting Chat Trigger press Esc or click outside the node to return to the main workflow canvas.

A node in n8n is a single building block in a workflow. Each node performs one specific job, and by connecting nodes together, you define how data moves and what actions happen.
The Chat Trigger node is the entry point of your AI agent. It allows you to send messages to the agent in natural language. You can also use other chat-based triggers, such as WhatsApp, Telegram, or similar options, if you prefer a different channel.
Step 2: Add the AI Agent Node
On the workflow canvas, click the plus (+) icon next to the Chat Trigger and add an AI Agent node. connect it to your trigger: Chat Trigger → AI Agent.

Step 3: Connect a Chat Model to the AI Agent
Click the plus (+) under Chat Model on the AI Agent node and select OpenAI Chat Model.
After selecting click Add credential. Paste your OpenAI API key, then press Esc or click outside the panel to return to the workflow canvas.

The chat model is what allows your AI agent to understand messages and respond intelligently. OpenAI works great for this setup, but you can also connect other models like Google Gemini, Anthropic chat model, Groq or any supported model if you have their API keys.
Step 4: Add Memory to the AI Agent
Click the plus (+) under Memory on the AI Agent node and add a memory option.

Memory allows your AI agent to remember previous messages in the conversation instead of treating every message as a new one. This makes the agent more natural, consistent, and useful when handling follow-up messages.
Step 5: Create a Google Sheet and Connect It as a Tool
First, create a Google Sheet with these columns:
Expense, Charge Date, Cadence, Cost, Status.
Name the sheet tab tracker and copy the sheet link and keep it open.

Now return to n8n. On the AI Agent node, click the plus (+) under Tool and select Google Sheets.
Click Add credential and connect your Google account.

After connecting your Google account, set the Operation to Append Row.
In the Document section, choose Select by URL and paste the URL of your Google Sheet, then select the tracker tab.
For the fields Expense, Charge Date, Cadence, Cost, and Status, click the star (AI) icon so the AI can automatically define and fill these values.
Once everything is set, press Esc or click outside to return to your workflow canvas.

Step 6: Generate and Add the System Prompt
Take a screenshot of your n8n workflow, then download the workflow as a JSON file.

Go to ChatGPT, upload both the screenshot and the JSON file, and paste the prompt below. ChatGPT will generate a system prompt that matches your exact workflow and tool setup.
Prompt:
## TASK ##
Your task is to output a clear, precise, and comprehensive system message for my n8n AI agent designed to keep track of my subscriptions (i.e. recurring expenses).
## CONTEXT ##
The AI Agent is connected to a Google Sheet and has access to the "AddEntry" tool.
When the user sends a message like "I just subscribed to ChatGPT for 20 usd a month" the AI agent should first confirm its understanding then fill out the columns in the Google Sheet.
For example:
Expense = ChatGPT
Charge Date = By default use today’s date (date chat was sent) unless stated otherwise
Cadence = Monthly
Cost = $20
Status = Active
I've attached a .json file and screenshot for you to reference.
The Pompt chat gpt gave:
Role & Objective
You are an AI agent whose sole purpose is to help the user track subscriptions and other recurring expenses.
Your job is to interpret natural-language messages about subscriptions, confirm your understanding, and then record them accurately in a Google Sheet using the Add Entry tool.
1. When to Act
Trigger only when the user message clearly indicates:
A new subscription
A recurring expense
A change to an existing subscription (price, status, cadence, etc.)
If the message is ambiguous or missing required details, ask a single clarifying question before proceeding.
2. Confirmation Step (MANDATORY)
Before writing anything to the sheet, you must confirm your understanding in plain language.
Your confirmation should summarize:
Expense name
Cost
Cadence
Charge date
Status
Example:
“Got it — I’ll add ChatGPT as a monthly subscription for $20, starting today, with status Active. Let me know if that looks right.”
Only proceed once the user agrees or does not object.
3. Google Sheet Column Mapping
When calling the Add Entry tool, you must populate all columns using the exact keys below:
Column Name Rules
Expense Name of the service or product (e.g., “ChatGPT”, “Netflix”)
Charge Date Use today’s date (date message was sent) unless the user specifies another date
Cadence Normalize to one of: Monthly, Yearly, Weekly, Quarterly, or One-time
Cost Numeric value with currency symbol if provided (e.g., $20, 20 USD)
Status Default to Active unless the user explicitly says otherwise
4. Defaults & Assumptions
If the user does not specify:
Charge Date → use today
Status → set to Active
Cadence → infer from phrasing (“a month”, “per year”, “annually”, etc.)
If inference is not possible, ask a clarifying question.
5. Tool Usage Rules
Use only the Add Entry tool to write to the spreadsheet.
Never fabricate values.
Never write partial or unconfirmed data.
Never create duplicate entries unless explicitly requested.
6. Tone & Style
Clear, concise, and professional
No emojis
No unnecessary explanations
Focused on accuracy and confirmation
7. Example Flow (Correct Behavior)
User:
“I just subscribed to ChatGPT for 20 usd a month”
Assistant:
“Just to confirm — I’ll add ChatGPT as a monthly subscription costing $20, starting today, with status Active. Should I go ahead?”
→ After confirmation, call Add Entry with the mapped fields.
After copying the system prompt generated by ChatGPT, go back to your n8n workflow and open the AI Agent node.
Select System Message, click Expression, and paste the system prompt into the box. Then press Esc to return to the workflow canvas.

Your AI agent is now fully configured. When you type a message in the chat box, the agent will respond and act based on the rules defined in your system prompt, including adding subscription details to the connected Google Sheet.
Final Result: Your AI Agent in Action
Click Start Chat and you’ll see a chat box connected to your workflow.
When you type something like “I subscribed to iCloud for 20 USD a month”, the AI agent first responds with a confirmation message to make sure the details are correct.
After you confirm, the agent automatically generates and adds the subscription information into the Google Sheet it’s connected to.
Each entry is structured with the correct Expense, Charge Date, Cadence, Cost, and Status, without you touching the spreadsheet manually.

In this exact same workflow, you can turn this AI agent into something else . Just swap the System Prompt, the AI agent can generate and write different kinds of structured data into Google Sheets , not just subscription tracking as long as your Google Sheet columns match what you want to store.
So the exact same setup can become a lead tracker, a content ideas tracker, a task manager, a results sheet, or any other structured tracker you want
Beyond the Basics: Advanced Considerations
This is the core concept of building an AI agent in n8n: start with a trigger, connect an AI brain (chat model and memory), give it tools (like Google Sheets), and control everything with a system prompt. Once you understand these building blocks, you can keep adding different nodes and create almost any agent you want on the same canvas, from simple automations to more advanced workflows that handle edge cases and respond more intelligently.
And the best part: you can build and test all of this during the free trial. When you’re ready to scale, a small investment lets you host your agent, use it in your own business, or package it and sell it as a service.
Will you try building your own AI agent in n8n? |
We’d love to hear from you!How did you feel about today's MonDive? Your feedback helps us improve and deliver the best possible content. |
Know someone who may be interested?
And that's a wrap on today's MonDive!


Reply