Usage samples: Whatsapp

❗️

Whatsapp only allows freeform text messages to be sent once a customer service window has started. A customer service window starts when a user initiates a conversation or when a user replies to a pre-approved template sent by the business.
This customer service window lasts 24 hours, and lasts 72 hours if the customer service window is initiated via a click-to-whatsapp ad.
Outside of the customer service window, only pre-approved Whatsapp templates can be sent to users.

πŸ‘

Please see ChatApps Send API for the full API reference.

Freeform messages

Text message

If you want to send a text message, your request will look like this:

{
    "user": {
        "msisdn": "+65000000"
    },
    "clientMessageId": "1234_id",
    "type": "text",
    "content": {
        "text": "Thank you for your recent purchase from TechStore! If you have any questions or need support, reply 'HELP' to connect with our support team.",
        "sms": {
            "encoding": "AUTO",
            "source": "<SENDERID>"
        }
    }
}


Text message with an image

If you want to send an image with an optional text, your request will look like this:

{
    "user": {
        "msisdn": "+65000000"
    },
    "clientMessageId": "1234_id",
    "type": "image",
    "content": {
        "text": "Welcome to Singapore!",
        "url": "https://wwww.example.com",
        "fallbackText": "We tried to send an image - but Welcome to Singapore",
        "sms": {
            "encoding": "AUTO",
            "source": "<SENDERID>"
        }
    }
}

Template Mesages

Template message with text only

Depending on the use case and content, your template submitted can be categorized as Marketing or Utility templates.

This template has 2 body parameters

{
    "user": {
        "msisdn": "+65000000"
    },
    "clientMessageId": "1234_id",
    "type": "template",
    "content": {
    "template": {
      "language": "en",
      "name": "template_name_1",
      "components": [
        {
          "type": "body",
          "parameters": [
            {
              "type": "text",
              "text": "Ana"
            },
						{
              "type": "text",
              "text": "http://example.com"
            }
          ]
        }
      ]  
    }
  }
}

Authentication template message

 {
            "user": {
                "msisdn": "+65000000"
            },
            "clientMessageId": "1234_id",
            "content": {
                "fallbackText": "",
                "sms": {
                    "encoding": "AUTO",
                    "source": "<SENDERID>"
                },
                "template": {
                    "name": "<insertTemplateName>",
                    "language": "en",
                    "components": [
                        {
                            "type": "body",
                            "parameters": [
                                {
                                    "type": "text",
                                    "text": "12345"
                                }
                            ]
                        },
                        {
                            "type": "Button",
                            "subType": 1,
                            "index": 0,
                            "parameters": [
                                {
                                    "type": "text",
                                    "text": "12345"
                                }
                            ]
                        }
                    ]
                }
            },
            "type": "template"
        }

Template message with image

This template has 1 image header and 2 body parameters

{
    "user": {
        "msisdn": "+65000000"
    },
    "clientMessageId": "1234_id",
    "type": "template",
    "content": {
    "template": {
      "language": "en",
      "name": "<insertTemplateName>",
      "components": [
				{
          "type": "header",
          "parameters": [
            {
              "type": "image",
              "url": "https://example.com/media/image.jpg"
            }
          ]
        },
        {
          "type": "body",
          "parameters": [
            {
              "type": "text",
              "text": "Mr. John"
            },
						{
              "type": "text",
              "text": "http://example.com"
            }
          ]
        }
      ]  
    }
  }
}

Template message with Location

This template has a location header and 2 body parameters

{
    "user": {
        "msisdn": "+65000000"
    },
    "clientMessageId": "1234_id",
    "type": "template",
    "content": {
    "template": {
      "language": "en",
      "name": "<insertTemplateName>",
      "components": [
				{
          "type": "header",
          "parameters": [
            {
              "type": "location",
                    "location":{
                    "latitude": "38.8693",
                    "longitude": "-77.0536"
              }
            }
          ]
        },
        {
          "type": "body",
          "parameters": [
            {
              "type": "text",
              "text": "Mr. John"
            },
						{
              "type": "text",
              "text": "http://example.com"
            }
          ]
        }
      ]  
    }
  }
}

Template message with a dynamic call-to-action (CTA) button

