Building AI Agents in n8n Somehow Got Easier (as a beginner)

Dr. Violet Howard shows how to build AI agents in n8n using ChatGPT-4o Mini, connecting tools like Gmail, Google Calendar, Airtable, and Slack. The new "let the model define this parameter" button lets the LLM automatically extract fields from natural language, so you can create functional agents in minutes without coding.
Chapters
N8N has done it again. They've somehow found a way to make building AI agents even easier. So whether you've been building agents for a while now, or this is going to be your first time taking a stab at it, what we're going to look at today is how you can get one spun up in minutes and completely understand what's going on and start to add more tools and more functionality super easily. So don't want to waste any time here. We're already in N8N. I'm going to hit tab, type in AI agent, and we're going to grab one and bring it into our workflow. So the first thing to recognize is that we're chatting with our agent in N8N. That's why there's a chat trigger right here. And if we click on this red chat bubble at the bottom, we can see this is where we actually talk to the agent. Next, what we wanna do is add a brain for the agent. So I'm gonna click on the chat model, the plus button right here, click on OpenAI chat model, and I've already got my credentials connected, so I'm good to go with ChatGPT-4o Mini as the brain for our agent. And so now we're already able to talk to it. I can come in here and I can say, "Hello," and it'll respond, "Hey, how's it going today?" And then we'll just quickly take a look at what actually goes on in the agent. All we're getting is the prompt user message. So every time that we talk to the agent, down here in this little window. The agent right here, as you can see, because we're searching for a prompt within the connected chat trigger node, this is what it's getting, which is we just said hello. And then we can see on the right, the output, which is what it said back to us, was, hello, how can I assist you today? Now that we have our agent up and running, all we have to do is add tools. And this is where it gets super, super easy. So I'm gonna click on the plus under tool. And then on the right, we have all these nodes as tool options. And I made a video about this a week or so ago talking about how easy it is to connect these things. Using the fromAI function. But what I'm going to show you guys today is even easier than using fromAI. So when you think of an AI agent and you start to think about functionality, the first thing you may think of is being able to send emails. So I'm going to grab a Gmail tool right here, if I can type it correctly. We're going to grab Gmail, and then we can see what we're going to do is set up our resource as a message, and we're going to be sending a message. By the way, if this is your first time, you're going to have to connect your Gmail using a credential. I'll tag a video right up here where I talk about how to do that. Anyways, when you want to send an email, you have to basically fill out 3 things. Who is this going to? What's going to be the subject? And then what is going to be the actual body content message of the email? Also the email type, which we're going to change in this case from HTML to text. Anyways, in that previous video when I talked about fromAI, we'd have to go into the to parameter, click on expression, type in 2 curly braces, grab fromAI, and then we'd have to define a key, and then we'd have to describe that key so that the model knows what it's looking for to fill in this parameter. And if that doesn't make sense to you yet, don't worry, it will, but I'm just going to keep breaking this down real quick. So now we don't have to do from AI anymore. We can simply just click on this button over here that says let the model define this parameter. So all I have to do is click on this button, click on this button, and click on this button. And now when we're talking to the agent, it's going to use its brain, its large language model, to understand who to send it to, what to make the subject, and then what to fill in as the message. You can see that we also have the ability to add a description to one of these keys, which I'll show an example of later. But this just says explaining to the LLM how it should generate this value. A good specific description allows the LLM to produce expected results much more often. Anyways, I just changed the name of this node to send email so that the agent understands what it does. And what I'm gonna show you guys is that we have no system message in here. Typically the system message is like the instructions for the agent, and in this case, all we're saying is the default, you're a helpful assistant. And the reason I'm not changing this is just to show you guys how intelligent these agents are when you start to add tools. Like I said, this took me a minute and it's already gonna be able to send emails for us intelligently. So let's get in here and try out a prompt. So as you can see, I said, send an email to Nate Hurk asking him if he wants to go to a baseball game this weekend. We'll send that off. We'll see the agent think about it using its brain. And now it's already sent that email before I could even finish reading that off. So it said the email has been sent to Nate asking if he wants to go to a baseball game this weekend. We can click into this node to understand what just happened. So because I told you guys that it's using its brain to figure out the to, the subject, and the message, you can see in the top left, it filled out these parameters with the email, with a subject, and then also with an actual body message. So let's hop into Gmail and take a look at this. So here's the email. We can see the subject is Baseball Game This Weekend, and the message says, hey Nate, hope you're doing well. I was wondering if you want to go to a baseball game this weekend. Let me know if you're interested. Best, your name. So obviously we don't want the email to be signing off like this every time, and we want to also get rid of this automatic message. So back in n8n, all I'm gonna do is add a description to this message field, and I'm gonna say sign off emails as Nate from ABC Corp. So that should take care of the actual sign-off. And then I'm going to add an option down here, click on Append N8N Attribution, and then flick this off. Now all I'm going to do is come down here to the chat window, hit Repost Message, and it's going to do the exact same thing. But this time we'll see that the email doesn't sign off with a placeholder and the message is gone. So it looks like it already took care of that. I'm back in my email now. We have the message: Baseball game this weekend, hope you're doing well. I wanted to see if you're interested in going to a baseball game, and then you can see best Nate from ABC Corp, and then there's no, um, this message was automatically sent by N8N. So just to put it into perspective of what's going on behind the scenes of that send email tool, all we're doing is we're asking ChatGPT-4o, because that's the chat model we chose, to extract the certain parameters out of our query. So let's take a look at this example. Extract the event start time, end time, attendees, and title. I'll send this off. It says, um, create an hour-long meeting for 4:17 PM to go over the corporate retreat with Kelly and Ryan. So here's the details that the AI model was able to extract: event title, start time, end time, and attendees. So this is all that's going on within those tools, and it's just filling in the details in the right spot in order to make that request to Calendar, email, whatever you're interacting with. So let's hop back into N8N and do an example of creating a calendar event just like this. Real quick, just wanted to say, if you're looking for a more hands-on approach to learning N8N and building AI agents, then definitely check out the paid community. Link for that's down in the description. We've got a great community of members who are dedicated to learning N8N. We've also got a great classroom section with deep dive topics like building agents, vector databases, APIs, HTTP requests, and then I'm doing step-by-step builds of all the YouTube videos that I've shown on my channel. We've also got 5 live calls per week, but anyways, let's get back to the video. All right, so now we're gonna do a calendar example. So I'm gonna move this one over, hit plus under tool, and I'm just gonna search for calendar, and we're gonna be creating a calendar event in our Google Calendar. So clicked into the tool, All we have to do is create an event, so that's already set up. We have to choose a calendar to actually put this on, so I'm just gonna choose my emails calendar. And then once again, all we have to do is click this button, click this button, so now the model's automatically gonna be determining the start and end times. And then we can add properties down here. So we wanna add attendees, and we also want to add a summary, which is just gonna be the title of the event. And then once again, we just have to click that button and click that button. And now the last step here is we just wanna name the node so the agent knows how to use it, and this is just gonna be called create event. And now in the chat window, what I want to say is create an hour-long meeting for 4:17 PM tomorrow to go over the corporate retreat with Kelly and Ryan, just like we did in that ChatGPT example, except for right now the agent doesn't know what today is, so it doesn't know what tomorrow is. So real quick, I'm going to show you guys how we can do that and give the agent access to the current date and time. We're going to do this within the system message. So I'm going to change this to an expression. I'm going to open up this up full screen so we can see, and I'm just going to say, here is the current date time. And then we're gonna do two curly braces. I'm gonna type dollar sign now, and then it's gonna go green, meaning it's an expression. On the right, you can see that we actually have the date and time. And if we just want to clean it up so it looks better for us, I'm gonna do.format, and then we have a nice clean date on the right. Anyways, now we're gonna send this off, and we're gonna see that it's gonna be able to use its Create Event tool to actually make that event for us. It's gonna fill in those parameters like start time, end time, summary, and who it's inviting. And as you can see, it just responded to us with the meeting details and and we can also click on that link. And what's really cool is that it also sent an email notification to both Kelly and Ryan letting them know of this meeting, and we didn't even ask it to do so. So first, looking at my calendar, here's today. If we go to tomorrow, we can see that we have our Corporate Retreat Discussion from 4:17 to 5:17. And then looking in the emails, we can see that we sent one to Kelly with the information for the meeting for tomorrow, and then it also sent one to Ryan. And obviously, these are fake emails, so it didn't really get sent, but you get the point. And we can see exactly what happened in here. So within the Create Event tool, we can see it created a start time, end time, attendees, and also a summary. And then if we click into the send email tool, we can see that there were 2 runs. So we have run 1 out of 2 and run 2 out of 2. And on the left-hand side, they change. So the first run, if we go to this, was sending to Kelly, and the second run was sending to Ryan. Okay, so that was cool and all, and we spun that up in a few minutes. But what if we actually want to be able to send to real contacts in a database? Let's connect that up. So here I am in Airtable. We can see that we have a contacts base, contact table, and we have these different contacts here. So what I'm gonna do now is go back into N8N. I'm gonna click on Add Tool, and I'm just gonna be adding an Airtable tool because that's where my contact database is stored. And I'm just gonna click on Search. I'm gonna choose the base and the table that I'm looking for, which is called Contacts, and I'm just gonna say Return All. And we're gonna change this node to Get Contacts. And then all I wanna do here is quickly just let the agent know that it needs to get contact information before it sends emails or creates events. So all I said in here was before creating events or sending emails, get contact information from the Get Contact tool. So this should work and we should be able to do that exact same thing, but now it's going to be looking at contact information. So now I'm saying create a meeting for tonight at 7 PM with Michael Scott. I'm gonna fire that off. As you can see, it just went and got Michael Scott's information from the Contact tool, and now it created the event. So we have the event created. Here's a little summary. So as you can see, it just responded. It said that it was able to do that for us. But if we go into Calendar, even though we asked it to create this at 7 PM, it created it at 5 PM because it doesn't really know timezone right now. And that only is because it's using local time, as you can see. So the way we need to fix this is we go into the system prompt and we just have to get rid of this.format, because when we.format it, it gets rid of the time. But now over here we have the actual time of where I am right now. So all I'm gonna do is send this off once again, and we're gonna see it's going to do the exact same process, but now it's gonna create that calendar event at the correct time. So it's finishing up right now. We'll see it post a message down in this window. There we go, we have our event created. And now if I go back into the calendar, we can see that we have an event created for 7:00 PM, which is correct. But you guys are also always asking for Outlook integrations, so I just wanted to show you it's the exact same thing. We have Outlook Send Email, Outlook Create Event, and all we have to do is the exact same thing where we click on these 3 buttons. Now the To, the Subject, and the Message are automatically being filled in by the model, as well as the title of the event, start time of the event, and the end of the event. So I'm going to send in this other query now that's saying create a meeting for tonight at 7 PM with Michael Scott and send him an email to confirm. And we should see it hitting both the Send Email tool as well as the Create Event tool. There you There we go. And now let's go take a look in our Outlook. So here we are in Outlook. You can see we have our meeting at 7:00 PM with Michael Scott. And then if we go into our sent messages, we have to michael@dunhammifflin.com. Hi Michael, this is to confirm our meeting scheduled for tonight at 7:00 PM. But one difference I wanna point out with Outlook and Google Calendar integration is that we don't have the ability to add attendees natively in this node to a calendar event. We would just have to access an HTTP request where we're accessing Outlook's API in order to actually add people to these events. but unfortunately that's not what we're talking about today in this video. So let's keep going. So if you're still not impressed with how intelligent this agent's being already with a 4L mini model, let's go in here and grab a Slack tool. So what we're gonna do is we're gonna name this one Send Slack Message. We are going to choose the channel we want to send in, and then we're going to let the AI decide the channel as well as let the AI decide the actual text of the message. And so in Slack, there's multiple channels. We have All Up at AI, Social, and YouTube Testing. and what's gonna happen is we're gonna let the AI decide what channel to send in based on our message. So I'm saying send a Slack message to Social reminding everyone to log off early today. So we should see this one hitting the Send Slack Message tool, as it did. There we go, the message has been sent. Let's go into Slack, click into the Social channel, and we see, hey everyone, just a quick reminder to log off early today. Enjoy your evening. But now what about a channel like All Up at AI where there's spaces in there and then they have to be filled in by hyphens? What I'm saying here is send a Slack message to the All Up at AI channel asking if the Wi-Fi's down for anyone else. It's gonna hit the Slack message tool. It's already been sent. Let's head over to Slack and we'll see within Uppit AI channel, we have, is the Wi-Fi down for anyone else? So back in N8N, what's happening in here is the model is able to figure out the channel. As you can see, it populated it with all-upit-ai. And it's because it knows that a channel in Slack, if there's spaces, it's gonna have to have hyphens in there. But let's say you have 10 or 15 channels and you don't want your agent to get confused. This is a perfect use case of when you would start to add descriptions in here. And you could say, you know, here are all 15 Slack channels I have, and you could list them out, and then it's knowing it has to pick from one of these 15, and then it's always going to be sort of populated correctly. So really, this was just a simple demonstration to show you how easy it is to get something like this spun up. You know, we could, we could easily add an Airtable tool. We could want to add a record, so we'll do Create Record within our contact base. So within our contact base, we have name, email, and phone number. I can just click on these 3 buttons, and now it's going to intelligently be able to understand how to add a contact using this tool. So I'm saying, add John to my contacts. Here's his number. Here's his email. The number isn't formatted correctly, as you can see, and it has been added to the contact database. We come in here, we can see we have John, john@example.com with his phone number already structured. So as you just saw live, that took me probably 10 seconds to add this tool and it's already working. And just a reminder, we have nothing in the prompt besides, you know, just telling it to get contact information before sending emails and then also the current time and date. So that's gonna be it for this one. Just wanted to make a real quick video about how easy it is to spin this stuff up. The best way to learn how to do this is just to get in there and play around with things, see why they're breaking, understand how to fix them, and, you know, just do by learning, really. So appreciate you guys making it to the end of this one. If you learned something new, if you enjoyed, please give it a like. Definitely helps me out a lot. And I will see you guys in the next one. Thanks, everyone.










