Welcome.
In this episode, we are going to build our very first agent and it's going to be something super practical.
It will send emails for us.
So this is probably one of the easiest agents you can build, but also one of the most useful.
You will see how quickly it all comes together, and by the end of this tutorial, you will have a fully
working setup that can understand your instructions and send emails automatically.
So we will communicate with our agent via built in open chat and instruct it to send emails for us.
And our agent is going to call tools.
So Gmail Tool and Contacts tool.
So it will retrieve the email address from the Google sheet I've prepared, and then craft an email
and send it to that email address.
We use a simple memory so it will remember the history of our conversation from our open chat, and
we can specify how many messages we want it to remember.
And we will trigger our an agent by this chat message.
But you can easily connect third party apps like telegram, slack, WhatsApp, and you can find how
to set up credentials and connect these nodes in the How to Setup credentials section.
So you can either follow me step by step, or just copy the whole workflow and tweak it to your needs.
And it's totally up to you, but I strongly recommend to learn with me along the way so we fully understand
how it works and how you can build on top of that, and also how to add more tools to your agent.
Alright, so let's start building and Create our agent from scratch.
So let's create the workflow.
First I'm going to add a chat trigger node as a trigger.
So that will activate our agent.
So let's search for chat.
And select this one.
Now let's close it for now.
Now let's add our agent.
So search for agent.
Press on this one.
So this is where we define the brain of the operation.
So now to make the agent actually understand us I'm going to connect chat model.
So we are going to use OpenAI GPT for all model.
But you can choose your favorite large language model such as cloud, Gemini, grok, Mistral and you
can connect to any LLM via operator.
And I'm going to explain how to use operator in the setup credentials section.
So if you are looking for LLM that has a dedicated node in N810, you can use operator.
All right.
So let's use OpenAI chat model.
Now connect to your account.
And from the list choose GPT four mini or GPT for all.
For this particular example you can use GPT four mini.
It will it will work great.
Now next we add a simple memory so it stores in memory, so no credentials are required.
Press on that.
And here you can specify the context window length.
So basically it means how many pass interactions the model receives as context.
So in this setup how many messages it has to remember from the open chat.
Feature.
While we be interacting with it.
So let's close it for now.
And let's say we want it to remember ten messages.
Great.
Now let's connect our agent to a Gmail node.
So we are going to create a tool which will be called by our agent.
So we are going to use.
Gmail node.
So Gmail tool.
And we want to send message.
Just make sure you are connected to the correct Gmail account.
So this is where the magic happens.
So this tool is going to send emails on our behalf as the resource you have.
Message sent because we want to send an email.
So we need to fill in these fields to subject and message.
And let me show you something cool.
So this new feature lets you autofill those fields using AI.
So instead, instead of writing manual expressions or hard coding anything, you just click the little
purple purple button next to each field and it fills in the right info for you automatically.
So it reads your prompt understands who the email is for what it's about, and write the message.
So it's super fast and super clean.
If you want a bit more control though, you can use the from OpenAI expression.
So just to switch the field to the expression and write the expression programmatically, and I'm going
to show you how to do this in the build your team of AI agents lesson.
So now let's keep it simple.
I'm just going to let the model define the parameter.
So simply simply click on that.
The same for the subject and for the message.
Now let's add another tool.
So Google Sheet to store our email addresses.
We want to email two.
So click on the tool again ad tool search for Google Sheet.
Tool which allows for reading, updating and writing data to Google Sheets.
Click on that.
Now go to your Google Drive and create a simple Google Sheet.
With two columns like Name and Email and enter some data.
Then go back to connect to your Google account.
So just simply click on this drop down.
Create new credential and sign in with Google, which will automatically connect to your Google Sheets,
and it will give your agent access to the Google Sheet you created.
And hit save.
Close it.
So we want set it Automatically, not manually.
So we are looking for a sheet within the document as the operation.
We want to get rows.
And here we want to select a document from the list.
If you have connected to your Google account, the Google sheet you have created should pop up here.
So now I'm going to refresh the connection.
And now when I want to choose the document from the list, you can see I have access to contacts I have
created.
So this is this Google sheet with the context data.
Now we want to choose a sheet within this document.
So it's sheet one.
It should pop up automatically.
Yeah I'm going to choose this one.
And that's it for for this node.
Now let's go back to our agents.
Let's open this node.
And now we want to add a system prompt.
So basically we want to guide our agent.
What we want to achieve.
So we want to provide instruction on what to do exactly.
So click on add option.
System message.
And then switch to expression mode.
And expand it.
And now I'm going to copy and paste the prompt I have prepared.
So this is our very simple prompt.
So we define the role for our agent.
So you are a professional personal assistant agent.
Your primary role is to send emails and you have access to two tools.
So contacts and email tool.
So basically two tools we have created.
And here we are describing how to use these tools.
So contacts use this tool when you need to look up contact information like an email address or phone
number.
You need to use this tool before sending an email or before getting emails.
And email tool you can add two here.
I use this for image related actions like sending emails, reading emails, or forwarding emails.
So basically you can add more tools to this agent if you want your agent to read emails for you and
summarize them, etc. you can just simply.
Add tool.
Again.
And here you just change the operation.
So you can add label, delete, get, get many emails and so on.
Now for this tutorial let's keep it simple.
So I'm going to remove it and let's work on our prompt.
So you want keep emails professional and format it nicely.
So the body of the email with the line breaks and clear structure.
And we always want it to sign off as best regards.
And Damon.
And here is the current time and date.
So just to make sure that I will not make mistakes regarding the date and time.
And now this is really important step.
So please don't miss it.
Because otherwise even if you will give very detailed description of the formatting style you want to
get.
Your agent will struggle to send emails properly formatted, so let's close it for now.
And let's go back to our Gmail tool.
And here make sure to switch to the text instead of HTML as the email type.
Now, before we test our agent, we need to make sure that the name of our tools match the naming in
the prompt.
So our agent knows what tools to call.
So we have contacts and email tool.
So let's rename it.
This is the Gmail tool.
And confirm.
Here you have contacts.
Confirm and save.
Now let's go ahead and test our agent.
So open chat by clicking on this button and type something like.
Hi.
Can you please send an email to Damien that I need to reschedule our upcoming meeting, please.
And now let's see it in action.
So I'm going to send this message.
So as you can see the contacts tool gets triggered.
Then Gmail tools get triggered.
And as a response we have I have sent an email to Damien requesting to reschedule your upcoming meeting.
If you need any further assistance, feel free to ask.
Now let's check my inbox.
Yes, I got an email, so request to reschedule meeting there.
I hope this message finds you well.
I would like to discuss the possibility of rescheduling our upcoming meeting.
Please let me know your available times and I will do my best to accommodate.
Thank you for your understanding.
Best regards.
Damien.
Brilliant.
As you can see, this email was sent automatically with N810.
Doesn't look great, so let's remove it.
And we can simply do it by going to our agent.
Let's close the chat for now.
So let's open the Gmail Tools node.
And scroll down.
And here under options click on add option.
Then open Anytime Distribution.
And let's turn this off.
And now when we send the next email this attribution will be removed.
And we will have nicely formatted email.
So yes if you want to interact with your agents via apps like WhatsApp, telegram, slack and others
and ask it to send emails on your behalf to any contact details you store in the Google Sheet.
Go to the How to Set up Credentials lesson, and you can find a separate tutorials where I explain how
to connect different services to your agents.
So this is a perfect starter agent to get hands on with.
And the best part is it's fully customizable so you can build on top of it to write drafts, summarize
emails, delay them, route them to Notion or Slack, or even plug in into your CRM.
So in the next videos, we'll build something more advanced, but for now, try building this one.
Click by click, get familiar with the tools and have fun with it.
Thanks for your attention and see you in the next one.