AI agents have been all the crazy this year so today we're going to cover a full beginers guide to AI agents with na n and by the end of it learn how to build your own AI agent so without further Ado let's get right into it so before we get started just to share a bit about myself my name is Cal from dynami Ai and my goal is to explore and share practical AI use cases and workflows that we can build today to get a hit in this AI race and so what are we going to cover today firstly by the end of the video you learn to understand the landscape of AI agents and from there you understand the difference between AI agents and automation and why AI agents is the next big thing and by the end of it you will be able to build your own AI agent using n8n and so why AI agents as you can see from this chart over here in Google Trends you can see the interest in AI agent has been an all-time high in the past couple of months so what exactly is going on and so essentially AI agents is the future of AI with a CG of 43. 8% it is predicted to grow from $3. 6 billion in 2023 to $139 billion in 2033 and by statistics 30 million jobs are predicted to be replaced by AI agents by 2030 and so why is that so right AI agents is essentially like your own AI assistant that has a brain of its own and it's the first step towards a truly autonomous AI to help you understand that even further AI agent is sort of like a digital helper that thinks decides and work for you and he has the ability to access work flows and tools and make decisions for you just like your own specific AI worker right and this is all because it's able to intelligently interact with the environment to achieve a goal so unlike a basic AI automation workflow where we have to give you a fixed structur instruction an AI agent can actually help us a achieve our goals by making a decision that isn't structured but based on the tools that we provided and the instructions that we give and so here's a simple table to just help you understand a little bit further about what's the difference between AI agents and automation firstly when it comes to decision making AI agents are able to think and make decisions autonomously whereas compared to automations automations follows predefined rules or workflows that we build for them and when an error occurs or something needs to be changed we have to change the predefined rules if not the automation will just continue to work in that specific manner whereas an AI agent will be able to think and make decisions autonomously with the ability to adapt and change whenever necessary but of course this is also fully based on the instructions that we train an agent to do that we will cover later on when we build our own agents secondly because of the autonomous nature of AI agents it is able to learn and adapt to new tasks dynamically whereas an automation is limited to the task it is programmed for and from there an AI agent actually works like a human worker where engages with us via natural conversation where and automation mainly Works silently in the background so when we giving AI agents instructions it's sort of like talking to your own worker we ask them to handle specific task for you and then you will have a back and forth conversation with the agents to get the results that you want as compared to an automation we give an input and the automation will work in the specific set of instructions and return you a specific set of outputs so of course while agents are more flexible there's definitely best use cases for each of them and so for an agent itself it's definitely more useful to handle complex Dynamic task that needs decision making as compared to automations which could be better for repetitive test that only needs you to set up once and it will automatically do the same same thing over and over again and so I know all this Theory may sound a bit overwhelming so not to worry and so the best way to understand is to execute and so today we'll learn how to build our own AI agent on N to Showcase to you how an AI agent works and what's required to build an AI agent and the platform we're going to use today is an which is a super powerful workflow automation to that powers AI agents by connecting apps enabling task execution so what I love about anyn is also that it is a low code and no code to that not only allows you to create these automation workflows but allows you to build AI agents within the system to make these AI agents for you more effectively in a simple manner that any one of us can get started right away and so for today's example we're going to build this email assistant agent that helps you read right send emails while updating a contact leas and share updates there too and so how does this agent work right so let's take a look at this diagram to understand how this agent works even better so you can see over here we'll start off with an input and this is where we will chat with the agent using a chat interface and so after telling the agent what we wanted to do we will actually send the information to the email assistant agent over here where it will have access to a couple of tools so just of weave over here you can see there is a chat model which is essentially like the brain of the agent and this is where we're going to use a large language model like chat gbt or clot later on and it's because to start you need to power the agent with a large language model for it to be able to provide you the results that you want afterwards the second thing that we need to build in this AI agent is to have a memory function the agent will be able to understand our conversation and keep them in memory so that we don't have to restart the conversation over and over game so for example the memory function will be useful if let's say we were to ask it read our latest email and and afterwards we want to further follow up with it with some context we have to tell the agent everything again but with memory function the agent will be able to continue the conversation from where we left off and the tools is where the agent really gets the superpower right so over here you can see we have some tools that we have provided so the first one is the search a table to which allows the agent to search the air table for contact details and from there we have the create air table field tool that allows the agent to create records and update our contact lease following that as this is a email assistant agent you will be able to send email as well using the send email tool and you will be able to read our emails as well using the read email tool and so you can see from this basic chart you can see the difference between an Automation and Asian right away already so for example if this was a automation it has to go through a set of specific sequence like searching the ad table and then sending the email and then giving us the output and so you can see from here what's so special about an agent is that there is no specific flow of action for it to do you only give it a couple of tools they can access to and from there the agent can actually utilize these tools to give us a result that we want for example if you want to sear search the air table for a specific contact you will actually use the search Air table tool and then provide us with the contact but if let's say we want to send an email you will use a send email tool and then we also can mix and match such as searching a contact from Air table and then using the contact itself to send an email and then providing us with that output so you can see from here it's actually more flexible and really works as your email assistant agent as compared to a specific workflow now so Theory can only get us so far so we're going to build the aii agent in any end and I'm going to show you how the whole flow actually works and show you what you can actually do in real time so let's get into any and to start the building now before we continue this video to get access to all my resources Link in description below to follow along more effectively so all you got to do is to create an account in any end and you will get a 14 days free trial to get started so as you can see from here this is the exact workflow that we have covered in our slides just now so I'm going to run through view each of them one by one to help you understand better okay and so I'm going to create a new workflow and build it from scratch let's start by creating a newf flow over here and click personal save changes and here we go all right you can see over here this is how we're going to add in a note in any end so we can add the first step and we're going to choose from the site a trigger and we're going to choose the trigger on chat message okay and we're going to click back to Canvas this is where we going to get a trigger from our chat and so just test it out we can say hi and you can see there's a trigger our message is sent over here and this is the message that we're going to send as input to our agent later on okay so this is very straightforward very easy once this is done we're going to add the next note so we're going to press plus over here and this time let's search for AI agent and let's click enter and we'll have the AI agent popped up over here so let's click back first you can see this is an AI agent that we are going to add in to our workflow and so let's go into the AI agent page to get started there's a couple of agents that we can use in any end and for today we're going to use a tool agent which is useful to utilize different tools to get the results that we want but from here you can also see there's other agents like conversational agents open AI function agents and so on and so forth that you can actually try out as well the second opt option over here is decide the source so the source comes from our chat input just now so you can see I've typed in high and you can see the chat input is provided over here and so we're going to manually connect it so I'm going to Define below I'm going to choose an expression and I'm going to pull this chat input over here just to show you that it works exactly the same and this where you can actually link the input over here and so just to help you understand a bit of the syntax on an N expression allows you to adding more customized inputs in the Json format and so from here one of the ways that you can map the previous input over is just by dring over the input into the box right like what we did previously and so we will have it over here and for now we're just going to keep it as that we are going to test St to see if we can get the answer okay and so from here there's a couple of things we need to do firstly we need to add in a system message and so this is where we're going to add in our prom to get the agent to do the specific task for us right but before we do that there's a couple of things we do need to add as well which is firstly the chat model and if you remember we have to link it to a large language model like cat GPT to give it the power of AI following that we're going to have to add in memory as well and lastly we're going to add in the tools that we want to create for our agent okay so let's quit this page for now and we're going to come back to this later on so let's press back the first thing we're going to do that's the simplest is to add in a chat model we're going to click plus over here and we're going to choose our model so let's choose open AI chat model OKAY from here you just want to add in your open AI account so you just have to click into the edit button over here right and from here you're going to have to give in your API key and once it's connected you can close this over here so to get your API key you just have to go go into platform.
open and create a new secret key and add it in into your n workflow now you have to put in some credits for it to actually work so make sure that happens all right once you add this in you can choose a model and for this simple example we are just going to use GPD 40 mini as it is good enough for us to get the results that we want at a low price all right and let's close this once this is done we should be good okay and now let's add in a memory feature as you can see from here in the memory section there's a couple of different options where we can use different types of memory storage but we can use the window buffer which is the easiest and no credentials are required this allows to start the temporary conversations in the window buffer memory for it to have enough context to get us what we want so let's click into window buffer memory and we're just going to keep this it will get the information from the session previously from our chat so this is good enough in the context window is how many past interactions the model will receive as context so we can keep it as five for now to get started but you can increase the number or decrease it according to what you want all right so let's keep this press back and this time Let's test out the conversation again and see if we get something out of it so we can say hi you can see over here that it's actually running if you take a look at our chat it actually replies us saying hello how can I assist you today so this means that chat GPT is connected and now let's test out if the memory actually works so I'm going to tell it I am cow what's good what is my name you can see it has remembered my name so that's pretty good and this is where the memory really comes in handy what did I ask you see and it remembers the previous conversation as well so it means that it's working so now let's give it some functions to make it work for us effectively so before we start building the tools we're just going to create a dumi data with air table to use as our contact database you can either do this with air table or an Excel or any other database you have but for this example I'm just going to use air table for us to understand how it works so over here you can see I've created a new add table base and I have a couple of dami data over here so I have a few names over here a few emails couple of phone numbers tag on whether they are client or Potential Prospect priority and some notes inclusive of created time and last modified time with all this information I'll be using this for our conversation with the AI agent later on and now to connect your a table to any you need to go to a table. com sreat token and from here you want to create a new token right and once you create a new Tok token and add in your base which for us would be the contact information you will be able to get a new token that you can copy to add into your API token later on for air table right so coming back to the workflow we're going to add in the air table to now so we're going to search for air table we going to click into this right and we're going to see over here you can see from the top if you do not have a credential like I mentioned earlier you just have to get your API key create a new credential adding your assess token and you will be able to connect it effectively right do have my access token over over here and so it's connected perfectly all right once that is done I'm going to choose the base and so make sure to connect the base that I want which is the contact information base over here and I'm going to add this in contact information and I'm going to add the table which is table one and then I'm going to change the operation so over here a couple of different functions that you can give your AI but for this example we just want to give it two functions to read and search and the second function which is to create new records so we're going to create the first one which is search add table and we're going to click search okay and from here we can leave the rest empty and that should be good go back to anyn we're going to rename this to search search a table okay now let's see if this works we're going to ask get some information and see if the agent can actually get us what we want so I'm going to ask can you find out what is Cal's email from the air table and so it's able to search the email exactly like what we have in the error table so you can see how now the AI is actually utilizing the tool to give us the result that we want very cool so I'm going to add in a new feature I'm going to find a table tool okay and from here we're going to choose create a new record in the table and we're going to choose the base the same one all right and this is good and from here these are some values that we need to send to the air table so here's where it becomes a little bit tricky so to give it a non-fixed answer that comes from the AI there is a feature CAU from AI That's super useful in this specific context so let's click expression and I'm going to show you how it works firstly we're going to open up the bracket we're going to add in the money sign from AI you can see over here from AI this feature itself allows us to add in the information so let's say if this is name we're going to add in name under key and we can also give it a description on what is the information about we can also give it a type as well now the following two are optional but it's are important information to give more context to the AI so I'm going to show you how we're going to do this I'm going to add in the bracket and I'm just going to put in a syntax with the quotation name you have to close the quotation and then your bracket again and that's very you have it and so this essentially will allow the AI to grab the name and update the name column using name and so I'm going to copy this I'm going to click expression at this in change this to email add this in we're going to add in change this to phone uncore number now we kind of have spacings inside the syntax so we can either use underscores or we can put the words together as well and for the TCH we're going to copy and paste this in you can see over here we want to have perhaps maybe only two text client and potential prospects this is where we can actually utilize the description feature to Ed more information for the AI so for example I can change this to Tech and I'm going to put a comma so I'm going to add in type of contact either a client or a Potential Prospect to help the AI understand better similarly we're going to copy this we're going to paste this here and we're going to change this to severity of the contact urgent meet low all right and we're good lastly we're going to add in some notes so we're just going to copy this we're going to paste this over here or we're going to change this to to priority right and change this to notes we're going to add in additional contacts and important information of what the contact is about now that's all we need to do and we can press back okay and now let's try this out so let's ask it to create a new contact for us to see what happens we're going to go into chat and we're going to ask it can you create a new contact for me in the contact list name is Samuel phone number we're going to give it a random one plus 55976 895 and then we're going to give it a random email as well email is Samuel gmail.