# Build Powerful AI Agents with n8n (Step by Step Guide!)

## Метаданные

- **Канал:** Skill Leap AI
- **YouTube:** https://www.youtube.com/watch?v=Kg3VhofbCDg
- **Дата:** 20.03.2025
- **Длительность:** 29:08
- **Просмотры:** 16,662

## Описание

Self-host n8n with Hostinger VPS! Use code SKILL for 10% off: http://hostinger.com/skill10

If you want to automate tasks with AI, this video is for you!
I’ll show you how to build your own AI agent using a platform called n8n—no coding skills required.

What is n8n?
n8n is an open-source, AI-native workflow automation tool that lets you connect apps and services. You can create AI agents to automate various tasks. To explore some examples, check out the n8n template library.

What We’ll Build
In this tutorial, I’ll walk you through creating your first AI agent using a common task:
✅ The agent will fetch your emails, use ChatGPT to analyze them, write a reply, and save it to Gmail as a draft. All you have to do is review the draft and press send.
✅ If the email requires immediate attention, it will send a message to a team member on Slack.

## Содержание

### [0:00](https://www.youtube.com/watch?v=Kg3VhofbCDg) Segment 1 (00:00 - 05:00)

in this video I want to show you exactly how to create AI agents that could automate tasks for you we're going to use a platform called n8n this is going completely viral right now because it's going to give you some options you've never had before with other platforms and I'm going to go very step by step there's no coding skill required to follow along with me and by the end of the video you'll have a real clear idea how to build AI agents to automate your tasks okay so the platform is called n8n and one of the big reasons why it's going viral and is so popular is because it's open source you could actually download it and run it privately on your computer and this is a AI native workflow automation tool so you may have used other competitors to this there's zapier there's make. com but this one actually takes it to a whole new level it's really designed to be AI native first and just to give you some idea of what kind of workflows you could automate with this platform they have this page that I'll show you once we set up our account here this is going to give you ton of different examples over a thousand different work workflows that the community makes here and they make it available a lot of them are free some of them are paid here but for example if you wanted to automate things in sales you could click here and then you could see all kinds of different Automation and exactly what each one does so when you click on each one you'll see if it's free to use and you'll be able to add it to your account and you will have all these different steps already laid out for you and there's ton of different options like things in marketing with support with design finance a lot of ways that people are using AI but now you could create these agents to actually take care of tasks automatically for you okay so what we're going to build in this video is an AI agent that's going to do exactly this task right here it's going to fetch emails from Gmail we could have a dedicated Gmail email address for support for example then it's going to kicking the AI agent and the AI agent is going to send that message to open AI so this is going to use version of chat GPT here and that is going to have its own custom instructions to know how to deal with different messages then it's going to actually be able to reply to that message and create a draft for us so we'll have a draft sitting in Gmail rather than just automatically sending it out this will be much safer because you could then tweak it or just verify before you press send and then it's going to analyze the message and if the message requires an instant urgent answer it's going to ping someone in our slack Channel and the slack message will say hey reply to this because it's urgent the ones that this automat atically replies to will sit in draft you can automatically send it too so I prefer to have it sit on draft mode and manually do it right now just to make sure this automation is working exactly like I want now you have three different options for using n8n so let me just walk you through those and then we'll go ahead and build our agent here but the first one is just the n8n website I'll put all these links in the description below too so this is going to be an option that is hosted by this platform and this is not a local install so you have to pay for this monthly and the pricing starts at $20 a month this is very similar to zapier and make. com and it kind of has a similar monthly pricing too but they do charge you a little bit differently on the workflow and how they count workflows the second option is you could self-host it and I'll link this document below This is highly technical though so because this is open source you could technically download it and use it on your own computer using your own hardware and if you're more technical this is one way to go about it as well self-hosting on your computer now the third way you could do this is by using a VPS or virtual private server now this has the benefit of a local install but it's a whole lot less technical but you still get the privacy because it's again private and you get the security of a local install too now I specifically partner with hostinger for this video because they have the easiest way and a native way to install n8n in these virtual private server in just a few clicks so I'll show you that in a second and once you end up setting this up this way this is what my hostinger hosted version of it looks like and this is what the n8n website looks like so you could see it's pretty much the exact same thing one of them you're hosting yourself privately and the other benefit is actually based on price because that hosting your option starts around $6 a month instead of paying $20 a month so you're saving 70% on doing that now if you use a PPS or if you install locally the only difference is the authentication when you're tying into other apps so if you tie into Gmail it's going to give you a step-by-step guide on how to do that it's a little bit different than the one and8 and hosts on their website so I'll link this page in the description below this video this is the hosting plan that I actually chose here the second one and if you're doing this long term they do have a two-year option or you could choose one month or onee option over here obviously the longer the duration the better savings you're going to get here just check out through this process and

