Examples

Use cases for the Sinch WhatsApp API

Interactive message templates

Interactive message templates can have three types of buttons:

  • quick reply button
  • call button
  • URL button (Static and Dynamic)

When the user clicks on a button, it triggers an action.

Message template with quick reply buttons

Suppose there exists a message template with the following data.

Template body:

Hi {{1}}.

Your order of {{2}} has been prepared for shipping. We can send the ticket to you in three different ways.
1. {{3}}
2. {{4}}
3. {{5}}

Please select your preferred delivery option.

Template quick reply buttons:

  1. Email
  2. Post
  3. WhatsApp

Template preview:

image

Example of a message using this template:

{
  "to": [
    "46732019282"
  ],
  "message": {
    "type": "template",
    "template_name": "deal_offer",
    "language": "en",
    "body_params": [
      "John",
      "a ticket",
      "Email",
      "Post",
      "WhatsApp"
    ],
    "media" : {
      "type": "text"
    },
    "buttons" : [
      {
        "type": "quick_reply",
        "payload": "email"
      },
      {
        "type": "quick_reply",
        "payload": "post"
      },
      {
        "type": "quick_reply",
        "payload": "whatsapp"
      }
    ]
  }
}

Example result on the phone:

image

The quick reply button payload, which is returned in a callback notification when the recipient presses that button, could be used to easily collect statistics about the most popular delivery choices for instance.

Message template with a static URL button

Suppose there exists a message template with the following data.

Template body:

Hello, {{1}}. Your account has been updated.

Template buttons:

  1. URL of type Static

Template preview:

image

Example of a message using this template:

Note

The buttons element is not required here as the button is of Static URL type.

{
    "to": [
        "46732019282"
    ],
    "message": {
        "type": "template",
        "template_name": "test_template_static_url",
        "language": "en",
        "body_params": [
            "Stephanie"
        ]
    }
}

Example result on the phone:

image

Message template with a dynamic URL button

Suppose there exists a message template with the following data.

Template header:

Incident {{1}} solved

Template body:

Hello {{1}}

An incident {{2}} that you reported was solved by our team.

Please check your account.

Template buttons:

  1. URL of type Dynamic

Template preview:

image

Example of a message using this template:

(Here buttons element is required because a button is of Dynamic URL type and a parameter needs to be provided.)

{
    "to": [
        "46732019282"
    ],
    "message": {
        "type": "template",
        "template_name": "test_template_dynamic_url",
        "language": "en",
        "header_params": [
            "INR0001234"
        ],
        "media": {
            "type": "text"
        },
        "body_params": [
            "Frederic", "INR0001234"
        ],
        "buttons": [
            {
                "type": "url",
                "parameter": "987654"
            }
        ]
    }
}

Example result on the phone:

image