in this video I'm going to show you how to build an automated email system that's promptly going to reply to your customers by automatically categorizing your emails and crafting replies so why is this important to have for your business according to mail model 90% of customers rate an immediate reply as essential or very important to dealing with customer service and as much as 60% of customers Define immediate as 10 minutes or lower and that is what this automation is going to achieve for you so let me show you a quick them of how it works so we're here now at the start of the workflow and it's active which means that if we send an email it's going to reply to it automatically so let's first start by going to my Gmail here and send a new email so I'm going to click on compose here and at left side here you see I already have some uh some categories that I've added and I'm going to send a consultation email asking for booking a time for consultation so two was just going to send to myself here I'm going to say hi uh I want to book a consultation now it will automatically categorize this as a consultation booking best mic and it's also going to extract the name there so let's click on send now we can take up to 1 minute until it replies so let's go back now to the workflow here and let me explain what happens so first of all we have this Gmail node or Gmail trigger node which will get triggered as as soon as an email is received what we'll do then is we're going to use this information extractor here with open AI to extract the name from the content of the email after that we have an if node here that is going to check if it managed to extract the name or if not if it managed to extract the name we're going to craft an introduction here starting with deer and then the name so de mic in this case if it didn't extract the name it would just create this introduction here saying hi just a general high after that we use this merge node to merge that together and choose one of those replies and then we have this set node here that I called format data what this does is it takes the introduction that we created and it combines them with other data that we're going to need later on in the workflow after that this email classifier is going to classify uh the email based on the content so we going to classify it into one of these categories here that we have chosen and then after classifying it you're going to send it down each respective path so if it was a consultation it's going to send it down the consultation path here and it will uh and this node consultation booking not here it will uh yeah it we're going to label it here it going to give it a label so one of those labels you chosen down here and then after it it's going to use this node here to reply to the message and here we have a template here templated message you can write whatever you want together with the introduction here that we got from the variable the introduction that created before so let's go back to my email and you see that we have now received a reply so this was my message that I sent hi I want to book a consultation best mic and you see here that extracted the name correctly dear Mike thank you for blah blah blah reaching out to business of course it's just a place order so you will change that according to your business best regards Etc and it's it has also been correctly categorized as consultation among all of the categories here so if you go to consultation here you will see that the email is inside here now let's get started building this so I'm here at my any1 dashboard if you don't already have an account you can create one by using the link below in description and you will get a free trial try it out uh so the first we're going to do is create a new workflow by clicking here and here we're going to choose our workflow trigger node which is the node that is going to trigger the workflow so we click here and it's going to be a Gmail trigger so search for Gmail click here and under trigger which chose on message received here okay so what this node does is it's going to trigger the workflow as soon as we receive a new email message and here is the pul time or the PO mode so the least one you can choose here is every minute you cannot choose any shorter interval uh so we're going to leave it as every minute because we want it to be as close to instant as possible and you're also going to have to set up your Gmail credentials now there's a tutorial here if you click on docs well not a tutorial but some instructions on how you can set it up and uh I also have a video that will help you do that you will find that in description below it's a straightforward process it's not it's not difficult now I already have my set up so I'm just going to continue here and uh on simplify here it can simplify the data that we're going to receive we don't want that so we're going to uncheck this we want as much dataa as possible okay now the next step here is to um extract uh the name so we're going to use an information extractor for that we're going to extract the name from the email to receive if there is a name so click on information extractor and here we have the text to extract information from okay so first we're going to run this and get the email email and here we get a schema with different items from the email and what we're going to extract the name from is the text here so we drag this over here and then here we choose from attribute description yes and here we're going to add an attribute and we're going to call this sender name that's the attribute or the the variable name of the value that we're going to try to extract and then here we're going to describe what it is we want to extract from this text here you see the text here I just want to which is the I just want you you say your service is great which is the email the email body here that is what we're going to extract so if we go back here and we're going to add a description to the information extractor so it knows what we want to extract so I'm going to tell it extract the the sender name from the email if no sender name return and empty let's make this a little bit bigger return and empty string okay and now if you scroll down here uh let's see click on options you have the system prompt I would like also want to update this if you do not know how the value of the attribute as to extract you may omit the attributes value instead I'm going to tell it to return an empty string you may you must return an empty string great now let's try this out sub node must be connect okay so it needs a an AI model to work of course so we go down here and click on model and here we're going to choose a model now I tried mistol for this it works sometimes sometimes not it's not very reliable so I ended up using open AI now the good thing with m mistol is that currently you can get a free account and use their apis for free but for open AI you're going to have to pay for it so GPT 40 mini is good enough here I also already have my credentials set up here it's very easy to to get set up your credentials it's just an open a open API key you just create your account and you go into settings and create an API key and then you will click here and you will paste it in here it's very simple okay so that is set up now let's try this again and it worked and let's see here what do we get Sender name empty so if you go and have a look at the email I sent here it was hi I just want to say your service is great so it's correct that it's empty because there's nothing here in the email body indicating any name let's go back here now the next step here is we're going to add an if node click there and search for if now what if node is going to do here is if we have managed to extract the name it's going to become true and we do take this path and if not it's going to become false and take this path so let's go back inside a node here and we're going to choose the sender name here from the information extractor and we're going to make sure that it is not empty so if it is not empty then this becomes true and we will have a name here and then we'll use the name otherwise it become false and we take the other path below that I just show you okay it's not empty and convert types when required sure and that's basically it for that now let's add a set node for the true here and we're also going to add one for the false no so not false set node um take it down here so what's going to happen now is if we have extracted a name here it's going to take this path it's going to be true this condition is going to be true that this variable sender name will not be empty it will have a name so if it is true it to take this path and if it's false it would take this path so let's go inside this true set node here and let's execute this see we should get some input okay of course now the name was not um the variable did not contain a name so which is actually false this time so let's work with the false uh path first so in case we don't have have a name and it is false we want to create an introduction that does not consist of a name a very general introduction I'm going to call this variable here intoduction and we're going to set the value here it's just going to be big string High because we don't know the name so we're just going to reply hi to the customer since we don't know his name okay and let's just rename this to No Name like so and above here we can rename this one to has name okay and here we're going to set the variable the introduction variable if there is a name now if there is a name it's going to start with there and then the name and the name we are going to get from from Json do uh what is it Json let's go back here information extractor outputs sender name yes so it's output sender name so we'll get it from Json output sender name I guess output yes okay so let's try it Json output sender name and a comma let's try this okay now let's what we're going to do is now send a new email here try and see if it works so let's compose one with the name inside to myself and say I want to book a call call my name is arra send this go back here and test the workflow May comes through this time we should now have a name here let's have a look at this expression there okay for some reason it didn't work as expected here sender name AC so Json it should work but it didn't uh this is where so let's test the step again okay now it worked for some reason yeah so we just had to run it again to make it work so dear R that's correct so you see that if if you have a name inside the email it will take this path and now the introduction will be de and the name in this case it's acram and if we don't have a name or the information extraction don't manage to extract the name from the email you will take this path and it will just say hi inroduction will just be high okay now we want to combine these two here into one path so we can just continue on One path in either case for that we're going to use a merge note let's take it down here and connect it here so we have two inputs now the has name input and the No Name and here we're not going to pen them we're going to combine them and the fields won't be matching really or will yes matching Fields we're going to leave it as matching fields and the fields to match here is going to be introduction because both set nodes has this introduction field that we're going to match and we're going to keep not the matches but the non-matches because the values aren't going to match one will say de acram the other one will say hi so not going to match or one will say d acram the other one will say yeah High actually but it's because it doesn't have any value from the beginning so so we will set that as high and only one of these will continue and that is the one that succeeded right so uh here we also both inputs pended together now let's try this step in this case we will end up with the arram so let's run it from here instead you'll see now that we got introduction there arram so if we didn't have a name let's try and remove this uh email with a name here latest one remove this email and go back and run this again it will take this path below now because that's the latest them one without the name and now we will end up with introduction high now we're going to add a set node here and what we're going to do in the set node is we're going to combine different um different items that we're going to need later on into one object here for convenience so the first one here is going to be introduction and we're going to use this introduction value and variable to craft our reply emails later on and then we also going to go to Gmail trigger here and we're going to need the ID which is the message ID what we should use later on as well to reply to the message so let's drag this over here and we will name this message ID and then we will also take the email body here which is text this one here we call this message body and this will be used to classify the emails okay I Let's test this now let's rename this to format data all right and now the next step here is to classify we're going to start classifying so text classify fire going to add that here then let's click on test workflow well we're going to have to add a model first now here we're going to add or I'm going to add a mystal model you can also use open AI but for the text classifier mistol worked very well so I'm going to use mistol here and I'm going to use the Nemo model so let's look for that mistal Nemo open mistal Nemo and setting up credential the same as open AI you just create a mral account and you go in there and create an API key it's very simple very straightforward okay now let's test this workflow it can't run why can't it run okay of course it looks for a text to classify Now text to classify is message body here so we're GNA add it like so Json message body at least one category okay so now we're going to have to add our categories so let's go back to the Gmail account here and here we're going to add our labels so the first label here is going to be for service inquiries so I'm going to call this service in in quiry create that and then here going to have one of consultation bookings consultation booking and one for feedback and then we also have payment billing and the last one is miscellaneous for everything else missous is that pronounce misay Mis Mis mcain yes like that I guess all right uh so now we have five categories here five labels you can also change a color like to do that it looks much prettier feedback feedback I want green feedback so use green for that miscellaneous can be I don't know white maybe payment building yellow money color uh or green maybe in America I don't know service inquiry it's just choose whatever okay now let's get back to the workflow and uh let's open text classifier now if you run this again now uh there should be some categories or no we're gonna have to add categories here sorry about that uh so the first category I'm going to add here is service quiry and then we're going to give it a description that tells uh the text classifier what it should classify as service inquiry so I'm going to tell it um questions about uh services offered uh rates you know and availability now let's add a second category here this is going to be consultation booking description will be uh scheduling scheduling consultations consultations follow up meetings meetings Etc and then we have uh this going to be St payment billing payment billing here we have questions about invoices invoices uh payments and refunds and then we had feedback feedback emails or clients giving feedback reviews and testimonials on our services and the final category here is miscellaneous [Music] miscellaneous uh emails that don't fit into any of the other categories so now we should have all our categories here so let's try the step and now the email went into one of these branches let see here which it went into went into the feedback branch and the message was hi I just want to say your service is great so it classified it correctly if you compare that with if you compare all of these uh category service inquiry consultation payment feedback it was definitely a feedback here because they told us our service was great so that worked perfectly okay now I'm going to show you a KN trick here by the way while we're working here we don't want to uh while we iterating we don't want to run all of our workflow every time so what we can do is you can pin the recent data so I'm going to select all of this here and then I'm going to click on P you can also right click and uh you should be able to pin here you see p here so H you click on P or you right click and click on pin and this will pin the recent data here so that every time you execute this it will use the recent data and and you don't have to make API calls and wait for such a long time okay now let's continue here for each of these categories uh we're now going to add a Gmail note and this Gmail node will be adding a label to that message so this is service inquiry now since we created our labels here we should be able to choose them from here so if it was classified as service inquiry we're going to label it as a service inquiry so let's scroll down here I'm going to find our service inquiry label here okay now we're going to have to test workflow I guess is can for reason okay we're going to have to give it um message ID maybe first going add label no that's correct sorry the operation here is ADD label that's correct here is where we will find our labels so this one is service inquiry and then we're going to give it the message ID so again test step execute previous nodes it didn't give us any data so let's do this manually we go back here you see we have uh okay so the message ID here is [Music] status pinned message body message ID it should just be Json message ID in this case format that up so message budy J on message ID and let's test this now let's run this our workflow okay of course here's the mistake I did um it went to the feedback branch and I'm expecting to get something in service inquiry Branch so let's create a node for the feedback bran first while we're testing here uh great Gmail and add label here and the message ID is going to be the same here Json Json message ID then we're going to select feedback down here where is feedback that's feedback now let's run this let's see what happened here we got an error bad request please check your parameters invalid ID value okay so something is obviously wrong here but we received the schema here so we can just drag it manually okay it looks looks the same so you know this is one error that happens sometimes sometimes when you input it manually it won't work so you just have to drag it or you know re-input it and stuff like that it just happens sometimes so let's test this now it should have worked so if you go back here and have a look let's see if it has categorized it yet and it hasn't really so let's run the whole workflow it should now have categorized it and you see now we have a c category here label feedback label I just want to say your service great so the email here is definitely feedback email because categorize correctly and it's also now been labeled here so if you click on feedback here you will find that email here inside of feedback you will not find it inside of the other labels okay now now I'm going to continue adding these here you can you know fast forward because it's going to take a time or you can just follow along okay so so add one here or another way better way is just do duplicate them so I'm going to duplicate this instead it's much faster doing it that way and this is going to be consultation Also let's rename them press on F2 I'm going to call this uh service inquiry and I'm going to call this [Music] consultation Bing and then we have payment oh we're going to duplicate duplicate this what about the name here conso station booking and we're going to call this payment billing and feedback there and then we have miscellaneous let's duplicate instead duplicate that let's organize this a little bit so it becomes prettier so rename this one to feedback and rename this to miss oh anous all right great now let's unpin all of these and try sending another email see what happens okay unpinning them all together didn't work so I do one by one now let's send another email now I'm going to try to send a let's say uh last one's feedback a maybe service inquiry so let's compose one here to myself here say hi what services services do you offer do you offer and what's your rates now the last time we didn't have a name but this time I'm going to add a name best Jack so let's send this go back here test the workflow and you see now we got to the service inquiry path bad request you know same the same issue here just going to have to rrag it uh the message ID here and let's do that now manually or R ofd otherwise we probably going to run into the same errors okay we can't do it here h okay that's bad so we're just going to have to do it later okay so let's run this again and you see now it worked here and if you go back to our Gmail account services to offer here High what service you offer what your rates it is now labeled as service inquiry best check great and in introduction now you see that it took the has name path so the introduction now was dear Jack so that's the introduction we're going to use now when we create to reply now let's start creating replies them so let's go over here and search for Gmail and we're going to look for the search for the reply node reply to a message and the message ID here is going to be the message ID from format data and as type here it's going to be text and the message is the message body here so that's the message we're going to reply to or no actually not we're going to give it a message that we're going to use as a reply I have a few messages here in a document I'm going to use so for the service inquiry I'm going to use this template here copy that and add it down here let's expand this so this is how the message is going to look like now I created an introduction and we have that in a variable so depending on we don't always want to say dear Customer because if someone sent a message that doesn't include a name we shouldn't reply their customer name we should reply just hi so that's why I set up the whole if else uh condition before so how we're going to do this is we're going to add a variable the introduction variable here so if we go down here to um format data we should have the instruction here let's drag it over here and now it will give us the jack in this case and in the case where the sender hasn't provided name it would just say hi so now I'm going to do this for the rest of these can duplicate it let's duplicate it multiple times connect this one here that and let's also rename this no do it from out here we're going to call it reply service inquiry reply reply consultation booking reply payment reply feedback RE reply miscellaneous okay now if you open up this we're going to have the same now this part here the variable part we're going to leave the same because it's a variable but for the rest here you're going to have to change this to whatever message you want to send I'm going to take my consultation booking message here paste it in here and remove this part because we're going to be receiving that dynamically reply payment here take my payment building up until this part I don't need the introduction there we got already have that so let's paste it in there and then we have [Music] feedback feedback now the final one here is the miscellaneous like that so let's try this out now test the workflow it replies to the service inquiry go to the inbox service inquiry here and we should now have received a reply let's refresh this and you see we got a reply hi what services do you offer and what's your rates and you see the replies dear Jack thank you for reaching out to blah blah blah of course you're going to change this to your business in this case feel free to explore our website portfolio blah blah blah best regards Etc so this worked great now let's try uh maybe something else let's try payments to do that I'm going to send myself new email and this time let's try without a name just saying hi hi um uh what hey yeah when when will I receive my refund and I'm not going to mention my name in any way so I'm going to send this go back here test workflow payment building didn't work for the same reason we we're going to have to fix this manually for the first time so I'm going to move this over here message ID and test it again let's go back here now to the Inbox and you see here when I see my refound but it was actually um it's was categorized incorrectly here okay let's go back and have a look here uh I think that might have messed up something with labels you see yeah it should actually be payment here not service inquired so let's choose payment the correct label here and I don't think since I duplicated everything I didn't change the labels for others as well I'm going to have a look at those others yeah so we're going to have to choose the correct label here as well consultation booking service inquiry is correct of course and then feedback is correct miscellaneous I'm going to need to change that as well okay so now our the label are correct and here everything else is correct here as well as I added those manually now let's try and run this again I'm going to delete all the messages here and let's try composing a new message but this time let's try a uh feedback message maybe or a miscellaneous message yeah so myself again I'm just going to say Hi how are you how are you send this back here test workflow and yep miscellaneous reply go back up here and we got Hi how are you thank you for reaching out blah blah blah we got the miscellaneous rise so everything's now working just perfectly so this is the automated system that we built it categorizes the emails for you automatically and then it uses these templates here that you choose and it personalizes the replies using the name that we set here so this basically it for this video if you'd like to get this workflow you will find the link in description below or if you'd like to hire me to build a solution for your business that is customized and fully adapted after your business and of course much better than this one you will also find contact information description below that said if you like the video please leave a like and make sure to subscribe so you don't miss out on future automation content until next time take care by