### [5:00](https://www.youtube.com/watch?v=Kg3VhofbCDg&t=300s) Segment 2 (05:00 - 10:00)

hosting here also gave me an additional coupon code so it will add to this discount that you get over here so if you type in skill right here and press apply you'll get an additional 10% discount I'll go ahead and Link hostinger in the description below this video as well as this discount code right here that you could apply during the check out process so you could host n8n on a virtual private server and once you log into your hosting air accounts VPS this is right here I'm going to just go ahead and create a new one I have one running right now you're going to click this first one right on top now it's going to choose a server location near you here and then right over here we're going to choose application and they have ton of different applications but we're going to look for n8n which is this one right here so we're going to select that now we need to create a root password because we need to log into this once we set it up on our private server now once you set it up you'll see all the resources you have access to over here and then if you press manage app it will take you to this page it'll probably show you the login screen here where you do have to type in your username and password to log in but then you get started here in the very first page of n8n and you could go ahead and start from scratch and then you'll press the plus sign here to build your first AI agent which I'll show you step by step and the link to the hosting air VPS option is in the description below if you want to take this route do this manually and install it locally there is a link to that document as well now for the rest of the video I'll just use the regular n8n webs side here okay this is the workflow we're going to create here from scratch and I also want to just show you another type of a workflow this is a little bit more complex so I'm not going to cover it in this video this is going to require much more in-depth knowledge about using n8n but this one uses these things called AI agents that could access other tools so this AI agent has for example access to open AI has access to this memory has access to slack and Gmail I'm going to for this video make it more linear once so let me go back to this one this is the one we're going to go ahead and create that kind of goes through it in a linear stepbystep order kind of achieves the same thing but the AI agents I'll probably cover in upcoming videos that fit inside of a workflow this is just an AI agent here that will do these things those other type of AI agents fit inside of an AI agent workflow so you got have multiple agents in the same workflow okay so to start a workflow all you have to do is press the plus sign up here and choose workflow and you could choose different projects you could create different projects for yourself and in this case I'm just going to put this inside of my personal project here okay here we're going to go ahead and build one from scratch so typically that's the very first step is you just create your workflow from here and put it inside of a project if you press these three dots over here you could also download a project and share that file with someone else and then they could import that file here so if you click this and you have a project someone else gives to you could import it that way I'll end up sharing this too in the description below this video once I build it out but it's important to understand how you gets created kind of from scratch that's why I want to do this step by step so we're going to press right here in the plus sign and it's going to give you an option to start your workflow they're always called triggers in these type of automation tools something has to trigger the sequence of events here now I'm going to go ahead and search here in the search bar for Gmail because receiving an email into an inbox is going to be the reason why this agent starts going to work so I'm going to go ahead and choose Gmail here and right here the trigger says on message received but there's ton of other things with all these apps that you could do so for example every time you get a message every time a message deleted is Mark as red you could create labels you could create drafts pretty much anything you could do inside of the Gmail app with the Gmail website you could do with these type of automations in this case my first trigger and you already knew that right out top message is received that's going to start my automation here now this page is going to require you to connect to whatever app that is starting your automation so in this case Gmail is starting my automation so I have to press this pencil icon here to make that connection to my Google accounts so if you're using the version on the n8n website you could use this signing with Google and sign in that way if you're self-hosting it you will have to follow along they usually give you a set of instructions on how to do it if you're using a self-hosted version to authenticate because if you're self-hosting the authentication process takes a few more steps that you'll see here on the right side okay so I connected my account here just off screen I give it the permission here that I needed to so it's all set I could close this right here so on this page really that's all you have to do is make sure it's connected to whatever email you want to pull in and it works pretty much with any email provider if you're making this kind of an agent everything else I'm going to leave the same I'm going to say fetch this step okay and

