Step-by-Step Tutorial: Build A.I. Agents with n8n (NO CODE!!)
66.49k views5262 WordsCopy TextShare
AI Workshop
🚨 Join my Skool community: https://www.skool.com/aiworkshop/about
Template for this workflow: h...
Video Transcript:
in this video we're going to build a really cool AI agent that will have the ability to pull data from the Internet or call in a separate workflow that will have an A API attached to it so we're going to build all of this step by step and I'm going to show you how powerful nadn is when it comes to uh building customized AI agents and how you can connect several different tools and obviously you can attach a large language model like um open AI in this case or anthropic or others as well I'm going to explain what nadn is and why this is such a cool tool to use when it comes to customize workflows and specifically building customized AI agents because it gives you the ability to connect different tools and therefore make the AI agent extremely powerful in in our scenario in this example that I'm going to walk through this AI agent will independently make a decision based on the question that you're asking it either to call the Wikipedia tool to grab data from the Internet or call this separate nadn workflow that we're going to build that will be connected to a third-party API app so this will be a really comprehensive tutorial on how to utilize n's different tools and different customizability options to be able to build a really powerful AI agent all right let's Jump Right In All right so a quick introduction for nadn um if you're not familiar with nadn nadn is a workflow automation tool but it's extremely powerful in my opinion it's way better than make. com voice FL or all these other automation tools that are out there in the market and specifically when it comes to building AI agents so the reason why I really like an and again I've been building these Automation workflows and agents for a while now and the reason why I landed on nadn and why I think that this is such a good tool is because it gives you really a lot of option when it comes to customizing and being able to provide different tools and attach different apps to be able to really customize your AI agent another great Advantage for nadn is that you can actually self-host this on your local computer again this is going to be more of a introductory tool I don't want to go too much deep into that but on the next videos I'll be able to build a more complex automation tool or more complex AI agents where then I'll be able to host or self-host nadn on my own local computer where then you basically will have the ability to own all of your data um and therefore be at ease when it comes to customizing and uploading your own data all right so with that being said um so you can create an um free n in account um and again you can do a cloud account so that's going to be the free option you don't have to worry about hosting self- hosting it for now we're just going to go ahead and use their cloud account but you can as soon as you log into your account you'll come into um your workflow and this is basically the starting point so I'm just going to get rid of this um so if you're familiar with a tool like make. com it's kind of similar to that but it's again like I said there's more custom customizability option here all right so first the first node we're going to add is uh a trigger and again a trigger could be something whether uh it's a manual trigger in this case obviously I added a manual Tri Tri trigger but it could be a chat it could be an email so you can have different uh trigger options available and again in the future videos I'll create other AI agents that will have a trigger of an email or a chat or a slack message uh but for this one we're just going to do a u manual when clicking test the workflow so this basically as manual as it gets all right so let's go ahead and click on this add node button right here um so what we're going to do is is actually go to Advanced AI again we'll come back in other videos and take a look at these other options that you can add obviously there's a lot of um different options when it comes to adding nodes but for this one we're going to click on Advance Ai and when you click on Advance AI this gives you all of the different options you have when it comes to the AI tools that you can attach but we're going to click on AI agent and as soon as you click on AI agent it's going to pull up um the setting and the parameter we don't have to worry about the settings for now but parameters this is where will be able to um attach actually different tools to this AI agent so for now let's just leave this as it is we need to attach a uh language model to this so I'm going to get rid of this this node because automatically pulls that up so the first thing we need to do is add a chat model so if you just click on this plus button or you just drag it so this is all of the language models that are available for NN and they have this integration so they have obviously the the most popular one they have the entropic you know your grock and um Llama Or Lama the openi chat model obviously um I I have an account with open AI so I'm going to choose this but it depends on your choice you can definitely um uh choose whatever you want all right so once you do that then it's going to ask you for your credential so you can connect to your API account again you have to have an open AI API account your keys that you need to grab from there so that way you can add to your credentials so I've already have my account here but if you don't you just click on create new credentials and again you just have to go to your API account and be able to grab your API keys or you can create a new API key the organization ID is optional but you have to have your API key all right so once you do that you're going to come back and this is going to get um your account is going to get connected here so the next obviously you got to choose your model again I'm going to use gp4 and that's pretty much it so now you have connected your uh open AI chat model to this and as you can see this this attach is complete so another thing I'm going to add here is a memory if you just click on this so you know not to get into too much details into this but this just basically gives NAD the the ability to store your um data into your windows memory buffer so that way it can refer to your previous chats when you build this AI agent so we're just going to click on the Windows buffer again you don't have to do much you don't have to add any credentials or anything like that you just got to attach it all right so the memory is done so this is what makes nadn really powerful the ability to add these different tools so they have a lot of tools available here uh so the first thing we going to add is a calculator and again a calculator just gives the this AI chat model the ability to uh run numbers so if you're asking it a a question um that requires mathematical operations then it will have uh the ability to do that with this calculator I mean again we don't have to worry about it too much all right so for the tools I'm just going to keep it separate and you can attach multiple tools here all right so another tool we're going to add is the Wikipedia tool again just if you just click on this PL plus button The Tool uh will open up again uh and as you can see at the bottom right here it says Wikipedia so what this tool does it gives your agent the option uh or the ability to to have a conversation with you and have access to the knowledge resource of Wikipedia okay so now that our AI agent has the um knowledge base from Wikipedia it means that we can cat with it right so right now as you can see in the bottom here it just says test flow um because right now this is a manual trigger but let's go ahead and get rid of this and we want to be able to add that chat trigger here so I'm going to go ahead and click on this um add first step and again you can click on that top right corner there as well and as you can see on the uh on the list here you have that trigger manually option on an app event on schedule on a web H hope call uh but as in the bottom you can see here it says on chat message so we're going to click on on that all right so oops so let's grab this over here and bring it here all right and then let's go ahead and connect this there you go so you just got to do is you just got to drag that and connect it to and you can always delete it from here this connection um all right so now that that's connected um so now again you don't have to do anything here this is just a trigger and as you can see at the bottom here little chat box appears which means now you have the ability to chat with this AI tool um so let's go ahead and actually do that first of all another thing is I always have the habit of saving so I'm just going to click on Save there that way you don't use lose your progress all right so now let's go ahead and test this out so I'm going to come here and chat with this so I'm going to say what is the capital of Spain for example right so it should be able to have access to that data via that Wikipedia tool that we that we that we gave it and there you go the capital of Spain is Madrid and on the bottom you can see the log for this message it means that it uh the AI agent use the windows buffery member again this is just to save so that way you can refer to it um um later on uh and it used the open AI chat model and it used the Wikipedia tool as you can see right here to search for that and if we get out of this you can see now that the AI agent used the following tools by looking at this um with the little green markings here all right all right cool now we're going to add another workflow to this and what you're going to do is click on this plus button again right here it says called NN workflow tools what this means is that this gives you the ability to call other workflows that you can create in NN and attach it to that AI agent and the way you do that is right here on the workflow ID you can attach the ID of a separate workflow that you've created so therefore um this AI agent will have access to that so let's go ahead and actually do that so let's go ahead and create a new workflow that grabs weather data using a thirdparty API okay so let's back out of this Fel and as you can see right now there's this little error message just because there is no workflow connected to this so in order to create a new workflow again you can just go back to your homepage and just add another uh workflow here so I'm just going to go ahead and do that all right so now I'm here with my new workflow so what we're going to do is leave this um the test workflow as manual trigger and click on the plus button here and here we're going to grab this data transformation so when you click this gives you the option to manipulate uh filter or convert different data that's coming in so we're going to click on this and we're going to select this um edit field again this is kind of the popular ones but you can see at the bottom they have all these different uh data transformation tools that you can attach and again the following videos I'll kind of go through some of these because they're very powerful but for now we just click on this edit field all right so we're going to go ahead and change the name here so I'm going to change this to query if I can type oops all right so click on rename we're going to leave the mode as manual mapping um so Json is if you're you know familiar with code you can actually add the mode via Json as well but for now we're just going to leave this as manual mapping so for the fields to set so this is where you can um grab uh a field from a previous input and in this case I obiously ours is a manual trigger so if you just execute the previous node it just says when clicking test workflow because we don't have anything added to this but obviously if you have a previous node that's attached to it and is doing something you'll be able to have access to that as well all right so now what we need to do is just manually add a field okay so the name you can name this again same thing I'm going to name it Cory you can leave it as string because this is just going to be um a value that we're going to provide to our API endpoint in the next note that we're going to add all right so for the value now we're going to add um a name of the city again this is just so we can test our workflow so for now I'm just going to say San Francisco that's my city so I'm just going to put that here all right and that's pretty much it so now let's go ahead and test this step and by testing this step you you want to make sure that uh the output is what you're expecting and in this case we want the output to be just be San Francisco and as you can see right here the quy it's the name of the field and it's outputting San Francisco based on what be put in the bottom here all right so let's back out of that and as you can see it's successful uh if there was any kind of error this green box won't appear it it's just going to show the error there okay so now we need to add a node that will have access to weather data and we're going to do this by grabbing the weather API from a third party so the way we do that is just again same thing add a node I'm going to search weather here and I'm going to use this open weather map uh tool that they have and again this is uh from a third party so it just you gives you the option as far as actions you can return current data or return weather data for the next 5 days so let's just click on the return current weather data because we want to be able to have you know the current data from our Cy which is San Francisco all right so once you click on that this will open up your credentials again to connect with so it's the same kind of concept you have to go to your open weather map um account on their website and if you click on docs here this also opens up um kind of a guide on how to grab your credentials so go ahead and do that once you do that again same thing you're just going to come here and uh add your access token which is your API key then at the bottom here you have your operation and you're just going to say current weather 5day for uh forecast I'm just going to leave it with current weather uh the format you can choose as metric or imperial you know obviously Imperial is the Fahrenheit metric Celsius I'm just going to leave it as it is for now um location setting so this is going to be the city name that's going to going to be coming in so the city this is where um we'll be able to grab the city and in this particular this field could be or this parameter could be coming in from our previous node and in our case in our previous node we added San Francisco as our query so that's exactly what we're going to do and then as you can see on the left hand side on input you have a query that's coming in and it shows San Frisco right so there's the schema there's a table View and there's a Json view right so if you're you know amiliar with code you can uh work with Json and that also is very helpful um because it gives you exactly the code version of it but you can just stay in schema because this if you're not familiar with code or you're not good at coding you just grab basically uh this schema from here so what I'm going to do is just basically grab this and bring it over here to the city and as you can see this show this uh converts it into um a Json field which again it's a JavaScript field so all right so that that's pretty much we're done with this point we're just going to leave the language is English so let's go ahead and test this step out and again I'm going to click on test step and there you go so because my um API is connected one thing I want to point out that when you create your open weather map API account it does take about 5 to 6 minutes for your API to key to get operation so just once you create that account just be on the lookout there because if you click on this it just going to give you an error so once you create your account your API key just wait a couple of minutes before you test this Stu out all right so now let's take a look at the output here as you can see it gives us the longitude latitude and again all this data is coming into to us via our open weather map account or our open Weather API there uh it gives you the temperature what it feels like pressure humidity all of this right in a in a table format because you output you also have the option to have the output in table format in Json or in a schema view but the table view this also gives you the data in a really well structured way and as you can see the ID and the name is the San Francisco because this is coming in from our query here all right so that looks good so now let's go ahead and add another field to this where we want to convert this data that's coming in from this API in this format and convert it into simple text so that way we can attach it to our um to our AI agent here so that way it can absorb that in plain text so in order to do that we're going to go ahead and add another uh note to this and that is going to be again our open um open AI chat model so again we're going to use our large language model to be able to um convert this table format output that we're getting from our open weather map uh API into plain text so I'm going to go ahead and search for open AI click on open Ai and you have all these different options you have assistant actions you have text actions image actions audio actions so it gives you a lot more comprehensive ways to use this um open AI tool but I'm going to go ahead and click on message a model all right so same thing your parameters the credentials is going to be your account um the resource we're going to leave it as text operation but but you do have option uh to um have image audio file and Etc all right the operation we're going to leave as message a model um you can have custom API call or you can classify the text violation all right so now for the model same thing we're going to choose from the list I'm going to use gp4 all right so for the message here let me give myself some more room here so this is where we're going to put our prompt right so let me go ahead and put my prompt here so you don't have to see me typing okay so I just basically said uh please convert the input from open weather map into plain English with a friendly tone to make it prettier use relevant emojis again you can work with the prompt and try to change it based on the result you get to make sure that it's exactly the way you want it but for now this is good for this example right and the data so I'm going to say here is the data and I'm just going to again grab the data that's going to be coming in from here so you have several options you can uh grab individual notes so for example I could just grab this and if I bring it here on the bottom as you can see it just says uh json.
weather so this going to give you the weather there but if you want to again grab everything and not worry too much about it you're just going to you come click on that Json field here and literally just grab everything right so I'm just going to go ahead and like select everything and come here and paste all right so that's good let's go ahead and test this out so on the bottom of the Roll you just leave it as user for now so let's go ahead and test it out let's see if this works and again all this data here it's coming in from our previous note which is our um open weather map API that we called uh to grab the data for San Francisco and Bam there you go as you can see on the right hand side here really cool way to put all of that data and convert it into a m Mage and again this is coming in because of our prompt here right um so same thing play around here if you see that hey you know what you don't like some of this or if you don't like the Emojis just change the um change the prompt to to your liking but for now this is good to go again this is a table format but the Json format gives you a more uh structured way to see this this data all right cool so we're pretty much done from here so now what we're going to do is add another quy to this so that way we can convert this data because again like I said this is still in a format that has the role in it the content in it this refusal all the stuff in there but what I want to do is just make this really nice and simple so that way we can have access to it with our AI agent so what I'm going to do is again same thing add another query here so I'm just going to go ahead and go to data transformation edit fields and this time I'm going to change this to response change the name to response cool and then the same thing you just just leave the modee as manual mapping um for add field you click and you can name this so I'm going to same thing name this response keep it as string because we're going to grab the text here right and for the value now all I have to do is just grab this uh this content here right so all I have to do is just if I go to schema I can whoops I can just grab the content perfect okay so that's cool so we're done there and now let's go ahead and test this out again so I'm going to click on test app and there you go you got uh the nice response here this an adjacent on from let's go ahead and table and this gives you um you know the better view that hey like this now the me this message is only coming in from this the execution of this workflow right and this messages is under the response field that we have set so now we going to do is grab this respond field and add it to our AI agent so that way it can has access to this message only when we're chatting with it so let's go ahead at this point we're done with this as you can see this is successful uh so now we're going to switch to our previous workflow our a uh AI agent workflow and we're going to now connect this workflow tool or sorry connect this workflow to this AI agent via this n8n workflow tool so this is what as I mentioned before makes NN really uh different from other tools tools because you can add separate workflows to it all right so you can again rename it but I'm just going to leave it as it is for now uh parameters so let's go ahead and name this parameter so I'm just going to say weather tool right because again this is uh um our weather workflow that's coming in from that separate tool there so I'm just going to name it weather tool you can name it whatever you want all right so for the description oh give me a oh yeah you're not allowed to have space so for the description this is where where you want to instruct this workflow you know to what to do so again gives you that uh placeholder call this tool to get a random color the input should be a string with comma separated name so this is just a um place order but it just gives you the format of how to write a description so what we're going to say is use this tool to get the current weather data for a specific City and we're going to say input should be the name of the city all right perfect that is good all right so now here's kind of the magic here's how you attach um your other workflows so you come here and select Source database um so if you Source this defined below this just gives you the option to just attach or copy and paste the Json uh so if you're familiar with code again same thing you can just bring the Json from your other workflows and just paste it here or the easiest way to do is just click on database and you can grab the workflow ID the workflow flow ID is always if you just look at the URL on top here so let's go back here if I click right here as you can see the workflow ID is this ID at the end of it so you know it says AI workshop. app. nn.
Cloud slworking2 which means that your AI agent has um access to this workflow over here because we added this tool all right perfect so now we're done there you go now that error disappeared because this workflow tool is now attached to this one because of the fact that we added that ID there right okay so now let's go ahead and test this thing out right so I'm going to go ahead and click on save so now if you're asking a weather related question this AI agent will anonymously decide to grab that data from this workflow tool but if you're asking it anything nonrelated to uh weather it's going to grab that data from Wikipedia and we're going to see that in uh real life so let's go ahead and start a chat here so earlier we asked it what is the capital of Spain and it answer the capital of Spain is Madrid and it used the Wikipedia tool here so now let's go ahead and ask it what's the weather in San Francisco all right perfect there you go now as you can see it's using it's giving us the weather in San Francisco that is 23.