How to create transactional Viber template
In Messaggio, messages are created and sent using registered Viber templates. To create one, go to the Templates section, select the Viber channel, and choose the Transactional template type.
Template Requirements
Creating a Template
Sending Template Messages
Using Variables
Restrictions on Links
Template Requirements
A transactional template may contain:
- up to 1000 characters;
- up to 8 variables;
- each variable value may contain up to 125 characters.
Variables must be enclosed in double curly braces:
{{name}}
{{account}}
{{debt}}Restrictions:
- the same variable may be used multiple times within a template;
- a transactional template cannot begin or end with a variable;
- there must be at least one space between the first or last variable and the surrounding text;
- two variables cannot appear consecutively without text between them;
- an example value must be provided for every variable;
- an OTP template cannot begin with a variable;
- an OTP template must contain the
{{pin}}variable.
Example template:
Hello, {{name}}.
Your outstanding balance for account {{account}} is {{debt}}.
Please settle your outstanding balance during the current billing period.Creating a Template
To create a template:
- Go to the Templates section.
- Select the Viber channel.
- Select the Transactional template type.
- Enter the template text.
- Add variables manually (for example,
{{name}}) or use the Add Variable button. - Provide an example value for each variable.
- Save the template.
- Submit the template for moderation.
After the template is created, its details page will display:
- the Template ID;
- the names of all variables;
- example values for each variable.
This information is required when sending messages through the API.
Sending Template Messages
To send a template message, specify:
- the registered Viber Template ID;
- values for all variables used in the template.
Example request body:
{
"recipients": [
{
"phone": "123456789"
}
],
"channels": [
"viber"
],
"viber": {
"from": "ViberName",
"label": "transaction",
"content": [
{
"type": "template",
"template": {
"template_id": "b9gff5f38b6c0961",
"parameters": {
"name": "Alex",
"account": "19888-2",
"debt": "80 RUB"
}
}
}
]
}
}If the template does not contain any variables, only the Template ID should be provided. In this case, the parameters object must not be included.
Using Variables
Variables are passed separately from the template text.
Template:
Hello, {{name}}! Your order has arrived.Parameters:
{
"name": "Alex"
}The recipient will see:
Hello, Alex! Your order has arrived.
Restrictions on Links
Links and full domain names cannot be passed as variable values. Messages containing them may be rejected by Viber.
Incorrect example
Template:
Website: {{site}}Parameters:
{
"site": "messaggio.com"
}In this example, the entire domain name is passed through a variable, which is not allowed.
Correct example
Template:
Website: {{site}}.comParameters:
{
"site": "messaggio"
}The recipient will see:
Website: messaggio.com
In this case, the variable contains only part of the text, while the domain suffix is part of the template itself, so the message passes validation.