Everyone knows that emails perform best when you personalize the email based on the person you are sending to. This post will show you how to go beyond simply using lead and company tokens in your emails and instead use ChatGPT to create fully personalized email subject lines and bodies.
There are many different scenarios where we could use ChatGPT to personalize our Marketo emails. For example, two examples that come to mind right away:
It is the second scenario here that forms the basis of this blog post and my testing.
I was quite impressed by ChatGPT’s performance when it came to creating an email snippet to insert in the email body. I think the Coca-Cola example below is a good example of how personalized ChatGPT can make our email content just by providing it with a website.
Personalizing an email for Coca-Cola
From my experience, the subject lines returned from ChatGPT are very repetitive and generic (see the Google sheet linked below). In contrast to the email body where there is a larger character range for ChatGPT to personalize the content I think it is expected that since the subject line is so short it is hard for ChatGPT to use the information it finds from the website.
While the subject lines are generic and repetitive they are at least personalized to include the company name that ChatGPT finds from the website. This is useful when you do not have information about the person’s company in Marketo yet.
As always the most important part of any project involving ChatGPT is to test and refine your prompt so that you are getting the outcomes you desire.
To make this easy you can:
Using the prompt below as an example there are a few important points to bear in mind so that the output is in the best format to use in Marketo emails:
Write an email snippet for a person who works at the company with the website {{company.Website}} speaking to their company’s use case and how The Workflow Pro can solve their company’s pain points. Write from the perspective of the The Workflow Pro brand, make the snippet around 100 words in length, using line breaks in the form of <n> after roughly every 50 words if needed.The snippet you provide will be inserted after the greeting and before text encouraging this person to compare us to competitors so you should not include a greeting or any other text besides the snippet. If you cannot find out any information from the website then return NA.
Once again it is important that the output from ChatGPT is ready to be inserted into the email without any modification. When I first tested this prompt ChatGPT was putting inverted commas around the subject line or returning the response in this format “Subject line: xxxx” so I had to explicitly tell it to exclude quotation marks and any extra words or characters.
Write an email subject line for a person who works at the company with the website {{company.Website}} speaking to how The Workflow Pro can be valuable for their company. It is important that you only return the subject line with no quotation marks or any extra words or characters. If you cannot find out any information from the website then return NA.
Once we have refined our prompts for the email body and the subject line we need to create fields to store the text returned from ChatGPT for these entities.
Looking at the docs we can see that a “String” field will work to store the subject line since a string can hold 255 chars. Using the same docs we can see that we will need a “Text Area” field (30k character limit) to store the email body.
Creating a field to store ChatGPT email body
Now we will need to create 2 webhooks:
See the Making ChatGPT Requests Using Marketo Webhooks section to see how to set up a webhook to make requests to ChatGPT and store the output in a Marketo field. Notice how company tokens are used in the payload body to send lead information to ChatGPT.
Webhook to get a subject line
Mapping ChatGPT response to the subject line field
Using the ChatGPT content fields is as easy as referencing the lead tokens within your email subject line and email body. However, in the case that ChatGPT cannot find any information from the website and returns NA we cannot rely on using the default value associated with the lead field token because this will only insert the default when the field is empty and not when the field is “NA”.
Defining email script tokens
We need to use email script tokens to insert default text when the field is “NA”. See the video at the top of the post to see how to create these tokens and insert them in your email.
Three important things to note about using the email script tokens below:
#if (!$lead.aIEmailSubjectLine.isEmpty() && $lead.aIEmailSubjectLine != "NA") #set( $a = $lead.aIEmailSubjectLine) #else #set( $a = "The Workflow Pro was named 2023 best content creator") #end${a}
For those of us not familiar with code, the script above will either return:
Using the email body field in our email is a little more complex because of the need to insert line breaks. You can test this out for yourself or take my word for it but line breaks in a text area field do not render when the text area field is used as a token in an email.
Using the email body script token
This was a pain for me to figure out how to fix and involved a while of messing around with an email script token but don’t worry I got you! All you have to do is copy the code below into an email script token and you will be ready to go.
#if (!$lead.aIEmailBody.isEmpty() && $lead.aIEmailBody != "NA") #set( $b = $lead.aIEmailBody.replace("<n>", "<br /><br />")) #else #set( $b = "After years of producing top notch content the Workflow Pro was named 2023 MOPs Content Producer of the Year!") #end${b}
The only difference between this script and the email subject line script is that this code will return the email body field with our special set of characters i.e. <n>, replaced with new line tags so that we get the line breaks we desire.
Refining your prompt using the Google sheet and process described at the start of this blog is a crucial first step before rolling these ChatGPT-enabled emails off the production floor. Since these emails will be customer-facing we want to make doubly sure that everything is working as expected so I recommend doing the following:
Flow actions for testing ChatGPT emails
List view showing ChatGPT fields
Now you can monitor the emails coming to your inbox and the smart campaign member list with the tailored view to see what values are being pushed into the ChatGPT email fields and how the resulting emails are rendering.
Once you are happy with how the ChatGPT emails are performing you can swap that “Send Alert” step with the “Send Email” step that will start sending these emails to your customers. All there is left to do now is to set up a champion challenger test to see how the ChatGPT subject line and email body perform compared to the default text that would otherwise be in this email.
Just can’t get enough ChatGPT content eh? Well then take a look at how you can use ChatGPT to:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.