### [10:00](https://www.youtube.com/watch?v=Kg3VhofbCDg&t=600s) Segment 3 (10:00 - 15:00)

here's the email I just sent myself a test email here so I could show you all the information so this step is working so I could actually click on top right here this empty area and you could see I got a check mark over here if there's any kind of connection issues kind of get a error message or error icon over here that you'll have to fix and they do always have this ask and assistant option down here so if you do get stuck this is actually kind of helpful it will try to find the problem and solve it for you or tell you how to solve it so that is an option you have here on their website now we're going to actually have to use some AI here because we're going to need to read that message here with our agent so I'm going to press the plus sign here and we're going to look for open Ai and this is the open AI one we want just says open AI right on top and there's ton of different options with open AI you could do a whole lot of different types of automations like as you get used to it this is just my initial introduction to these so I'll keep it kind of simple but all we want to for this one is message a model so that's what I'm going to choose but you could also message an assistant you could build out an assistant right here create an assistant ton of different options generate audio this has access to things like dolly for generating images analyzing images I'm going to message a model over here and then we're going to get this box over here the first thing we need to do is press the plus sign and we need to give it API access to open AI API that is going to charge you that portion regardless of how you set this up even if this is privately installed because we need to pay open AI to use a version of chat GPT here for us to get some results I also got a popup here that gave me some free open aai credits here so if you get that popup right here if you're using their website gives you a little bit just to get started but I highly recommend you actually click over here and create a new credential and type in your API key over here okay to get an API key the open AI API key you go to platform. open. com click on dashboard right over here and over here you'll see API key on the left side and this is going to show you any API key you've set up and you want to create a secret key from here this is 100% independent from the chat GPT website so if you're paying for chat GPT that is not going to get you an API key you have to set that up on the platform website I'm going to go ahead and create a new key from here give it a name over here and create a key now you're only going to see this one time so copy it and store it somewhere safe and I'll just go and paste it over here and save okay I got the check mark here if you have any issues you do have to tie in a credit card under the billing section in open AI in order to be able to use that API here then you have models it says from a list of models over here and depending on your account you may have ton of different models available or you may just have a couple to choose from it depends on how often you use that and which of these has been unlocked so chat GPT you have 4. 5 let's see if I have access to 4. 5 so but that is going to be a little bit more costly I'm going to use actually Chachi pt4 on Mini because it's pretty good for especially what I'm using it for it doesn't need the best model available but I do want the cheapest model available that's still pretty good and that is 4 mini right now this is the part where we're going to talk to the AI so the first part right here message we want to change it right here to assistant and we're going to add a prompt here to tell the AI how to behave so this is called a system prompt and if you buil custom gpts for example this is going to look familiar to you I have one right over here you a helpful email response agent if the sender's message seems urgent draft the response via Gmail asking for more details or offering assistant ensure the response is clear professional and prompt now you could obviously take your time and get very detailed with these type of system instructions just make sure this is set to assistant right over here okay so that's all I had to do for this step and then I want to add a message and I want to set the second one to be the role of the user okay so this is where the actual prompt is going to go this is the system prompt on how this chatbot is going to behave this is the actual user prompt like when you're using chat GPT this is where your actual prompt goes and in this case I'm going to say here's the information of the email that needs to be triage so from to subject and body those are all the different parts of the email when it comes through and I need to put something here because otherwise every time a new email comes going to use the information from the previous email so that's when the difference right on top that says fixed or expression okay so there's kind of a difference here between the two fixed it means it never changes but expression it means every time a new email comes this needs to change so we need to put something here that knows well the from the two the subject is usually going to change every time I get a new email in order to pull in that data we already set up the Gmail step so we need to pull in right here just click right here

