Msg91 Help Doc
Email
Personalize Emails with Handlebars in MSG91

Personalize Emails with Handlebars in MSG91

What is Handlebars and How to Use It?

The Handlebars feature in MSG91 allows you to create personalized and dynamic email templates by inserting variables and applying logic directly into your content using {{handlebar}} syntax.
This makes it easy to customize your emails for each recipient based on their name, behavior, or order details—without needing to write multiple templates or manually edit content.

Example Use Case: Order Confirmation Email Using Handlebars

Objective:
Send a personalized order confirmation email that dynamically includes the customer’s name and lists all the items they purchased, with quantity and pricing.

User Scenario:
Riya places an order on your eCommerce website. She buys:

  • 1 Black Dress – ₹1,499

  • 2 Lipsticks – ₹299 each

Instead of hardcoding product details or creating different templates for every order, you use Handlebars to dynamically populate the data.

Data Sent to MSG91 (via API or platform)

"first_name": "Riya",
  "order_id": "ORD10293",
  "order": {
    "items": [
      { "name": "Black Dress", "quantity": 1, "price": 1499 },
      { "name": "Lipstick", "quantity": 2, "price": 299 }
    ]
  }
}

Handlebars-Based Email Template

<h2>Hello {{first_name}},</h2>

<p>Thanks for your purchase! Here are your order details:</p>

<h3>Order ID: {{order_id}}</h3>

<table width="100%" cellpadding="10" cellspacing="0" border="1">
  <thead>
    <tr>
      <th>Product</th>
      <th>Qty</th>
      <th>Price</th>
    </tr>
  </thead>
  <tbody>
    {{#each order.items}}
    <tr>
      <td>{{name}}</td>
      <td>{{quantity}}</td>
      <td>₹{{price}}</td>
    </tr>
    {{/each}}
  </tbody>
</table>

<p>We hope you enjoy your purchase. </p>

Output Received by Riya

Hello Riya,

Thanks for your purchase! Here are your order details:

Order ID: ORD10293

Product        | Qty | Price
-------------------------------
Black Dress    |  1  | ₹1499  
Lipstick       |  2  | ₹299  

We hope you enjoy your purchase. Hello Riya,

Benefits of Using Handlebars

Without Handlebars

With Handlebars in MSG91

You send each order email individually

Use one dynamic template for every order.

Multiple emails flying everywhere - hard to track issues

Always accurate and personalized using live data.

Credits wasted sending separate emails for each order

Save credits — one smart email covers everything.

1. Log in to Your MSG91 Email Account

Open your MSG91 Dashboard.

2. Go to Templates and Click “Create Template”

Navigate to the Email section → Templates → Click Create Template.

3. Choose “Start from Scratch” or Use AI

You can either:

Build a new template from scratch, or

Use “Generate via AI” and then enhance it with Handlebars

4. Insert Handlebars in the Email Body

Use Handlebars directly in your HTML editor to dynamically display personalized content based on the order data.

5. Test Your Template

Click Preview or use sample JSON data to see your template in action. MSG91 will render real-time results based on your test data.

6. Submit for Approval and Launch

Once your template is ready:

Submit for approval.

After approval, use it in your transactional flows or campaigns.

Done! Your personalized template is live.

Why Use It?

Dynamic, personalized emails at scale

Great for order updates, cart recovery, offers, and more

Compatible with automation and transactional flows

Need Help?

If you’re unsure about your data format or template logic, our team is here to assist.

Email: [email protected]

Live Chat: Available on MSG91 Dashboard

Prev