Templates

Sometimes it will be more convenient to separate the content of a message from the API call to send it, such as when this is changed often or a non technical team is responsible for the content. To do this you can use our Templates feature.

Setting up a template

To setup a template is very simple, just do the following steps:

  1. Open the Templates page from the left hand menu in the portal (highlighted in green below)
  2. Click the Create button (highlighted in yellow below)
1919
  1. Now enter a Template Name which describes what the template is used for
  2. Optionally enter a Template ID or just let the system generate this for you using the Template Name; the Template ID is used to refer to the template in API calls.
  3. Optionally add a Description to describe the purpose of the template.
542
  1. Click Next to start creating the templates content.
1203
  1. Create your template content by add one or more message parts, using text, merge fields and media. Merge fields will be populated from the profile data the template is being sent to, or left blank if no data is found.
  2. Click Create to save the template.

Using your templates

You can use your templates by simply adding the templateId field to your Enterprise Communications API call instead of specifying bodies or message parts directly. See the example call below:

🚧

Templates or content but not both!

You cannot use the templateId field as well as the body or messageParts fields in a "One" API call. You must choose one or the other!

{
  "templateId": "promotion_message",
  "to": {
    "phoneNumber": "44123123123"
  },
  "channelOptions": {
    "sms": {
      "from": "dotdigital"
    }
  },
  "rules": [
    "sms"
  ],
  "metadata": {"data": "My important data"}
}

In addition to using templates with the Enterprise Communications API they can also be used in the chat tool for canned responses.