Sending a template via API

Sending a template is described in the API documentation in the /sendTemplate method.

You can also send a template from the 'Developer Cabinet' → 'Test Requests' section of your personal Cabinet. 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.

СвойстваОписание

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

index: the order in which the button appears in the card.

0 is for the first button, 1 for the second.

Warning: if you have the first QUICK_REPLY button in the template and an URL button after it, then index for the URL button = 1, even if you have omitted the first button in the body of the request. The position of the buttons should be the same for each card.

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.

How to send the ‘Catalogue’ template

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.

 {
      "type": "button",
      "sub_type": "CATALOG",
      "index": 0,
      "parameters": [
        {
          "type": "action",
          "action": {
            "thumbnail_product_retailer_id": ""
          }
        }
      ]
    }
Example of sending the ‘Catalog’ template

Because the template did not contain a variable description in the text, object with type "BODY" is omitted when it is sent.

POST https://api.1msg.io/{{channel}}/sendTemplate
Content-Type: application/json
Body: {
  "token": "{{token}}",
  "namespace": "{{namespace}}",
  "template": "catalog_services",
  "language": {
    "policy": "deterministic",
    "code": "en"
  },
  "params": [
    {
      "type": "button",
      "sub_type": "CATALOG",
      "index": 0,
      "parameters": [
        {
          "type": "action",
          "action": {
            "thumbnail_product_retailer_id": "0002" // A thumbnail of this product will be sent. You can send 'thumbnail_product_retailer_id': ''. The product image of the first product in your catalogue will be used.
        }
      ]
    }
  ],
  "phone": "+556123122026"
}
        

Last updated