Template messages
With template messages, you can craft and store rich messages that can easily be sent to your users. This functionality can be leveraged to create a set of "canned messages" or "agent saved replies" that can be reused by multiple people in your company.
Creating a template
A template contains two parts: the template name, and the template message. The name is used as a reference to identify your template and must be unique within your account. The message can be any type of structured message that you would like to reuse and send to multiple users.
To create a template, use the Create Template API:
curl https://{subdomain}.zendesk.com/sc/v1.1/apps/{app_id}/templates \
-X POST \
--user '{key_id}:{secret}' \
-H 'content-type: application/json' \
-d '{"name": "example_template", "message": { "role": "appMaker", "type": "text", "text": "This is an example" } }'
Sending a template message
Templates can be sent using the dedicated shorthand syntax. To send a template, use one of the methods below to include the syntax in the text
property of a message, and the message will be replaced with the template's content instead:
%((template:example_template))%
An alternate syntax is also available in case a conflict occurs between the previous syntax and an external templating language: %{{template:example_template}}%
.
If additional text is included alongside the template syntax, two messages may be produced as a result. The first message will contain any text that precedes the template syntax, and the second message will contain the template content. Any text that follows the template syntax will be ignored. Try sending a template with leading text:
This is my example template: %((template:example_template))%
Sending using the agent composer
Agents can send templates directly by using the syntax in the composer when replying to a messaging ticket:

Sending with a macro
You can also create a macro that contains the template syntax to allow agents to quickly send template messages for common use cases. For example, you might create a macro to send a carousel message featuring some of your best selling products.
Use the Comment/description action when creating your macro:

Sending with the API
To send a template with the API, use the Post Message endpoint and include the syntax within the text
property of a text message:
const apiInstance = new SunshineConversationsClient.MessagesApi()
const data = new SunshineConversationsClient.MessagePost()
data.author = {
type: "business"
}
data.content = {
type: "text",
text: "%((template:example_template))%"
}
await apiInstance.postMessage("{appId}", "{conversationId}", data)
Sample templates
We've created a set of sample templates so you can test sending various structured messages without having to create your own templates first. You can quickly try out sending rich messages using these pre-created samples. Simply send a message including the following syntax to try each template:
- Compound message:
%((template:smooch_tmpl_family_basket))%
- Carousel message:
%((template:smooch_tmpl_things_to_do))%
- Form message:
%((template:smooch_tmpl_lead_capture))%
- Quick reply:
%((template:smooch_tmpl_rate_conversation))%
- NPS survey:
%((template:smooch_tmpl_nps_survey))%