Messaging - Create SMS Template
Messaging - Create SMS Template
This page walks you step-by-step through how to use Telesign Messaging to create a custom SMS template.
Before you begin
- Make sure Telesign Messaging is enabled for your account. Contact our Customer Support Team to enable this product.
Key terms
- Components: Parts of the message content that can be defined in your template.
Layout
At the highest level, the content of templates on non-SMS channels consists of one or more components. SMS templates only have the "body" component however. This component is always required.
Variables
The text in your template can also include variables. Include a variable name in a parameter value in double curly brackets. When you send a message using a template with a variable, you can include that variable as an additional parameter. You cannot give a variable a name that matches a mandatory parameter for the template.
If you define a variable without a name ( {{}}
), the service assigns a default variable name based on the order in which it was included:
Parameter | Order | Default variable name |
---|---|---|
body.text | 1 | body_text_1 |
body.text | n | body_text_n |
You can also include a default value when you create a variable, by including it within the curly brackets after the variable name. Separate the variable name and the default value using " : ".
NOTE:
Variables are supported in all templates, not just SMS templates.
The text in the end user's message in this example is rendered as "Buy one get one free! Use code 'BOGO' at checkout on viatushop.com.":
"body": {
"text": "Buy one get one free! Use code '{{bogo_code}}' at checkout on viatushop.com.",
"type": "text"
}
"message": {
"sms": {
"template": "sms_template_1",
"parameters": {
"bogo_code": "BOGO"
}
}
}
In this next example, the text in the end user's message if the "bogo_code" parameter is not included at all is still rendered as "Buy one get one free! Use code 'BOGO' at checkout on viatushop.com.":
"body": {
"text": "Buy one get one free! Use code '{{bogo_code: BOGO}}' at checkout on viatushop.com.",
"type": "text"
}
Components
Each part of the layout has a set of available content type options.
body
This can only include text. This component is required for all templates. You can include any number of variables.
Steps
- Keep the page POST https://rest-ww.telesign.com/v1/omnichannel/templates open in another window to reference while following these steps.
- Make a request to the POST https://rest-ww.telesign.com/v1/omnichannel/templates endpoint like this:
POST /v1/omnichannel/templates HTTP/1.1
Content-Type: application/json
Authorization: Basic 12345678-9ABC-DEF0-1234-56789ABCDEF0:vjE/ZDfPvDkuGNsuqCFFO4neYIs=
Host: rest-ww.telesign.com
{
"name": "sms_bogo",
"type": "standard",
"channel": "sms",
"content": [
{
"body": {
"type": "text",
"text": "Buy one get one free! Use code '{{code_name}}' at checkout on viatushop.com."
}
}
]
}
If the request is successful, you should receive a response like this:
HTTP/1.1 200 OK
Server: nginx/1.17.7
Date: Wed, 10 Oct 2022 21:25:54 GMT
Content-Type: application/json
Connection: keep-alive
Allow: GET,POST,HEAD
{
"status": {
"code": 3800,
"description": "Request successful",
"updated_on": "2022-10-22T21:25:53.765723Z"
}
}
This response just confirms that the server received your request and is processing it. If the processing completes successfully, you should then receive a notification to your transaction callback service like this:
{
"reference_id": "B56259E45884010488343BAA15FB0002",
"name": "wa_bogo",
"channel": "whatsapp",
"language": "en_US",
"status": {
"code": 3850,
"description": "Template successfully created",
"updated_on": "2022-10-22T21:25:54.181346Z"
}
}
Search your notifications based on the "name" and "channel" properties; the combination of these two properties uniquely identifies each template. Once you receive this notification, you can begin using this template with Telesign Messaging. See the Templates Callbacks resource in Reference for more details about these notifications.
Updated 4 months ago