Send Personalized E-mail from React Application

Published October 30, 20214 min read

Send Personalized E-mail from React Application

Benefits of personalizing email content are that they are more likely to be opened by recipients, recipients are more likely to read them in full, and they are often shared with other people - because they show up as more personal emails. Personalized e-mails are not new, but it is time to take those personalized e-mails to the next level. One of the newest technologies that can be used for this purpose is image generation. In this article I will show you how to send an e-mail with personalized image to your customer once he makes some action in your application or website. I will use Integromat to take advantage from no-code automations.

Create Integromat webhook

I started from creating a scenario in Integromat and adding a webhook module. The module generates an unique webhook URL where I can send my requests from server or from frontend application. The CORS won't be a problem here because Integromat accepts requests from frontend applications.

Integromat webhook configuration

Send request on click

Let's go to the code part! I started from creating a simple <a href=""/> tag in my React application. It looks pretty standard I added href attribute with link to some article and custom onClick method.

<a href="https://bannerly.io/blog/posts/multi-language-image-variants/"
   target="_blank"
   onClick={onLearnMoreClick}
   className="btn btn-link d-flex align-items-baseline">
    <span>Learn how to quickly generate multi-language images</span>
    <i className="far fa-arrow-right ml-2"/>
</a>

The onLearnMoreClick method will be invoked once somebody clicks the link. The onLearnMoreClick will send a POST request to endpoint generated by Integromat. I used axios but you can use any other library to do this. If you don't want to use any library check Fetch API.

const onLearnMoreClick = () => {
axios("https://hook.integromat.com/your-webook-url",
  {
    method: "POST",
    data: {
      firstName: account.firstName,
      email: account.email
    }
  });
}

We are passing two values which we will need in next steps:

  • firstName - user first name,
  • email - user e-mail to send him personalized e-mail.

Edit image template

I used existing template from Bannerly template library. However, if you want, you can create your own template using template editor in Bannerly. We will edit the top component with 'Hey Jakub!' text, and we use Integromat to replace the text for every webhook request.

Example template for coupon code and image generation

Configure Integromat scenario

Below you see a whole Integromat scenario where I connected everything together. The scenario is self-explanatory, we have 4 modules:

  • Webhooks module - receive requests from application
  • Bannerly - generate image based on data from request
  • HTTP - download the image from Bannerly
  • Email - send e-mail to a customer

Integromat scenario with image generation and SMTP

Add text to image using Bannerly module

HTTP module is only for downloading image from received URL from Bannerly module. Download generated image with text using HTTP Integromat module

Thanks to the HTTP module we can add the image itself instead just the URL. Send attachment using Integromat email module

Let's test!

Click 'Run once' button in created Integromat scenario and then click link to open the article from which we created in the first section. Now the request from our frontend application should be sent Integromat Webhook module, after that data will be passed to Bannerly module where a new image will be generated. Bannerly will take your template and replace title on the image and return a link with ready to download image. Next, HTTP module will download the image generated by Bannerly module and add it as an attachment in the last step. In E-mail module we composed a simple e-mail message which we sent to the user who clicked the link!

example email with personalized image

Presented Integromat scenario is just a simple example what you can do with batch image generation. Possibilities are unlimited! Your flows can be much more complex, you could generate an image for every occasion with Bannerly, for example you could add user avatar to make it more engaging. Image that your customer gets a personalized image with his name and profile image! Have fun with Bannerly!


Share article

See all articles

Design. Automate. Scale.

Free plan • No credit card required • Get started in minutes