- [Instructor] Let's start building our first
AI agent inside n8n.
Make sure you create a new workflow.
And let's also rename this workflow to Presales AI Agent.
(keyboard keys tapping)
First, we'll begin by adding a chat trigger.
This will be the main way to interact with the agent.
(mouse clicking)
We'll come back to this in a second.
Next, add an AI agent node.
(keyboard keys tapping)
This will be the heart of our workflow.
It's what brings together the model memory
and the tools the agent can later use.
You can leave the default settings here for now,
we'll also come back to this in a bit.
To make our AI agent an AI agent,
it, of course, needs some AI,
so let's connect it to a Google Gemini model.
(mouse clicking)
At this point, you can really use any model,
but we're using Gemini here
because it has a generous free tier,
and the models work pretty well for agenetic workflows.
If you haven't,
make sure to select a Gemini credential here.
To create one, click Create New Credential,
leave this window open,
head over to Google and search for Gemini AI Studio.
Click on aistudio.google.com,
and click Get Started or Log In.
You'll need a free Google account for that,
but this is how it should look like once you're logged in.
On the left, you will see Get API Key.
Click this one and click Create API Key.
If you're doing this the first time,
it might be that you need to create a new project here.
In this case, just click Create New Project
and give this new project a name.
I already have a project.
I select this and give my key a name.
Make sure to delete this key later on after our demo.
You don't need a credit card to set this up.
There's a pretty generous free tier.
Next, copy the key, head over back to n8n,
and paste the API key in here.
Click Save, and you're all set.
Let's close this window,
and you should now be able to select the Gemini models
here from this dropdown menu.
Make sure you select Gemini 2.5 Flash,
that's one we're using in this course.
Let's close this for now,
and we'll also add a simple memory component.
The goal behind this, that the agent should be able
to remember the current conversation.
So, in this case, click plus and select Simple Memory.
This will allow the agent to, in this case,
remember the last five messages.
Let's set this to 20,
so that means the agent can remember
up to the last 20 conversations.
Note that this is a really basic implementation.
The memory will be deleted once the user
closes the browser window or refreshes the current session.
There are more advanced ways
to persist memory between chats.
But, for now, this basic implementation will do.
Let's open the AI agent node again
and come back to our system prompt.
Click Add Option, and select System Message.
This will define how the agent
will behave and interact with us.
I've already prepared a system message for that.
In order to see this message or system prompt,
go to the GitHub repository,
and here navigate to Agent and agent_system_prompt.
As you can see, this is quite long.
Feel free to pause this video here
and read through it in your own time.
What this prompt does is essentially telling the agent
the goal it should solve
and the tool it has eventually available for doing this,
which, of course, it doesn't have right now at this point,
but that's fine for now.
So let's copy this prompt and go back to our n8n,
and paste the prompt in here.
Let's close this window,
and we have set everything up
to try our agent for the first time.
Click Open Chat,
and then type a quick message,
maybe "hello."
(keyboard keys tapping)
And you can see here how the agent responds.
We can now also ask a follow-up question like,
"What can I do here?"
You'll probably notice something interesting.
The agent at this point might claim that it can send emails,
generate quotes,
or help you to answer questions about the exhibition.
But that's not true yet,
because, at this point, our agent
doesn't have any tools connected,
so it might hallucinate
or say it can't perform those actions,
and that's exactly what we'll fix next.
In the next videos,
will give our agent the very first tool
so it can actually do something useful for us.
(keyboard keys tapping)
So, in this case, you can see that when I ask,
"When is the exhibition,"
it just returns an empty output
because the tool isn't available.
But there's also a good chance that it could have replied
with a hallucination and just a made-up exhibition date.
So that's what we are gonna fix in the next videos
and give our agent its very first tool
so it can actually do something useful for us.