Api reference MessageFlow
  • Welcome
  • Introduction
  • Authentication
  • REST clients samples
  • Long running actions - Retry-After header explained
  • Input compression
  • Using filters
  • Dynamic e-mail content
  • SMS Billing
  • Incoming webhooks
    • Steps to configure webhooks
    • Step 1: Identify the events to monitor
    • Step 2: Create a webhook endpoint
    • Step 3: Handle requests
    • Step 4: Test that your webhook
    • Step 4: Test your webhook
    • Step 5: Save your webhook configuration
  • External resources
  • Current Version
  • License
  • Groups
  • Contacts
  • Emails
  • Sms
  • Blacklist
  • Campaigns
  • Pushes
Powered by GitBook
On this page

Dynamic e-mail content

Our API allows for inserting dynamic content into Email templates. This removes the need to create individual templates for particular recipients. All you have to do is create a single, universal template and use an API request to insert relevant data.

Email template

The options available with templates are:

Simple content insertion If you wish to use a predefined variable in a template and actually display its value:

<html>
    <body>
        Dear {{ name }},
        We are pleased to inform you that …
    </body>
</html>

Conditional instructions If you’re unsure whether the variable will always be set or would like to differentiate a part of the template depending on the variable’s value, use conditional instructions:

<html>
    <body>
        <div data-gb-custom-block data-tag="if">

            Dear {{ name }},
        

<div data-gb-custom-block data-tag="elseif" data-0='male' data-1='male'></div>

            Dear Sir,
        

<div data-gb-custom-block data-tag="elseif" data-0='female'></div>

            Dear Madam,
        

<div data-gb-custom-block data-tag="else"></div>

            Dear Sir/Madam,
        

</div>

        We are pleased to inform you that …
    </body>
</html>

Conditional instructions can contain the following operators: ==, !=, <, <=, >, >=

Loops Our interface also allows for passing on datasets (product lists, for example) and dynamically generating content for each of its elements:

<p>List of available products:</p>
<ul>

<div data-gb-custom-block data-tag="for">

<li>
    <b>{{product.name}}</b> - <span>{{product.color}}</span>
</li>

</div>
</ul>

Passing on data used in the dynamic content

Data can be passed on for both a specific recipient, using the vars field, and an entire request using globalVars field:

{
  "subject": "Test email subject",
  "smtpAccount": "1.test.smtp",
  "from": {"email": "sender@acmedomain.com", "name": "Sender Name"},
  "globalVars": {
    "products": [
      {
        "name": "skirt",
        "id": 1,
        "color": "green"
      },
      {
        "name": "hoodie",
        "id": 6,
        "color": "red"
      }
    ]
  },
  "to": [
    {
      "email": "jane.doe@acmedomain.com",
      "messageId": "janedoe00001id@acmedomain.com",
      "vars": {
        "name": "Jane",
        "sex": "female"
      }
    }
  ]
}
PreviousUsing filtersNextSMS Billing