### [15:00](https://www.youtube.com/watch?v=Kg3VhofbCDg&t=900s) Segment 4 (15:00 - 20:00)

execute previous node and it's going to pull in all this information here on the left side and it's going to present it in three different ways that you look at that information so there's schema this is kind of what that looks like then there's table format this is probably the usual way that you'll look at things if you're looking at any type of data and then there's Json format which looks a little bit complicated but typically data on the web gets passed on in this type of Json format in this case we're going to use the schema format so you don't really have to know much about these it right now when you get more advanced with these automations you kind of need to know a little bit about how Json is structured but there are just different ways to present the same data three different ways actually I'm going to use schema for this one because it's really easy for this type of automation so if I look at the Gmail trigger right up here this is the input I could look for a from line so that's over here and I just have to grab this box right here and put it right in front of this from section it's added this little code right here so it's drag and drop then there's the two section so I could see is there a two yeah that's right over here bring that and put that over here and you could see I'm under the Expressions Now by default it switches you from fix to Expressions when you grab these it says the subject line we'll look for a subject line over here building question is the subject line We'll add that over here and then we'll go down to the body of the email and that's usually the snippet right here the snippet of the email will have to be added over here like this okay so now we have pretty much everything that we're asking the chatbot to analyze right so system instructions here on how to analyze something how to behave the tone and things like that is the assistance role the user role is going to be the actual thing that we're going to go ahead and put in here so like if I was using chat GPT I would just type in here's the information that needs to be triaged and then copy and paste all this into the email and it will give me a reply okay and that's all we have to do here everything else is the same over here and I just have to press test this step right on top and here's the content thank you for reaching out to us I could certainly assist with that switching your accounts from monthly to yearly that was the actual question they say can I switch from monthly to yearly could you please provide me the email associated with your accounts maybe they used a different email so this is actually a good question because sometimes people use a different email to send a message than they have on their accounts so it's going to be saved now as a draft that's the next step we're going to set up over here but the assistant is working based on the system instruction I give okay so we'll click off top right over here so we got our trigger the email came in open AI went to work the instructions worked and it has an output so what do we do with that message now well we need to add one more step over here in order to deal with that message and that's going to be Gmail again so we're going to choose Gmail but this time we're going to go ahead and create a reply now if you go down here you'll see these options for creating a draft so that's what I want to choose because I usually still to this day don't like the AI to reply automatically for me you could just set that up as an auto reply inside of Gmail for example right but in order to do it this way you take advantage of the open AI engine it's based on the context of the email right but you can send a message too so if you do want to reply to an email that is an option I highly recommend you do the draft till you really fine-tune this and get it exactly like you want check bunch of responses a lot of times I like to put the finishing touches to these drafts but it takes care of 80% of the work already okay so how is it going to reply credentials are the same it's the same Gmail account so I don't have to add it again but if you were to add it this is the pencil icon in order to add that the resource is going to be set to draft so we don't have to change anything and all this is going to be the same email type is still going to be text I don't want HTML and the message here we do need to change over here so I'm going to change this to expression again and we want the message that we got so that's the content right here so we need to grab and put the content over here right if you were set to the fixed it's going to send the message every time the same exact way as you put in over here but if you do expression is going to use the message the content from this box over here instead and over here I also like to add an option over here which is thread ID so we'll choose this option that is one of the things that gets pulled in directly from Gmail to kind of tell which email this is so if you look down here you'll see thread ID right here this is from the Gmail trigger so I'm going to grab this and I'm going to put this into this box over here and it's going to automatically change it to expression even if you're on this fix tab it'll change it over here and I did not add a subject so we'll go ahead and look for our subject here inside of our email and we're going to go ahead and drop this and set that as an expression over here too okay so subject message thread ID those are the things you need here it's going to create a draft we're going to test the step here we should see the output here on the right side now I'm going to actually open up Gmail to make sure we did get that okay

