Sending a template via API
Last updated
Last updated
Sending a template is described in the API documentation in the /sendTemplate method.
You can also create a template from the 'Dev Toolkit → 'Test Requests' section in your personal account.
To send a template, you need to know the namespace, name and language of the template. To get this information, call the 'Get list of templates' method (/templates).
Some properties that can cause problems in the /sendTemplate method.
Свойства | Описание |
---|---|
In requests, you should only send the objects that you have specified in the created template. For example, if there is no HEADER in the template, do not send it. Objects are also omitted if:
Header object of type Text without variable;
Body without variable;
Quick reply buttons and number buttons are always omitted;
URL button without variable.
Header objects of type IMAGE
, VIDEO
, DOCUMENT
always contain the full link to the media document. Note that the link to the media document must contain the format of the document.
The Carousel template is only supported in the Cloud API.
Carousel template:
Has its own type - CAROUSEL
An object with type CAROUSEL contains an array of cards. It is used only for this template type
Each card contains card_index - the order of appearance of cards in the card carousel. 0 - means the first card, 1 - means the second card, etc.
The ‘Catalog’ template is only supported in the Cloud API.
Before you send a catalogue, check if you have it enabled. You can check in your personal account in 360 Dialog, or by calling the /commerce method.
Catalogue template:
In the button object, you need to write CATALOG in sub_type . The name of the button is not controllable.
In thumbnail_product_retailer_id you can write the article of the product specified in Meta. In this case, the thumbnail of this product will be used as the header image of the post. Otherwise, the product image of the first product in your catalogue will be used.
Example code part when no thumbnail_product_retailer_id is specified.
template
It's the name of the template
language
policy: write "deterministiс"
code: language from the /templates method
Object with type "body"
Text message. Can be omitted if there are no variables in the text.
Object with type "button"
You can display only buttons with sub_type ‘url’ or ‘catalog’ in the body. Other types of buttons can be omitted when sending the template