okay so today I'm going to be doing a live build of an AI agent this agent is going to qualify leads and going to generate a personal message for each lead so don't want to waste any more time let's just get straight into building this one the first thing that you got to do is have a lead database set up somewhere so for today we'll be using Google Sheets we've got two leads here for Simplicity sake and information about each lead and this data is coming in from a Google form um your your potential leads
would fill out this form and then you have to make sure that it's linked to a sheet that way it'll pop in here automatically and then your agent can qualify them so one thing to note is this form ends with this column right here anything else we should know and then before you hop into building this agent you want to add a column called rating a column called reasoning and then a column called Outreach this is just so an nadn it knows to populate these three columns with the information so um if that doesn't make
sense right now don't worry as we get into building it you'll see exactly what I mean so back over to NN this first workflow that we're going to be building is a lead call tool so this is going to be the tool that the agent calls in order to qualify leads so that is going to be a trigger of when called by another workflow so the agent will call this tool in order to start the process of moving it through this logic second thing that we need to do here is grab a Google Sheets node
um as you can see there's 10 actions within this Google Sheets and we're going to do get rows in sheet now you need to set up your credentials for this node basically just telling n&n that it has permission to access information in your Google Sheets so if you click on docs right here it'll bring you to this page by NN and it will pretty much walk you step by- step how to get this set up with your credentials it's super simple um you're basically just going to sign in and you might have to set up
your ooth consent screen but like I said that document will have all the information you need so we're going to do a sheet in the document and we're going to get rows and then we're going to choose the document we want that's going to be let's work together responses and then the sheet there's only going to be one sheet in here so it'll be form responses one then you can go ahead and click test step this is how we make sure that the information is actually reading into anent so as you can see we've got
our information about John and about David right here so it populated in well now let's move on to the next step so we're going to add another node this one's going to be open AI a ton of different actions you can take once again we are going to do message a model you're going to have to set up this credential here so I'll show you guys exactly how you do this one you're going to click create new credential and you're going to have to grab an API key so over in open AI you're going to
go on the left hand side find API keys and then you're just going to create a new key name it whatever you want and then once you do that it'll give you this value to copy copy that right there and then just going to paste that into Ann hit save and you should be good to go there connection tested successfully okay now you have to set up this node so we're going to do text message a model and then choose our model of GPT I'm going to scroll down and choose 40 okay and now we
need to prompt this node what to do so this first message box here we're going to change this to a system prompt because we are telling the node what it needs to do and so I'm going to copy and paste in this information right here so you guys don't have to see me type so we're saying your task is to qualify incoming leads leads are a form submissions to a closed community group use the following criteria the first one is they need to be a decision maker who runs the company or at least has influence
in the decision- making process and then the second criteria is we currently only want to work with companies with around 45 or less employees also known as company size which is how it comes over right over here as you can see so if a lead is qualified it will reply with qualified otherwise it's going to say not qualified super simple and then we just wanted to specify the format of Json to go to put the output into um so you guys can just copy and paste this exactly right here um I'll throw this in the
description so it's easier but that's just how we want the um output to be formatted so that we can easily move it into the next node and put it back into Google Sheets so we're done with this one now we're going to add another message this one is going to be a user message and and this is just the information that we want this um open AI node to be using to qualify a lead or not so we've got name company size and decision maker and what we're going to do is grab in this information
from the Google Sheets so on this left hand side for name we're going to drag in full name that jumps weird but we want it right there Name colon full name and then down here you can see how it's coming in so name John Richards same thing with company size we'll put that right here size 15 and then last but not least decision maker we'll grab that one from here and it comes in as yes I am the primary decision maker in the result tab so that's all we need to do for this node you
can once again hit test step and we'll see how the data is coming in over here on the right hand side so the first one is coming in as qualified and the second one is coming in as not qualified this first one has the reasoning of the lead is primary decision maker the company size is within the threshold and this one says the company size is 100 which exceeds the limit of 45 employees so these two nodes are working that's awesome now we're going to add another one onto this open AI node what we want
to do here is grab a data transformation and we're going to do edit Fields we're going to leave this one as manual mapping and then we're going to click here to add a field this one we're just going to name this field reply we want to change this to an object and then for the value we just want to grab the content basically the open AI node rated if it's qualified or not and we just want to grab that response so we're going to put that into the value here and then one last step we
want to put in front of the dollar sign we're going to go json.parse open parenthesis and then behind content we're going to close the parenthesis oops close the parenthesis and it should go green that's how you know it worked and then you can see the result it should say object colon and then exactly what came out of the open AI node so test that step make sure it's working it should come out as a really clean um two different fields here qualified and reasoning so looks like that did its job perfectly okay next step here
is we need to add this information that we just got the qualification status back to the original data so if we grab here pull over and now we want to add a merge node this merge node is just going to combine the data but we don't want to append it we want to combine and we're going to combine just by position so that's just saying the first um row of data from the Google Sheets is going to match with the first row from the open a Noe and just keep matching it down um and then
you got to make sure that we drag in this right here to the merge node and then we'll go in here and test this step uh as you can see we've got the original data from the Google sheet scroll all the way over we should have our um qualifications set status so qualified not qualified okay so we're almost done with this tool already now we need to add another sheets node so that this information actually goes back into Google Sheets so we're going to choose update row same thing got to set up your credential and
then we leave all this blank or default choose the document once again choose the sheet once again and now it's going to fetch the columns and we're going to match the columns on timestamp so it's going to match up the correct rows in your database and make sure that everything is sort of synced up and now we have to update the values so which which fields in our database do we actually want to change so time stamp is we're using that to match so we're going to drag in time stamp and the only thing we
want to change here are those are those last two columns right here rating and reasoning so you can go ahead and just delete everything El out of here just to keep everything nice and clean so for rating down here from the reply node we are going to grab in qualified it will come through as a result of qualified or not and then for reasoning same thing we want to drag in reasoning so that we can see why a lead was either qualified or not qualified should be good to go with this node we'll hit test
step and we will see see that it populated in here real quick we'll pop over to Google Sheets and we can see if it actually worked so yep John got qualified and David is not qualified with their respective reasonings right here so now we're going to move into the next oh wait no not yet one more thing we have to do is we have to add another edit fields and once again we'll leave it as manual mapping we're going to add a field this one's going to be called respon leave it as a string and
then just say done for the value so the reason we have to do that is because like I said we'll tell the agent to qualify leads it's going to think how do I actually qualify leads it's going to send us off to this tool the data is going to start moving through this logic it'll come here it'll come here it'll parse through all this and then once we hit here and the information's actually updated in our Google sheet the agent needs to know that it's done so it can tell whoever prompted it hey we did
that for you so this node sets the field of response which goes back to the agent as done it's really simple no need to over complicate it this is just how the agent knows that this tool has been executed okay so we got that saved we're going to go back and now we're going to make the um the personal message tool so add new workflow we're going to call this one personal message tool as you can see this means tool basically at least that's how I assign assign tools and agents same thing with the trigger
we're going to do when called by workflow add a Google Sheets node and we're going to get row so this um this workflow is going to be very similar to that last one which is super nice because it's pretty much we're getting we're getting the information from the database we're doing something to get some sort of answer to put back onto the row and then we're actually putting it back onto the row so these two workflows are going to be very similar we got to grab the document once again test step and we should see
actually the rating coming back so we've got qualified and not qualified here same thing open AI node message a model set that up with the key we just made um and and then we're going to grab a oops connection okay we should be good I don't know what's going on here we're going to grab 40 once again and okay now we need to system prompt this open AI node so I'm going to copy and paste this in here again so that you guys don't have to see it but here's what I said your objective is
to write a personalized message to each of the leads output the leads preferred method of contact and when is the best time to contact them then provide a script that is personalized based on their company job title and what they're looking to automate if the lead is qualified then provide a message otherwise don't and then at the end I wanted to add these messages should be sent from Nate herk the company is 1 12 345 Corp and His email is Nate herk at blah this message shouldn't include any variables like your name or company name
use the information I provided so I had to add this in here because when I was playing around with this agent it would put the message out with you know hey this is your name um contacting you from company name and we don't want it to be like that in case you know that just takes out or that makes you have to do a lot more manual work so we just wanted to get rid of that process okay so that is the system prompt now we need to once again add a new message this is
going to be a user prompt and same thing as that last open Aon node we're just going to be giving this node the information that it needs so it wants to qualify or it wants to send messages based on um the name the job title what they're looking to automate and if they're qualified or not so again we're just going to drag in the information I don't know why it always does that the first time but we've got name John Richards job title he is the owner what do he looking to automate he wants to
automate customer support and sales and then rating we'll drag in over here if he is qualified or not so let's test this step and see what we get okay so this first row is for John um it outputed this message I won't read this all right now we can read it later but it outputed the message because he's qualified and then the second um lead over here the lead is not qualified therefore no output is required so that step is working correctly so now we need to once again grab data transformation and edit Fields we're
going to manual map add a field same thing reply um I think actually we can leave this one as a string yeah we can leave this one as a string and for the value we want to grab this information that's coming from the previous node so preferred method of contact email best time to contact morning and then the message below it we'll test this step and it came through nice and now once again we need to combine this new message with the original data set with the lead information so drag this over here we're going
to grab a merge we're going to combine based on position o that's not going to work because we didn't drag the other input in so now we'll go in here and test this step oops okay we should see we got two records here and then at the end we've got the messages back associated with each record so next once again got to add a Google Sheets node to push this new information back into sheets so that's going to be updating a row in the sheet we'll set this up once again hopefully not too repetitive um
so we're going to match again on time stamp so we'll drag that in and then we only want to update the message so we're going to get rid of everything else here except for outreach that's the column where the message is going to go and we just grab the reply throw it right in there and it comes through with the information we're looking for so test this step go into here and as you can see now in Google Sheets we've got the Outreach message for these two leads lead's not qualified so he got nothing this
guy got a message and then can't forget of course we need to add the final set node so you can type in set edit Fields whatever you want to call it manual mapping add a field field is called response leave it as a string and the value is going to be done so you will save this and now we have the two workflows that we need we're going to go back into our project add a new workflow and of course it is time to build the agent so this one's called demo agent and we need
to add the trigger so you can trigger it manually all these type of things we were doing when called by another workflow but this time we're going to do on chat message because the whole point is that we can ask the agent to do something and it will do it so we've got this trigger here um to add an agent you can either type in agent oops that's not how type agent agent or you can just go to Advanced ai ai agent it's going to be a tools agent there's couple different options um conversational is
good for like customer support um but we want to do tools because it's going to be accessing different tools to do different jobs so we've got this and then we going add a system message this is just prompting the AI agent what to do I don't want to get too much into prompting right now let's just leave this as a helpful assistant because this workflow is not too complicated but yeah just leave that like that for now chat model I always use open AI with the model of 40 that's all we need for memory we're
going to do window buffer memory so if you guys don't know what this node does it basically is just going to give the agent context of our conversation so if you ask it to do something and then it's going to respond and then you can ask it to do something and you may reference what just happened the agent will be able to remember remember five um chats basically that's the context that it'll have to work off of if you don't add this it'll basically just be question and answer reset question answer reset so it's super
easy to just throw that in there so pretty much I just always do that okay so this is where the magic happens we're going to add the two workflows that we just built we're going to use this node right here call NN workflow tool to do that so this first one that we're going to do is the lead call and we'll just call it this lead call up here too just to keep everything organized and now you have to give this node a description of when to use this tool so super simple call this tool
to qualify leads in the database so where is the workflow that we're calling here you can do by ID by or from list it's really nice that they let you choose just from a list here and we want to do the lead qual tool so set that up and then this is the response field if you remember at the end of the tools we set up that set field and we made the response field done so that's what it sees that's how it knows it's done so there's lead qual now we're going to do this
same thing again this one is going to be the let's call it message going to put that in here as well and then same thing call this tool to generate personalized messages for leads and I'm actually just going to get rid of personalized that way it's it's a little easier when we ask the agent can you make messages for the leads we don't always have to say can you make personalized just to keep it easier so same thing from list we're grabbing the personal message tool and it's returning response so oops let's go ahead and
save this agent and let's get to testing it so we're going to chat with it we're going to say oh first we need to get rid of this information to make sure it's working so we've got the two leads here with no information in the rating reasoning or Outreach column let's see if it's working so can you please qualify the leads in the database so it had to talk to chat to figure that out now it's using the leadqual tool so that's working well back to the agent it's going to go back to the model
and it outputed to us all leads in the database have been qualified how can I assist you further so as you can see here we've got the two leads are qualified not qualified with their reasonings now we're going to go in here and say yeah of course let's um can you please uh make messages for those leads so he's going to talk to the model uhoh it's using the lead call tool that's not what we want we want it to use the message tool there we go okay so I think it was just making sure
they were qualified back to the model back to us messages have been successfully generated how can I ass you further okay perfect so let's actually read this message now so this guy's qualified he got a message let's read this message so they said oh no what did I just do okay he said [Music] um preferred method of contact is email contact him in the morning the subject is transform your business process with 12345 Corp hi John Richards I hope this message finds you well my name is Nate herk and I'm reaching out from 12345 Corp
given your role as the owner and your interest in automating sales and support I believe our services can significantly enhance your business operations at 1 12 345 Corp we specialize in streamlining processes to improve efficiency customer satisfaction by automating customer support and sales we can help you save time reduce errors ultimately increase your bottom line I'd love to discuss how we can tailor our Solutions are you available for quick call later this week I'm generally available in the mornings okay so it was very personalized it sounded like I actually went in here and wrote this
myself obviously this message can get a lot better as you prompt it differently as you give it information about your company and the services that you offer so you can give it access to that through you know a database a vector database whatever it may be um so this is just a super simp simple example I think I built this in you know maybe 20 minutes so you can definitely make them better and better and as you add more leads one thing that I wanted to point out real quick is with this workflow this lead
qual tool I think in an actual um application you would want to set this up not as a call from an agent you would probably want to set it up as a trigger based on Google Sheets so if we did sheet trigger down here on row added so if you added in this node what this would do is every time someone submits a response to your form it's going to pop into here as a new row and then this workflow will run automatically because it's being triggered by a new row so you'd set up the
logic exactly the same you just put this right here and then you could probably get rid of this set field but you do the logic the exact same and then it would automatically immediately qualify them or not qualify them and you could do the exact same thing with the Outreach message but I just wanted to show you guys sort of how easy it is to build a tool and how easy it is to build an agent that can call these tools and just sort of open up your eyes to the capabilities of agents and what
they can do so yeah um I hope you guys enjoyed this live style it it is good to and actually I'll show you guys one more thing real quick so when you're testing the agent you know obviously you hope to get no errors in the workflow but if you do you're going to go down to executions and then you'll see all the previous runs they'll be read if they errored so let's say we got an error with the personal message tool we click on view and this always takes way too long to load but once
we get here this is the run that would have just executed so you can click and see exactly what's happen happening so you can see maybe you didn't prompt this tool right and something's coming out weird or you can see maybe you messed up the parsing and this is coming out as a a a weird object um the point is you can get in and find exactly where things are happening and go in and troubleshoot so yeah I think that's going to do it for this one um please let me know what else you guys
want to see and if you sort of like these live builds or step by steps let me know too and yeah that's all so thanks guys