ChatApps: usage samples

👍

Please see ChatApps Send API for the full API reference.

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

{
    "user": {
        "msisdn": "+65000000"
    },
    "clientMessageId": "1234_id",
    "type": "text",
    "content": {
        "text": "Hello World!",
        "sms": {
            "encoding": "AUTO",
            "source": "SENDERID"
        }
    }
}

If you want to send an image with a text (optional) and a fallback text (optional), your request will look like this:

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

If you want to send a WeChat message, you need to specify the WeChatId of the user. As there are no delivery receipts on WeChat, there will be no fallbacks, hence the msisdn is not required. Your request will look like this:

{
    "user": {
        "weChatUserId": "wsknf_12324k4n2n22"
    },
    "clientMessageId": "1234_id",
    "type": "image",
    "content": {
        "text": "Welcome to Singapore!",
        "url": "https://example.com/media/image.jpg",
        "fallbackText": "We tried to send an image - but Welcome to Singapore",
        "sms": {
            "encoding": "AUTO",
            "source": "SENDERID"
        }
    }
}

If you want to send a Viber rich message, with a text, an image and a button, your request will look like this:

{
  "user": {
    "msisdn": "+650000000"
  },
  "type": "buttons",
    "content": {
        "text": "Welcome to Singapore!",
        "url": "https://example.com/media/image.jpg",
        "button": {
            "caption": "Check the documentation",
            "action": "https://developer.8x8.com/"
        }
    }
}

If you want to send a template message only on WhatsApp, your request will look like this (this template has two parameters). This would be a valid request for a template with static buttons too:

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

If you want to send a rich template message only on WhatsApp, your request will look like this (this template has an image header and two parameters):

{
    "user": {
        "msisdn": "+65000000"
    },
    "clientMessageId": "1234_id",
    "type": "template",
    "content": {
    "template": {
      "language": "en",
      "name": "template_name_1",
      "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"
            }
          ]
        }
      ]  
    }
  }
}

If you want to send a rich template message only on WhatsApp, your request will look like this (this template has a location header and two parameters):

{
    "user": {
        "msisdn": "+65000000"
    },
    "clientMessageId": "1234_id",
    "type": "template",
    "content": {
    "template": {
      "language": "en",
      "name": "template_name_1",
      "components": [
                {
          "type": "header",
          "parameters": [
            {
              "type": "location",
                    "location":{
                    "latitude": "1.3521",
                    "longitude": "103.8198"
              }
            }
          ]
        },
        {
          "type": "body",
          "parameters": [
            {
              "type": "text",
              "text": "Mr. John"
            },
                        {
              "type": "text",
              "text": "http://example.com"
            }
          ]
        }
      ]  
    }
  }
}

If you want to send a template message with one dynamic call to action button, only on WhatsApp, your request will look like this (this template has no body parameters and only the second button is dynamic):

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

Did this page help you?