### [20:00](https://www.youtube.com/watch?v=Kg3VhofbCDg&t=1200s) Segment 5 (20:00 - 25:00)

and this is exactly what it looks like without me doing any editing inside of Gmail so the message came in high skill leap I like to switch my account for monthly to yearly can you help me with that John and then this is my reply and it says subject reply to billing question so you got that right hi John it picked up on the name thank you for reaching out to us I can certainly assist you with that could you provide me the email address associated with that once I have that I could process your request more efficiently thanks for your reply even added all this information here including my full name best regards it's literally ready to go right I could just press send so this automation as long as it's turned on and running every email that comes to this inbox so you want to dedicate it typically to like a support inbox or billing inbox and then if I feel like it needs some help I'll just manually do some revisions here if I feel like it's ready to send I'll send it or if I feel like it just doesn't need a reply well I'll just press the garbage can here and delete this draft this is why I like this draft mode once a day couple times a day I could have all these drafts sitting here reply to emails all done for me now let's take it a step further now the next thing I want to add here is let's assume that someone is saying hey maybe they will double build on accident something happened with our billing and they were double built for something and they want to refund and the message will seem more urgent that way so what I could do is well this is going to sit in draft maybe I don't want to check that like every 10 minutes right I want to check that a couple of times a day and send out those drafts well I'm going to start another chain here where it's going to use open AI again to analyze the message and send a slack message to my team on a channel that is urgent right so they respond immediately within 60 second or within a couple minutes to that email so we'll choose open AI for that one more time we'll choose this option and again we're going to message a model so same thing as we did before we're still connected to our open AI accounts I'm going to choose 40 mini again on this one and this time we just need a text as a user role we don't need that assistant role unless we want to give them more specific instructions and all I wrote is alert our team via slack about the severity of the content of the email we received without given context or pretext just return the message text okay and I press test actually too early because we need to give it all the information that we had in the from to subject and the body of the email too so I'm going to type those back in and we do need to drag and drop those things into these fields again so we want to go down to the Gmail trigger and pull those same type of things in here and now I'm going to go ahead and test that step over here and here it says we've received a billing question and that they need to switch please address this promptly and it's going to go to slack which we need to add in the very next step and if you want to really dial this in you could actually add the assistant right so you could choose the assistant option and give this bot a system instruction only reply to messages that sound like these or have these key words or sound urgent and then you define what urgent means so you could really tweak this right here in this case we don't get many of these so actually want pretty much all of them to go to slack but if you wanted to always add an assistant first then add the actual user prompt here and then use these system prompts to dial that in as much as you want to like we did with the very first step okay so everything has a check mark and our last step is going to be slack so we're going to type in slack and by the way they have ton of different options I'm just showing you a few pretty much this works for just about any app you could imagine so if you use a different email or different type of messaging app I'm sure they have like a Microsoft one yeah you could do Microsoft teams but in this case we use slack so I'm going to choose slack for us okay I just search for send a message is one of our options inside of slack this is going to bring up slack credential you have to add that again so I'm going to add a new credential here and tie this to my slack I'll press allow here okay successful exit this okay I clicked away we have that set up so we're going to go ahead and send a message and we're going to send a message to a Channel or you could send it to a user so if you want to it'll give you the different users you have here I'll send it to myself here and then under the message here I'm going to change this again to the expression so we could choose the open AI step which right here was the content this is the message we want not any of the previous messages we want the last step here so I'm going to drag and drop the content over here just click away that's all we need to do there and I'm going to go ahead and press test the step right on top over here this is the whole step so we're going to get a message inside of slack this is going to be a private message but as I mentioned you could also send this to a channel if you have multiple people that need to see this message here and it looks like you send us the message here this is just my actual slack account it actually added a little warning imagy so I could get to this

