This content demonstrates how to build a free, no-code AI agent using n8n to automate tasks, specifically focusing on sending payment reminders to clients with overdue invoices, and incorporating a human-in-the-loop approval process.
Mind Map
Click to expand
Click to explore the full interactive mind map • Zoom, pan, and navigate
Hey, did you know you could create an AI agent completely for free and you don't even need to
know how to code? I'm David and at David's Donut Den, sometimes we have customers who order donuts
for events, but they don't pay us on time, so I gotta chase some people down. Instead of me
keeping track of that, let's build an AI agent to take care of that for us. We're gonna use the app
N8N. I'll show you how to set it up for free in just a minute, but first, let's get on the same
page about what an AI agent actually is. So AI agent can mean different things depending on who
you're talking to. So for this video, I really mean a digital process that starts to feel like
a real teammate doing work for us. That boils down to about three characteristics. First is they have
reasoning skills. Unlike an AI chatbot, which you would detail explicit steps to, agents can take
in a goal and figure out the best way to achieve that goal. In this example, the agent could first
make sure that the article is relevant, the tone and format works for LinkedIn, it checks its work,
et cetera. It figures out what you meant versus just doing what you said. The second is they have
tool access. Unlike chatbots, they can actually do things like move money around, email someone,
order something for you, or make a post on social media. Third is they have memory. They maintain
context throughout a task and even multiple tasks. So they learn from past mistakes just like we do.
Now if that starts to feel like these agents will replace you, I honestly can't say whether they
will or won't. But the more you know about them, the more they can enhance and support you. Now
we're going to build an AI agent in N8N. N8N is a workflow automation tool like Zapier or make.com.
After you sign up, you get a 14 day free trial and up to a thousand workflow executions for free. But
if you're willing to do just a little more work, I'll show you how to run it for free. First, go to
the Docker desktop website. You can find the link in the description below. Then go to the download
Docker desktop version and choose the version which is right for you. Once it's downloaded,
go ahead and install it. After the install, you'll probably have to restart your machine.
And if you're on Windows, make sure you enable WSL or Windows Subsystem for Linux if you're
asked. After the install on Windows, double click the Docker desktop icon to launch it. Accept the
service agreement when you're ready and we'll skip making an account. Now go down to your taskbar and
click on the start menu. Type in CMD and then click on command prompt. Then type this exactly
all lowercase Docker volume create n8n_data. Then press the enter key. If it was successful,
you should just see n8n data. Here's the next command. By the way, both of these you can copy
from the description. Press enter again. And after a few moments, your Docker should be started.
What does that mean exactly? Well, it means you can copy and paste this link into a new browser
window to access n8n. Then create your account and I'll see you on the dashboard. Now here's the main
dashboard. I like this one compared to other tools because it's pretty simple. In the top right,
you'll see you can create a new workflow. We'll come back to that in just a second.
Below that you have some analytics about your workflows. And then in this section,
you'll see all the workflows that you've built. Don't miss down in the bottom left hand corner.
You also have access to thousands of templates. Let's check a few of them out. You can search or
filter by the type of template. So let's check out AI templates. You can find all sorts of ways that
n8n can help you in your personal life as well as at work. Back on the homepage, click on test
a simple AI agent example to get started. This is the n8n editor. You can move around the canvas
by using your touchpad or by middle clicking with your mouse and dragging. And when you want to get
back to the full view of your workflow, click on the zoom to fit button in the bottom left. You can
also press the number one key. Now our workflow has two steps in it and those steps are called
nodes. The first node is special. It's called a trigger that tells n8n how the workflow starts.
Because this node says when chat message received, it seems like we can already chat with our agent.
Let's try it by clicking the open chat button. Then I'll ask in the chat window,
are there any signs of life out there? And we hit an error. This is totally expected. We have to set
up our agent first. There are three things we need to set. First is the chat model, then the memory,
and then a set of tools. The model is the reasoning power behind the agent. It's the LLM
you want to use. Let's delete the open AI model by clicking on the trash can. Then I'll click on the
plus icon to see what models I can choose from. There's a lot of others like anthropic Gemini,
deep sea, Olama, and so on. In this video, we'll select Gemini because I want to show you how to
do this for free. Here we need to get n8n talking with Gemini. That's done through a credential. So
I'll click on the select credential dropdown and click create new credential. To do this,
we need an API key. That's no problem. Head over to aistudio.google.com. You can grab that link
from the description. And once you're here, click on the get API key button in the top right. From
here, click create API key, then click create API key in new project. If you don't see this button,
you can probably create an API key in an existing project. Once you have your key, copy it,
then head back over to n8n and paste that key. Click save in the top right. You should see that
the connection tested successfully, and then click the X in the top right. Then under model, open the
dropdown and scroll down until you see Gemini 2.5 flashlight preview 617. The reason we're choosing
this is because on the free plan, it gives you 15 free requests per minute and 1000 free requests
per day. If these limits have changed, you can check the link in the description to find a better
model for you. Now we set up the model. You can click anywhere outside these boxes to head back
to the canvas. To see if this worked, let's try the chat one more time. Well, it ran successfully,
but it didn't give us a useful answer. We'll have to set up the agent's memory first. Click the plus
icon next to memory to add a memory node. So memory gives the agent power to remember its
previous steps. In this tutorial, we'll keep it simple and choose simple memory. We'll also
change the session ID from connected chat trigger node to define below. It doesn't matter what you
type here. It just means there'll be one place to store memory and it'll store the last five
messages with the model. Let's head back to the canvas and add our last piece, which are tools.
These give the agent power to do what it needs to do. Let's check out what's available by
clicking on the plus button. You can integrate with over 250 different products here. The
agent needs access to past invoices and we can enable it through the QuickBooks Online tool.
N8n already has an integration here, so I'll click on that. Just like with Gemini, you'll
need to set up your credentials. Now, because you might not have QuickBooks, take this as an
example of any third party app you might want to integrate with. The options that show up after
tool description will depend on the app. In this case, under resource, we want to get invoices and
under operation, we want to get many invoices. We only want the invoices that are overdue, so
let's add a filter. We could type this in by hand, but the whole point of an agent is it should be
able to figure this out for us with some minimal instructions. So click the AI button to say, let
the model define this parameter. Next, the agent needs to send payment reminders. That means email.
Back on the tool connector, click plus again and then search for email. Now, if you're using the
cloud version of N8n, it's actually easier to use the Gmail tool directly. That's because you
can just sign into Gmail, but when you're self hosting, you have to do a little bit more work.
Let's click the send email tool. Just like with other tools, let's create our credential. We'll
use our Gmail settings. That means the user is our email address and the host is smtp.gmail.com.
Now the password is not your Gmail password. It's something called an app password. You can create
one by going to security.google.com, making sure that you're signed in and then searching for app
passwords at the top of the screen. Click on the app passwords icon to make one. Once you have your
password, fill in the form and then click the save button in the top right. Your connection should be
successful, so let's exit out of this one too. Now that my credentials are set, I need to tell the
agent who and what we're emailing. First is the from email. That's easy. It's the email we signed
in with. Next is the to email. Now the agent's going to get that from the invoice, so we need
to tell n8n let the model define this parameter. We also want the model to decide the subject line.
Then to simplify the email, let's make it plain text instead of HTML. And we'll also rely on
the model to generate the message. Now we had to set all of those parameters, but there are some
optional ones which we can explore by clicking the add option button. You can add attachments or add
a CC line or BCC line. However, let me turn your attention to append n8n attribution. This adds
a message to the bottom of every email saying it was sent by n8n. We want to look more professional
than that, so let's turn that off. Now let's head back to the canvas and put all of this
together. Let's save our progress first and then let me tell you something about tools. See it's
our responsibility to teach the agent about these tools. And to describe a tool, it helps to name
it first. So to name the QuickBooks online tool, I'll double click it to open its node settings
again. Then I'll click on its name and give it a new name. Get Invoices is a simple self-evident
name. Let's exit out of here and then give a name to our email tool. I'll make this one a little
bit more descriptive and call it send payment reminder. Now it's time to make our agent sing.
Let's double click on the agent to see what we can configure about it. First we can click on the
agent drop down to see that n8n supports multiple different types of agents. The tools agent is the
default. This supports calling all the tools we've just set up. Next we have the prompt. I'm going to
click this icon in the bottom right corner of the window to expand it. In the center of the screen,
we just have the current prompt. This is the default that n8n sets up ahead of time. These
green and red blocks indicate that the prompt is created dynamically. As you can see, anything
inside those curly braces is JavaScript. And then on the right side, you'll see the JavaScript
evaluated for the current context. This by the way is why our chats didn't work earlier. It's because
the agent was instructed to tell us to connect to memory first. Now instead of starting this prompt
from scratch, let me show you a process that can help you get to that right prompt. I'll head over
to the free version of chat GPT, and then I'll click that speech bubble in the top right to
turn on a temporary chat. I'm doing this so chat GPT doesn't use any of its past memory or prompts
for what I'm about to show you. So we're going to ask chat GPT to create this agent prompt for us.
Here is a template that you can follow. First help me write a prompt for an AI agent using these key
components, role, task, tools, and outputs. These are common elements of reliable prompts. Then I'll
tell chat GPT I'll write a brief below that starts with a task and this pound sign is just a symbol
to indicate a heading. So the task is to send payment reminders to customers who have at least
one overdue invoice in QuickBooks Online. The next step is context. This is more info for the
agent on how to act to do its job. Basically here I'm telling it to start polite when the customers
are under seven days overdue, but get more and more firm. Then make sure you only send one email
per customer even if they have multiple overdue invoices. Next comes the tools and this is where
we use the tool names to offer descriptions to the agent. I tell it how to get overdue invoices
and that it can send payment reminders. Finally I describe what I want at the end of the process.
Here I'm asking for data in a JSON format which will show why later on. When I submit this chat
GPT will put the full agent prompts together for me. Now a trick which I didn't do here is ask chat
GPT to ask me questions first in case there is any ambiguity. You can see an example of that
in the description. Now you do need to proofread that this is actually what you want, especially
within the task section. I'm happy with this. So now let's get it into a format we can copy with
this prompt. You can copy this prompt from the description. It just converts that prompt into
markdown back in an eight and let's replace the prompt in the center column with the prompt that I
just copied. Now we're not quite ready yet. We've got one more thing we need to change. It's this
today field I just highlighted the AI model won't know what today's date is. So we've got to tell
it. Here's how we'll do that. I'll simply tell the model the current date that uses JavaScript which
requires me to use two open braces. Then to get today's date I can use the special variable now
on the right side we can see what that actually evaluates to. It's not quite what we want. But
if we use the format function we can retrieve the date by using this date format that gives us the
right date over here too. And if you're not a coder just remember you can use this text to
get the current date. Now you've been so patient through all this configuration. Let's get this
agent working. I'll add a simple step to run this and then let's see what happens. No guarantees
that this works the first try. Okay, I had to try this a few times to get it to work. Every time an
issue came up I just tweaked the prompt a little bit to fix it. To see what actually happened I've
expanded this bottom pane to see the logs. You can click on any step the agent went through to see
more detail. And you'll normally see inputs and outputs broken up side by side. So it understood
it needs to fetch the invoices and then called the get invoices tool. Then it re-invoked the model
with this new data and found multiple overdue invoices. Then it sent two payment reminders and
one of them was for the Kevin Cookie Company. I always got to chase that Kevin guy down. And
finally here's the actual email which I can access from my sent box. That brings us to the sponsor of
today's video. Intuit the creator of QuickBooks Online. Now it's annoying when you don't get
paid on time but did you know that QuickBooks Online already has AI driven payment reminders
built in? They're configured ahead of time and based on the customer's history. And if you have
several late customers, QuickBooks Online will guide you through automatic late fee collection.
It's about more than getting paid though. QuickBooks tracks all the money you earn and
spend and categorizes it automatically with AI. That way you actually save money on your taxes
since you'll find extra deductions. And sales tax is tracked for you too. So it's a breeze to
know how much you owe to each agency. And now it's powered by its own suite of AI agents. It
is a great time to try QuickBooks. Click the link down in the description to give it a shot. Okay,
so even though we were successful, what we have so far isn't realistic. I have a hard time believing
anyone would send out emails without reviewing them first. When we put a reviewer in the process,
it's called human in the loop. Fortunately, N8N realizes this is a core part of an agent workflow.
So it's got a number of tools you can use to get human approval. Let's build this out by creating
an approval process in Discord. Just like all other nodes, we'll start with the credential.
I've already set up a token so I can paste that in here. Now let's configure the bot. I want the bot
to message me. So message is correct. I also want it to wait for a response. So this is correct.
So next I'll choose my server and I want all of these approvals to go to the approvals channel.
All good, but now we're stuck because we don't have access to the email subject and message
here. I can tell that because I can see all the possible data I have access to in this input pane.
And the only thing the agent tells us is that it's sent to emails. Not helpful. So let's modify our
agent node to make this work. So we skipped this option last time, but we're going to need it now.
It's called require specific output format. This adds another option to the agent called an output
parser. Let's add one and make sure all the data we require comes back. We'll use the structured
output parser that gives us the best chance of getting the subject and message in the discord
node. Here we can set up an example of the format that we want. This has everything a human might
need to make an approval. Now if this looks like Greek to you, don't worry. You can provide chat
GPT with a list of these fields and ask it to generate sample data in Jason for you. Okay, if
we've done everything right, the output should now match this format. Before we try it, let's clean
up three other things. First we need to remove the send payment reminder tool. The agent can
only email if it's been approved in discord. So I'll remove this tool by clicking the trash icon.
Second let's update the prompt to accommodate this change. There are two changes here. First, the
agent should just write each customer an email, not send it. And second, we'll remove the send
payment reminder tool from the prompt. The last thing to clean up, which I've ignored until now,
is that we kick this off with a chat message. What we need instead is a schedule. This is a
weekly operation. So I click the plus button here and then I can click add another trigger and then
select on a schedule. To make this a weekly operation, I'll change the trigger interval
from days to weeks and then leave weeks between triggers at one. We'll get out of here and then
now let's remove the chat node with the trash can. Let's see if our agent likes the changes. I'll
double click on the agent node and then I'll click execute step. This only executes the workflow up
to this node. Okay, it looks like we hit an error and we can see from the red outline around the
tool that it's in the get invoices step. Sometimes this happens where the LLM sends the wrong data
to your tool. In this case, it made up sending select star from invoice. So let's just make a
quick edit to the tool description so it doesn't do that. Now let's try this again. Awesome. That
did the trick. Now to check the output will work for that discord node, I can click on this output
button. Now it looks like we have everything we need. Customer name, customer email, subject and
the body. Now give yourself a pat on the back because this was the hard step. Now let's get
this approval process set up in record time. The agent gives us output, but we need that output as
a list of email details. That's so we can run an approval process on each one. To make that happen,
I'm going to add a new node called split out. This does what we want. Turn a list and side items into
separate items. So see how the agent gave us this output node. We actually need the details
list instead. Now that's as easy as dragging and dropping details into fields to split out. You
can preview this again through execute step and see that it results into items. Now that we have
the list, we've got to add a new node to loop over each item. You'll find that under the flow nodes
and then select loop over items. And we'll keep the batch sizes one since the approvals run one
at a time. Now this loop looks different from the other nodes. It has a loop case and a done
case. The approvals run in a loop, so I'll get rid of this replace me node and this loop path. Also
get rid of the done path and then drag and drop the plus of the loop path to our discord node.
Now let's configure the approvals. I'll double click on this discord node so we can edit it.
This time we now have access to all the data to create a message. Here's my very simple template
to start plugging in data. And next I'll drag in fields from the input starting with email body.
I'll add the customer name as well as the email subject. And you can see a preview of the data
down below. Now what's cool with N8N is that the approval processes are built in. So all we need to
do is add approval options and it'll take care of the rest. I'm going to choose a simple approve or
disapprove workflow. But you can allow your human to make corrections via the response type option.
So let's test this out by clicking execute step. Here in discord in this approvals channel, I can
either decline or reject the message or approve it. Let's click approve. Now we've tested it,
we get the output saying that approved is true. That means we can send the email. So let's get
that set up. To create a branch, we're going to go back to flow nodes and this time choose
if. So we only move forward if approved is true. I'll start by dragging and dropping approved into
values. Then I need to change the comparison. Since approved is a Boolean, I'll go to that
dropdown list. Then I'll select is true. Now it's time for the email node. We'll go over to this
true branch because we're testing if approved is true. Search for our email tool like last time and
then let's set up send email. I don't want to wait for a response. So I'll just click send an email.
Let's make sure we get our previous data first. That takes a second or two and now we need to fill
in the email info. This is where I don't like n8n. See, we can't access the current data in the loop.
Instead we've got to get it from code. You can copy and paste this code from the description and
the email text is the last of it. We'll head back to the workflow then make sure that every branch
goes back to the loop that includes your approvals and rejections. Now let's run our workflow end to
end and see if it works. Okay, it got our emails and now it's waiting for us to respond in discord.
Let's reject this first one for hope Mills. And now the second one comes in for the Kevin cookie
company. We got to approve that one. Back in the workflow we see one email was sent and one was
not. And we can see that email in our sent box. And look at that in just a few clicks you can have
an AI agent that can reason about the best way to achieve a goal, invoke a number of different tools
to get there and even work with humans to produce the best outcome. Thanks so much for watching.
Leave me a comment on what you want to see me cover next and I'll see you in the next video.
Click on any text or timestamp to jump to that moment in the video
Share:
Most transcripts ready in under 5 seconds
One-Click Copy125+ LanguagesSearch ContentJump to Timestamps
Paste YouTube URL
Enter any YouTube video link to get the full transcript
Transcript Extraction Form
Most transcripts ready in under 5 seconds
Get Our Chrome Extension
Get transcripts instantly without leaving YouTube. Install our Chrome extension for one-click access to any video's transcript directly on the watch page.