{
     "user": {
          "msisdn": "+65000000"
     },
     "type": "Template",
     "content": {
          "template": {
               "name": "<insertTemplateName>",
               "language": "en_US",
               "components": [
                    {
                         "type": "button",
                         "parameters": [
                              {
                                   "type": "text",
                                   "text": "landing-page.php",
                                   "payload": "landing-page"
                              }
                         ],
                         "index": 1,
                         "subType": "Url"
                    }
               ]
          }
     }
}

Interactive messages

Interactive message with reply buttons

These types of messages do not require to be submitted for template approval, similar to freeform messages. They can be sent in an ongoing conversation via our Automation Builder or any third-party workflow/chatbot builder.

This message type can support up to 3 reply buttons

{
    "user": {
        "msisdn": "+65000000"
    },
    "type": "interactive",
    "content": {
        "interactive": {
            "action": {
                "buttons": [
                    {
                        "type": "reply",
                        "reply": {
                            "title": "Option 1",
                            "id": "option-1"
                        }
                    },
                    {
                        "type": "reply",
                        "reply": {
                            "title": "Option 2",
                            "id": "option-2"
                        }
                    },
                    {
                        "type": "reply",
                        "reply": {
                            "title": "Option 3",
                            "id": "option-3"
                        }
                    }
                ]
            },
            "body": {
                "text": "Body"
            },
            "footer": {
                "text": "Footer"
            },
            "header": {
                "type": "text",
                "text": "Header"
            },
            "type": "button"
        }
    }
}

Interactive message with a list of menu options

{
  "user": {
    "msisdn": "+6593530697"
  },
  "type": "interactive",
  "content": {
    "interactive": {
      "action": {
        "button": "Book Slot",
        "sections": [
          {
            "rows": [
              {
                "id": "slot-1",
                "title": "Monday, Oct 9",
                "description": "9:00 AM - 10:00 AM"
              },
              {
                "id": "slot-2",
                "title": "Monday, Oct 9",
                "description": "11:00 AM - 12:00 PM"
              }
            ],
            "title": "Oct 9, 2024"
          },
          {
            "rows": [
              {
                "id": "slot-3",
                "title": "Tuesday, Oct 10",
                "description": "2:00 PM - 3:00 PM"
              },
              {
                "id": "slot-4",
                "title": "Tuesday, Oct 10",
                "description": "4:00 PM - 5:00 PM"
              }
            ],
            "title": "Oct 10, 2024"
          }
        ]
      },
      "body": {
        "text": "Looking for personalized assistance? Our Customer Success team has the following slots available. Tap to select a time."
      },
      "footer": {
        "text": "For urgent inquiries, email [email protected]"
      },
      "header": {
        "type": "text",
        "text": "Customer Success personalized sessions"
      },
      "type": "list"
    }
  }
}

Whatsapp Commerce

πŸ‘

Pre-requisite: You should have a catalogue created and connected to your Whatsapp Business Account (WABA)

Interactive message with a single product item from a business catalog

It will be hyperlinked to the specific product in the business catalog

{
    "user": {
        "msisdn": "+65000000"
    },
    "type": "interactive",
    "content": {
        "interactive": {
            "action": {
                "catalog_id": "<YourCatalogId>",
                "product_retailer_id": "<YourProductRetailerId>"
            },
            "body": {
                "text": "Body content"
            },
            "footer": {
                "text": "Footer content"
            },
            "type": "product"
        }
    }
}

Interactive message with a list of product items from a business catalog

You will be linked to a product list in the business catalog

{
    "user": {
        "msisdn": "+65000000"
    },
    "type": "interactive",
    "content": {
        "interactive": {
            "action": {
                "catalog_id": "<YourCatalogId>",
                "product_retailer_id": "<YourProductRetailerId>",
                "sections": [
                    {
                        "product_items": [
                            {
                                "product_retailer_id": "<id>"
                            },
                            {
                                "product_retailer_id": "<id>"
                            }
                        ],
                        "title": "Section title"
                    }
                ]
            },
            "body": {
                "text": "Body content"
            },
            "footer": {
                "text": "Footer content"
            },
            "header": {
                "type": "text",
                "text": "Header"
            },
            "type": "product_list"
        }
    }
}