### [25:00](https://www.youtube.com/watch?v=Kg3VhofbCDg&t=1500s) Segment 6 (25:00 - 29:00)

right away now once you finished setting up any workflow and you've tested it here with the test workflow option in all these steps we could actually turn it on because up to this point it's going to be set to inactive here so if I go ahead and click this and it says workflow activated it will check Gmail for events and Trigger all these different steps that we have set up over here so as long as this is activated it's going to go to work anytime you want to deactivate it you could go ahead and click this and each step could also be deactivated this way so if I want to turn off the slack option I could turn it off from here too and obviously these AI steps are the real power of these right because these are just regular automation tools before AI came out but now with AI it has exact context it could read and right based on what's coming in so it's going to completely change your workflow the automation is a whole lot more powerful you could build it out from here and as I mentioned in the beginning of the video oh by the way make sure you save these right on top right here make sure you press save but now if I go to my other workflow I was building out on this account you can see you could get a lot more complex with these AI agents having access to these tools so when we were building out these agents you'll see this little plus sign right here so if you click this it gives these AI agents access to different things they're capable of doing as one of the steps over here so it makes it a whole lot more powerful this gets a little more complicated because you really have to understand how these Json files are formatted it's pretty straightforward once you get to know it because it's a different way to represent data but it you know it is technically code here so I know a lot of people that are not technical they don't want to make it that complicated but as I showed you in the very first step you could pretty much do these in a very linear way without really looking at Json or any type of code is kind of what's drag and dropped I didn't type a single line of Json or JavaScript or any type of code and this automation is ready to go so this is going to keep running if you wanted to stop running you could stop any of these steps here so if I want to go back in the beginning and turn it off as long as this is deactivated here none of these other things are going to work this is going to deactivate that whole flow over here or you could let's say you don't want slack messages just turn that off and the previous steps will work over here as well and as I mentioned in the beginning of the video there is a tab right here for templates so if you go to this tab right here you'll see all kinds of different workflow automation templates so what you could do is I'll just show you as an example I'll pick on marketing here and let's say this one aied social content generator you could click on it and you could press use this workflow and I have the cloud one this is from n88 I have the hostinger one so depending on where I want to put it I'll choose that import into the template and it takes a second here it's going to ask you to connect any type of account that is required on that step here I'm going to skip that and here is your whole workflow I'm just going to zoom into to it over here and a lot of these actually kind of come with these type of notes so you see exactly how it's working you can see it gets pretty elaborate over here now if you want to just use the one IE build so you have it as a template and you kind of build your own underneath it so you can kind of refer back to the top one all you have to do is press these three dots in a new workflow import from a file just double click on the Json file that I have and you'll get that exact same thing that we built in this video obviously none of these are going to be connected conect it to Gmail or open AI you need the API keys and these account credentials here for it to work but all the different things I added including these kind of text again build on your own text here to make sure it works with your flow they're always all included in a type of workflow that you create now I've been using more and more of these automation tools especially Inn so I'll be making more videos I'm actually making an entirely dedicated course to showing all kinds of practical workflows to just automate a lot of things that you do daytoday so I'll make sure I'll link that in the description when it's ready but I'll be making free videos here on YouTube coming up very soon as well thanks again for watching let me know if you have any questions and I will catch you on the next video

---
*Источник: https://ekstraktznaniy.ru/video/12470*