# n8n Tutorial for Beginners - Build Your First Free AI Agent

Source: https://www.youtube.com/watch?v=dpoMEcXjVH8
Recap page: https://rapidrecap.app/video/dpoMEcXjVH8
Generated: 2025-07-29T07:32:07.994+00:00

---
## Quick Overview

This n8n tutorial demonstrates how to build a free AI agent that automates sending payment reminders via email, integrating with QuickBooks Online and using Google Gemini for AI processing.

**Key Points:**
- The tutorial successfully builds an AI agent using n8n that identifies overdue invoices in QuickBooks Online and sends payment reminders via email.
- Key components of the agent include the "When chat message received" trigger, "Agent" node, "Google Gemini Chat Simple Model" for AI, "Simple Memory" for context, "getInvoices" tool for QuickBooks data, and "sendPaymentReminder" tool for email.
- The agent's prompt is carefully structured with "Role", "Task", "Tools", and "Outputs" to guide its behavior, including escalating tone for overdue invoices.
- The workflow utilizes JavaScript expressions within n8n to dynamically fetch the current date for invoice filtering.
- The tutorial demonstrates the use of "Split Out" and "Loop Over Items" nodes to process multiple invoices and send individual emails.
- A "Create a channel" node for Discord is added to receive approval for sending emails, showcasing conditional logic.
- The final workflow successfully sends payment reminders and provides a JSON summary of the actions taken.

![Screenshot at 04:01: The n8n workflow canvas displaying the "When chat message received" trigger, "Agent" node, "Google Gemini Chat Simple Model", "Simple Memory", "getInvoices", and "sendPaymentReminder" nodes, illustrating the core components of the AI agent.](https://ss.rapidrecap.app/screens/dpoMEcXjVH8/00-04-01.png)

**Context:** The video is a tutorial demonstrating how to build an AI agent using the n8n workflow automation platform. The presenter, David, explains the core components of an AI agent and guides viewers through setting up a practical workflow that automates sending payment reminders to customers with overdue invoices.

## Detailed Analysis

The tutorial guides viewers through building an AI agent using n8n, a workflow automation tool. The agent's purpose is to identify customers with overdue invoices in QuickBooks Online and send them payment reminders. The workflow begins with a "When chat message received" trigger, feeding into an "Agent" node. This agent node connects to a "Google Gemini Chat Simple Model" for AI processing, a "Simple Memory" node to store context, a "getInvoices" tool to retrieve overdue invoices from QuickBooks Online, and a "sendPaymentReminder" tool to send emails via Gmail. The prompt for the agent is carefully crafted to define its role, task, tools, and desired output format, ensuring it acts as a collections assistant that escalates its tone as invoices become more overdue. The tutorial also covers setting up necessary credentials, like API keys for Google Gemini and SMTP credentials for Gmail, and configuring the different nodes, including the "getInvoices" query to filter for overdue invoices and the "sendPaymentReminder" tool to customize email content. Finally, it shows how to execute the workflow, troubleshoot errors, and use the "Split Out" and "Loop Over Items" nodes to process multiple invoices and send individual emails, culminating in a successful test run that sends emails and provides a JSON summary of the action.

### AI Agent Basics

- Role, Task, Tools, Outputs
- Building the Agent: Connecting Google Gemini, Simple Memory, getInvoices, and sendPaymentReminder tools
- Prompt Engineering: Crafting the AI agent's instructions and context
- Workflow Execution: Setting up triggers, testing, and troubleshooting

### AI Agent Setup

- Define Role as Collections Assistant
- Task Definition: Identify overdue invoices and send reminders with escalating tone
- Tool Integration: Connect to Google Gemini, QuickBooks Online (getInvoices), and Gmail (sendPaymentReminder)
- Prompt Engineering: Specify output format and use JavaScript for date formatting
- Workflow Logic: Use "If" node to route based on approval status, "Loop Over Items" to process multiple invoices, and "Create a channel" for Discord notifications

![Screenshot at 00:06: The n8n interface showing the "When chat message received" trigger connected to the "Agent" node, which is further connected to "Google Gemini Chat Simple Model", "Simple Memory", "getInvoices", and "sendPaymentReminder" nodes.](https://ss.rapidrecap.app/screens/dpoMEcXjVH8/00-00-06.png)
![Screenshot at 00:46: The "Agent" node configuration showing the prompt with defined "Role", "Task", "Tools", and "Outputs" sections.](https://ss.rapidrecap.app/screens/dpoMEcXjVH8/00-00-46.png)
![Screenshot at 01:17: Visual representation of the tools available to the AI agent: dollar sign \(money movement\), shopping bag \(ordering\), envelope \(email\), and network icon \(collaboration\).](https://ss.rapidrecap.app/screens/dpoMEcXjVH8/00-01-17.png)
![Screenshot at 02:11: The Docker Desktop download page, showing options for Mac, Windows, and Linux.](https://ss.rapidrecap.app/screens/dpoMEcXjVH8/00-02-11.png)
![Screenshot at 04:01: The n8n workflow canvas with the basic AI Agent template, including the "When chat message received" trigger, "Agent" node, "Google Gemini Chat Simple Model", "Simple Memory", "getInvoices", and "sendPaymentReminder" nodes.](https://ss.rapidrecap.app/screens/dpoMEcXjVH8/00-04-01.png)
![Screenshot at 05:11: The Google Gemini API account setup screen, prompting for API key and showing available models.](https://ss.rapidrecap.app/screens/dpoMEcXjVH8/00-05-11.png)
![Screenshot at 08:26: The SMTP account configuration for sending emails, requiring user, password, host, and port.](https://ss.rapidrecap.app/screens/dpoMEcXjVH8/00-08-26.png)
![Screenshot at 11:55: The ChatGPT interface with a prompt template for an AI agent, detailing the role, task, context, tools, and outputs.](https://ss.rapidrecap.app/screens/dpoMEcXjVH8/00-11-55.png)
![Screenshot at 14:01: The n8n workflow showing the prompt with JavaScript expressions for retrieving and formatting the current date.](https://ss.rapidrecap.app/screens/dpoMEcXjVH8/00-14-01.png)
![Screenshot at 17:17: The n8n workflow with the "Split Out" node added, processing the agent's output into multiple items for further processing.](https://ss.rapidrecap.app/screens/dpoMEcXjVH8/00-17-17.png)
