Now that everyone knows what ChatGPT is, the blogs and LinkedIn posts are flying around you. The possibilities are endless, with loads of pre-made prompts that turn your idea into an AI-executed reality. But entering a prompt in ChatGPT remains limited to that functionality as well. As a marketer who prefers to automate everything, we set to work to enrich our emails with ChatGPT. The result? A personalized poem in an AI-powered email that is completely tailored to its recipient. Below, you can read what that process looks like, and we’ll show you how you can apply this to your emails as well.
What did we need?
- A form, using the module from Mail+ ;
- A landing page, also from Mail+;
- A link between the form submission and Spotler Flowmailer, we used Zapier for this;
- You guessed it right from the previous bullet point: Flowmailer ;
- A license with an AI tool, in our case OpenAI;
- A little understanding of webhooks and APIs, but we’re happy to help you with that too 😉.
In this simple example we trigger an email in Flowmailer from a Mail+ form, via a webhook. That email is built up based on data from the form and enriched with an AI-generated poem. We wanted to keep what we ask for in this form as simple as possible, but we wanted to request enough data to be able to personalize it. For example, we only asked for e-mail address, name, language, company, and the industry in which the company is active.
Step 1: Processing form data
When you collect form data in Mail+, you naturally want to be able to use it in the rest of the process. To forward that data from one system to another, we used a webhook. You can find this in the ‘Processing’ section of Mail+ forms. Here you set an address (see step 2) where the data should go – a POST request. It is also important to map the data from the forms, which ensures that another system can process your data again.
Data mapping really means ensuring that database fields match. Does system 1 handle first names as ‘firstname’ and system 2 as ‘fName’? Then during the mapping, you ensure that system 1 sends the first name as ‘fName’ to system 2, with the value being the data that system 1 knows as ‘firstname’. That looks something like this:
Now that the form is ready, the next step is to make it available on your website. In our case a simple landing page, but you can also easily integrate Mail+ forms with your website .
Step 2: Process the data and trigger an email
Now that the form can receive and forward the data, it’s time to let that second system do its job. If you are an advanced API specialist, you can skip the following, but for ease of use we have chosen to hang Zapier between the systems.
What is Zapier?
Zapier is a tool that allows you to link different systems together and add actions to them, from a user-friendly interface. Learn more about the link between Mail+ and Zapier .
Setting a trigger in Zapier based on a webhook (‘Webhooks by Zapier’) generates an address that you can use in step 1 . The webhook URL consists of a series of unique numbers and letters, as in the (modified) example below:
From Zapier to Spotler Flowmailer
In Zapier, supported by the form data, you can have a message sent by Spotler Flowmailer. Flowmailer then allows you to transform that data into a beautiful, personalized email. To do that, we first had to make sure that all that e-mail traffic is secure.
To be able to trigger your emails from Zapier in Flowmailer, you must first establish a connection with your account. For this you need your account ID and you need to create a Source . In Zapier we have set up this process in two steps:
- Get authentication from Flowmailer to be able to send the email through your account;
- Deliver the data with the authentication keys generated by Flowmailer.
Unique authentication keys (OAuth) are created for every email that needs to be generated – to prevent someone from getting their hands on them and emailing you using your account. The response of the POST request to Flowmailer contains the following:
As you can see in the image above, each key expires after 60 seconds. We then use the key itself ( access_token ) in a call to Flowmailer to send a message.
Deliver the data to Flowmailer
In the next step, you use the access_token to be able to offer an e-mail in the correct account with the correct authentication. In that POST request, you process all the data you want to send to Flowmailer:
Based on the data or the source of the message (in this case Zapier), Flowmailer knows exactly which steps it needs to take to format and deliver your message.
Step 3: Enriching the email data with Artificial Intelligence and a design
Now you have prepared data from your Mail+ form to be used in other tools. In an earlier step we created a Source in Flowmailer, which we will now use.
In this case we call the Source ‘Event API’ – because it was made specifically for, you guessed it, events. The moment data arrives via this source, you can indicate in Flowmailer what should be done with it via Flows: the way to set up your e-mail journeys.
Push the data through a Flow
When creating such a Flow, you can select on which source or other condition this Flow should be triggered. For example, you can also trigger a different Flow on specific data within a message. For now, we’ll keep it a bit simpler and all messages from the ‘Event API’ source will go through this Flow:
We then indicate in the Flow what should be done with your message, step by step. We have only provided some form data, so we want to connect to ChatGPT (the ‘External Data’ step) and add a template where we can display that data. You can do that easily by dragging the appropriate ‘Flowsteps’ onto the timeline:
Get started with Flowsteps
Within Flows you work with Flowsteps; the steps a message must undergo before it is delivered. In our case, we put an External Data step on the timeline that allows external data to be retrieved, posted somewhere, or updated during the sending process. For example, we can ask ChatGPT to write us a nice poem:
Using ChatGPT in your transactional email
With a simple prompt, you can instruct ChatGPT to write a personalized text with a simple prompt. Please note we have explicitly requested permission to have personal data processed by ChatGPT. If you do not want to work with personal data, you can always use other data, such as ‘language’, ‘company’ or ‘industry’.
The attentive viewer will see in the request body that we are using model ‘text-davinci-003’ and not the latest version of GPT . At the time of making this example, gpt-4 was not yet available – but Davinci is fine for this use case 😊.
The prompt is simple:
This prompt gives you a short poem and ends each line with an HTML break, making it easier to use in your email. For example, I got:
Spotler, his home,
He works hard and smart.
He learns a lot,
And never stands still,
He is a tech hero,
With a big will.”
Although I do not expect that we have found our new Shakespeare with ChatGPT, these types of AI-generated texts do of course offer opportunities to hyper-personalize your content. But first make sure that this content can also be processed in your e-mail.
A design sauce over all that data
The finishing touch for any email is its design. That bucket of data is nice, but without a nice wrapper around it, no one will remember your emails. In Flowmailer you handle this super efficiently with the smart template composer. This allows you to make one template in multiple languages, without making different variations. Learn more about it here .
For this example, we created one leading template that is filled with texts from Flowmailer’s Language Packs. Based on the language indicated in the form, the template is filled in with the correct text. For example, we created these three variations in Dutch , German and English with just one template:
How we turned simple data into an AI-powered email.
With the right tools, you can create a personalized email from just a little bit of data. In this example we have chosen a limited use case, but one that offers sufficient tools to reconsider which data you request and what you do with it in your emails. Do you want to try this for yourself? Please contact firstname.lastname@example.org or be inspired by one of our product demos .