Sometimes it can 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.
Set up a template
-
Log in to the portal.
-
Go to Templates and select Create.
-
Enter a Template Name.
-
Optionally, enter a Template ID, or, select the Automatically generate an ID checkbox to have the system generate this for you using the template name.
The Template ID is used to refer to the template in API calls. -
Optionally, enter a Description for the template.
-
Select Next.
-
Add one or more message parts, using text, merge fields and media. Merge fields are populated from the profile data the template is being sent to, or left blank if no data is found.
-
Select Create to save the template.
Use your templates
To use your templates, add the templateId
field to your API call instead of specifying bodies or message parts directly.
Templates or content but not both
You can't use the
templateId
field as well as thebody
ormessageParts
fields in a single 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, templates can also be used in the chat tool for canned responses.