1msg.io
Knowledge Base
Knowledge Base
  • Welcome to 1msg.io knowledge base!
  • Getting Started
    • Description and features
    • Connection and setup
  • ONBOARDING
    • Attaching your WhatsApp number to WABA — detailed guide
    • Solving problems with restrictions from Meta
  • Troubleshooting while onboarding flow
  • Obtaining the green checkmark badge
  • Template
    • Create templates
      • Create a Carousel template
      • Create a Catalog template
    • Send templates
      • Sending a template via 1MSG personal account
      • Sending a template via API
  • FLOW BUILDER
    • Basic flow builder overview
    • Building the example flow
    • Flow block types
    • Troubleshooting
  • BILLING
    • Tariffs and payments
Powered by GitBook
On this page
  • How to send a Carousel template
  • How to send the ‘Catalogue’ template
  1. Template
  2. Send templates

Sending a template via API

Last updated 12 months ago

Sending a template is described in 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.

How to send a Carousel template

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.

Example of how to send the ‘Carousel’ template

An example of a 2-card template. Each card contains a quick reply button and a url button. The media header is an image.

POST https://api.1msg.io/{{channel}}/sendTemplate
Content-Type: application/json
Body: {
  "token": "{{token}}",
  "namespace": "{{namespace}}", // Call the list of templates via the /templates method and find the namespace for the required template
  "template": "marceting_carousel_01_test", // name template
  "language": {
    "policy": "deterministic",
    "code": "en" // language from the /templates method
  },
  "params": [
    {
   /* /* Common text message. Can be omitted if there are no variables in the text. */ */
      "type": "body", 
      "parameters": [
        {
          "type": "text",
          "text": "21OFF" // variable {{1}}
        },
        {
          "type": "text",
          "text": "21" // variable {{2}}
        }
      ]
    },
    {
      "type": "carousel",
      "cards": [
        /* The first card */
        {
          "card_index": 0,
          "components": [
            {
              "type": "header",
              "parameters": [
                {
                  "type": "image",
                  "image": {
                    "link": "https://img.freepik.com/free-photo/top-view-citric-fruit-slices-table_23-2148495686.jpg"
                  }
                }
              ]
            },
            {
              "type": "button",
              "sub_type": "url",
              "index": 1,  // button position, starting from 0. Here url-button is the second in the sequence, so index=1
              "parameters": [
                {
                  "type": "text",
                  "text": "summer" // parameter in url link
                }
              ]
            },
            {
             /* Card text. Can be omitted if there are no variables in the text. */
              "parameters": [
                {
                  "type": "text",
                  "text": "10F" // variable {{1}} in the first card
                },
                {
                  "type": "text",
                  "text": "10" // variable {{2}} in the first card
                }
              ]
            }
          ]
        },
        /* Вторая карточка */
        {
          "card_index": 1, 
          "components": [
            {
              "type": "header",
              "parameters": [
                {
                  "type": "image",
                  "image": {
                    "link": "https://img.freepik.com/free-photo/delicious-background-orange-slices_23-2148231462.jpg"
                  }
                }
              ]
            },
            {
              "type": "button",
              "sub_type": "url",
              "index": 1, // button position, starting from 0. Here url-button is the second in the sequence, so index=1
              "parameters": [
                {
                  "type": "text",
                  "text": "winter" // parameter in url link
                }
              ]
            },
            {
               /* Card text. Can be omitted if there are no variables in the text. */
              "type": "body",
              "parameters": [
                {
                  "type": "text",
                  "text": "30F" // variable {{1}} in the second card
                },
                {
                  "type": "text",
                  "text": "30" // variable {{2}} in the second card
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "phone": "+556123122026"
}

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"
}
        
the API documentation