Send emails using Airtable and SendGrid dynamic templates

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi this is greg from business automated today i will show you how to send nicely formatted emails from every table using sendgrid we will do it in two different ways first of them by pressing a button second one will be scheduling emails to be sent later let's get to it [Music] let's start first with the format of airtable that we'll be using for sending the emails you can see that we are having here field column with the first name let's say the name of our customer we're having also the email of this customer here we have a subject line where we can customize the subject line and we are having some personalization text that we'll be adding later inside of send grid email now before we continue with any automation i wanted to let you know that there is also a built-in app from sendgrid inside of airtable when you click on add apps and look for send grids you can find it here this is also a legitimate way to send emails and it's fairly straightforward to use what it does not allow you to to do is to use dynamic dynamic templates from sendgrid so you would have to paste the html of the email here which is also possible but i think it's slightly easier to basically use the dynamic templates and automations so that we can modify the look of the email inside of center okay so having said that let's move on to send grid now and let's create dynamic template that will contain those those fields so i already have send grid open over here and am on dynamic templates the first step here will be to create a new dynamic template now we have created the template now we need to add a version which will be the actual html that will be visible to our clients we can create a blank template from the scratch or we can go into send grid and use one of the ready-made designs over here for that we are going to use the welcome visa template as a welcome email we will use the code editor so that we can edit the code and we can add the html but you could also use the design editor that doesn't doesn't matter for this case okay you can see that we have already our template here and the fields that we would like to customize is for example here first name so what we are going to do we are going to click on the name here lisa we are going to find this here inside of the code and we are going to change it to first name with double curly brackets this will be the name of our variable that will be substituting with our dynamic text remember that the names of the variables needs to be as a single single string without any spaces in between that will complicate things for for cent crit okay so once we have this template placeholder here let's go to the test data inside of the test data we'll use a json format to fill in this information so let's open curly bracket and let's close them straight away so that we don't forget and let's put the name of the variable that we have typed and let's put this in bracket so that we don't forget the brackets first name and then colon and then also in brackets the name of the person that we would be sending this to okay so now we have the first dynamic field the second field that we would like to customize is the text over here so let's go back let's click on the text and now we can see here the white text so let's substitute this as well and let's put double curly brackets text okay there is nothing here so let's copy this text and inside of our json we'll add another variable so we'll do quotation mark and let's write text and inside will be our longer text okay this is just to show you that that what the text will look like visually so that you can see that this will be the information that will be substituting dynamically from our integra from our air table okay another variable that we would like to substitute is the subject so we would like to customize the subject to customize the subject we are going to go to here to the subject and instead of the fixed subject we are also going to use placeholder curly brackets and we are going to call it subject okay version one you can see that the subject of the email has disappeared so let's also add it here you can see that there is an error in the data this is because every variable every different placeholder needs to be separated by comma so if you see error like this just to make sure just make sure to check whether you have commas whether you have all the quotation marks okay so we have a nice looking template with placeholders so now the next step will be to get this information into placeholders from our air table so the first step will be to create a send email button we're gonna select field button we're gonna call it send email and in our case what the button does it basically opens a url and this url will be a web hook to which will send the information about each role now the question is how do you get a url to send this information we need to create a web hook and for that we'll use integromat integromat is a software that allows to integrate easily different apis so you can go check out their website and start with a new scenario here so skip them enter page and start by creating a new hook here you select a custom web hook and add a new web hook that will be used for this particular purpose we're going to call it send emails via secret okay so now you have a email of email now you have url you can copy this url over here and go back to send grid and then insert that url here but you have to make sure that you're putting quotation bracket because this is a text okay and now at the end of this url you're going to make a question mark and then write record record id equals and then we are going to use ampersand and we are going to find the record id of this particular row by using the record id function okay so let's go back to integrate let's click ok and let's start this scenario let's press run once and let's go back to our table and now the moment when you click the button it will open a new url new window with the record id of the record that we have selected so going back to integromat you can see that we have retrieved here that information about that particular record we could add all the other information that we need to the url inside of the button here and we could do it directly here but it's actually easier and faster to use airtable module to take the record id and retrieve all the other information that are needed inside of our table so in this case inside of integromat so in this case let's go to airtable and let's select get a record okay here you will have to first add the connection to the airtable which is fairly straightforward just requires the name of the connection and your error table api key once this is done select the relevant base and select the table from which this information is coming from and now you will use the record id that you have received from the first step okay so let's test whether it works let's click run once and let's trigger a new record for bob accept it we can close the window and you can see that we have received this information from from airtable the connection was successful and here we have retrieved all the information from that particular record so now we can use this in the next steps okay this is the place when we will add the send grid module and in this case we are going to use for the maximum flexibility we are going to use make an api call here again you need to add a connection to send grid and you click on the add and then you put the api key for sendgrid api create for sendgrid can be found in the settings so let's save this here let's go back out of this template clicking on settings and api keys will allow you to create new api key you can go ahead and just select the full access as it's faster easier or you can specifically select permissions here but full access will work fine okay once you enter the api key here your connection is created and now what you are going to do is going to send you're going to fill out the url the url will be mail slash send we need to remember to change the method from get to post and now the most important part is the body of this request to send to sendgrid so i will copy paste the body that you can also find in this description of the of the video it will be a formatted json okay it looks a little bit cryptic over here but do not worry let's copy it again from here and let's use one of the online json formatters let's say jsonformatter.org or you can find any other json formatter just so it's easier to see than inside of integromat let's let's paste this json here so it's easier to see okay so now we have that json nicely formatted so you can see with colors what are we talking about okay so the first step is from email from email needs to be an email that is verified by sendgrid that comes from your domain this is something that you can do in sendgrid inside of the settings and inside of the sender authentication okay so this will be your email and your name here you can also specify the reply to domain um sendgrid will not accept any replies so here you can place another email instead let's say info head if you would like to receive replies from that email the next step is to adjust the template id the template id is something that you find inside of the dynamic templates once you go to the template and here you can copy paste the id of the template okay next step will be the personalization in this case let's keep it as for the safety to try let's keep it as your own email first so i will do track later i'll show you how to use this in a dynamic way this is the topic of the email so let's keep it like this this is basically the part where the dynamic template starts so let's go back to the cell grid let's open the send grid and here inside of our test data this is the dynamic template data that will work inside of cengrit so let's copy paste this information and let's replace what i had here in the template okay and at the bottom we have unsubscribe groups for the time being let's ignore the unsubscribe group so i'll just delete those groups from from here and i need to also delete the last comma so there is no orphan comma at the end okay so now once you click format beautify you can see that it all processes correctly means there is no errors so you can copy this data from here and from here doesn't really matter you can now copy this back into integromat okay and this is where we will start substituting the data so the first thing once you see over here so for the personalization tool for the email you will select the email that comes from every table so email address make sure that you're testing this first on your email not the customer not to irritate people with too many emails and also don't test it on fake emails because it will affect your ranking in sendgrid when you have too many bounce emails for the name we're also going to use the first name for the subject we are going to use the subject line that we have created and then for the first name that is the same and for the text we are going to use the dynamic text that we have created so let's start this way first okay so let's give it a go and let's make the first run so let's start run once now we need to trigger this and we'll receive email for bob on to info at business automated with this subject really appreciate and so on let's click you can see that execution was successful here we got code tool2 means message was scheduled for delivery and let's search this in our inbox okay and this is our email that we have just received with the subject and so on and now let's add unsubscribe group as you can see the default and subscribe groups are inactive right now so this is one thing that we'll have to add inside of cent crit let's go back into cent grid and inside of suppression and subscribe groups this is where you defined what type of groups you have as the emails that you're sending so that people can unsubscribe rather than from every single email from you that you give them a choice to unsubscribe from specific types of emails so you can see that here we have two unsubscribed groups which is called newsletter and product announcements so these are the numbers of those unsubscribe groups and you can also create a new unsubscribe group here create a new group and you can put the name that your clients will see what is the group for those particular emails okay and now those unsubscribe groups needs to be added inside of send grid in integromat so let's go back to our execution let's take this information let's just copy paste it here so it's a little bit easier to see so here we have the template id and at the very bottom behind the last one we need to add a comma and we need to add unsubscribe groups and here we need to put the number of the default group or sorry the number of the group that this email belongs to and here the numbers of all the groups that you give your customer choice to unsubscribe from so you can see this is one eight five one seven one eight six so these are the two groups that they can unsubscribe from okay so everything looks correct there is no error so means the structure of the json is correct let's copy paste this again go back to integromat copy paste over here okay let's press run once let's go back over here and let's maybe customize the subject a little bit so we will call the subject make a subject the formula say ampersand to connect different strings well come to the club okay this way you'll see that the subject change as well okay accept it we can see that the succession that the execution inside of an integromat was successful and let's find this email as well now you can see that we received email called welcome to the club and at the very bottom you have unsubscribe group so either i can administer unsubscribe from all the groups or i can select unsubscribe preferences and this is where you give your customers choice to opt out of selected selected groups okay let's add two more things to integrate so the first will let's respond to our url call to confirm that this email was successfully sent we'll use for this webhook response status 200 200 is a code for a successful reply and here we'll send we'll say email successfully sent okay and let's also get a visual confirmation in every table that this email has been sent so let's update here a field let's create a new field called status single select and it will have an option email sent so now we can add airtable update a record select the correct table and let's use the record id either from the step two or step one but let's use the last step so we're updating the correct record for sure so this is step two here what we're going to do in the status we're going to write email set if you have not created this status inside of every table yet it will cause an error because it does not exist unless you select smart links so you'll be able to create any other status email set successfully okay and let's run once and let's send another email to bob you can see reply here from the webhook execution here also was successful and we have the confirmation here that this email was sent out now depending on the use case you might want to click individually for each email to make sure that you are sending it out but sometimes you might want to send out more emails in a batch so for that there is a different way how to do it in this case you would do additional field called emails to be sent and we are going to call it send email and this will be a notification for ourselves that if we write send email this should be the email that should be sent so we can select send send let's just delete this confirmation over here and what we would do we would create a separate view and filter out only the emails that we have selected to be sent but at the same time also make sure that once those emails have been sent they are disappearing from this list so the status should be empty is empty okay and let's call it emails to be sent now going back to integromat here this scenario is ready we can basically start it and activate it and let it run so on the press of the button the scenario will start sending emails or we can also go back and we can clone this scenario and instead of web hook in the beginning we'll use a different module we will use search search records let's change the start from the webhook to here we can now delete the webhook it's connected here to the start and for search records we'll do very simply search all records within specific view and in the view we'll select emails to be sent okay let's just test it first to see what it returns so let's click here let's unlock this let's connect this from the next module and let's test the individual module here okay we see that we have received two bundles which matches what we wanted to send over here so now what we are going to do we are going to connect this to the next module instead of this record id we will be using record id from the first from the module number six the one that starts this scenario let's click ok and we don't need the webhook response right now so we can delete this module everything else stays the same and we can run once to execute all of them or we can set a schedule and we can be checking that particular view let's say daily or every other day of the week or every 15 minutes if we want for this case we'll just manually run it once so that you can see what happens so let's click on once and you can see for every email found there will be a separate execution and when we come back there will be no emails in the view because they all have been sent out and marked as sent successfully over here you can also see that i have received another email over here so everything worked out fine now one more covet to this email what can happen is that in case you are having a quotation mark inside of the text this would break the json so this would basically destroy the structure of the json inside of inside of integromat because when the computer sees quotation mark it would think that this is the end of the string so you will not see quotation mark inside of names but it can happen to be that there's quotation mark in a subject so you can see that here i basically have placed quotation quotation mark for this particular email so let's just put more quotation marks let's delete this one here and let's show you what what will happen oh actually what happened was a different case if there is no record found in the view because we did not send send email if there is no record in that view to avoid errors because our table is not finding anything because there is nothing found to be found you need to set a filter and the filter will be total number of bundles does not equal does not equal to zero okay let's test it again there's nothing to be sent at the moment you can see it stops over here okay let's go back and let's send this email and you can see there was an error in inside of sendgrid because it could not properly process the request that we have been sending because of all those additional quotation marks that basically destroy uh fork the computer understanding of a json json structure okay so let's close this one here and to avoid this we will have to do following things so we have to add a module which is called json and use transform to json so this object transform anything into json format which means for a string it basically wraps it in escape clauses so it will not break the json okay let's select text and you can basically see what happens over here let's unlink this part for the time being you can see it basically has created a string with additional backslashes that escape all the quotation marks so now what we can do we can go back to linking everything together and right now instead of text we can actually delete the quotation mark because the text from the json transformer already comes with the quotation mark so we can put the json string over here and now we can click ok and let's run once now you can see that this has been successfully processed it has been marked as sent and i have also received this email with quotation mark here inside okay if you encounter any problems just always make sure to check whether the json structure is having all the closing brackets or whether it's having all the quotation mark and if it's not missing any commas or if it doesn't have too many commas so formatters like this will be very helpful for you because you can see that there is an error and it's not possible to process and it also gives you which line the error is located so that's going to be very helpful and it was you can see that it was expecting end of the line like this so he gives you a hint how to fix it and how to correct it okay i hope this video was useful for you guys and if it was please subscribe for more business automation content [Music] you
Info
Channel: Business Automated!
Views: 899
Rating: undefined out of 5
Keywords:
Id: rxqgH2bFDTs
Channel Id: undefined
Length: 27min 50sec (1670 seconds)
Published: Sun Jul 18 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.