Skip to main content

Sending WhatsApp Messages

This section describes how to send messages via WhatsApp using the Sinch India Conversation API.

note

Customer opt-in is essential before sending any messages. Businesses can only initiate a new conversation with a defined, approved WhatsApp template.

Supported Message Types

  • Text Message
  • Media Message (Image, Video, Document, Audio)
  • Location Message
  • Interactive Quick Reply Button Message
  • Interactive List Message
  • Product Catalogue Message (Single & Multi-Product)
  • Templated Message

3.2.1.1 Text Message

AttributeRequiredData TypeDetails
text_messageYesObjectSpecifies the message type as a text message
textYesStringThe text to be sent
{
"app_id": "01E9AHW7C686SN0HZ595BH1YYY",
"recipient": {
"identified_by": {
"channel_identities": [
{
"channel": "WHATSAPP",
"identity": "91931XXXXXXX"
}
]
}
},
"message": {
"text_message": {
"text": "Today is 19/04/2023."
}
}
}

3.2.1.2 Media Message

A message containing a media component such as an image, document, or video. Uses the media_message object.

AttributeDescription
url (required)URL to the media file
captionCaption for the media on supported channels

Image Message

{
"app_id": "01E9AHW7C686SN0HZ595BH1YYY",
"recipient": { "identified_by": { "channel_identities": [{ "channel": "WHATSAPP", "identity": "91XXXXXXXXXX" }] } },
"message": { "media_message": { "url": "https://example.com/image.jpg" } }
}

Video Message

{
"app_id": "01E9AHW7C686SN0HZ595BH1YYY",
"recipient": { "identified_by": { "channel_identities": [{ "channel": "WHATSAPP", "identity": "91XXXXXXXXXX" }] } },
"message": { "media_message": { "url": "https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4" } }
}

Document Message

{
"app_id": "01E9AHW7C686SN0HZ595BH1YYY",
"recipient": { "identified_by": { "channel_identities": [{ "channel": "WHATSAPP", "identity": "91XXXXXXXXXX" }] } },
"message": { "media_message": { "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" } }
}

Audio Message

{
"app_id": "01E9AHW7C686SN0HZ595BH1YYY",
"recipient": { "identified_by": { "channel_identities": [{ "channel": "WHATSAPP", "identity": "91XXXXXXXXXX" }] } },
"message": { "media_message": { "url": "https://sample-videos.com/audio/mp3/crowd-cheering.mp3" } }
}

3.2.1.3 Location Message

AttributeDescription
title (required)Shown near the button or link that leads to a map
labelLabel or name for the position
coordinates.latitude (required)The latitude
coordinates.longitude (required)The longitude
{
"app_id": "01E9AHW7C686SN0HZ595BH1YYY",
"recipient": { "identified_by": { "channel_identities": [{ "channel": "WHATSAPP", "identity": "91931XXXXXXX" }] } },
"message": {
"location_message": {
"title": "Your ride is here!",
"label": "Meet your driver at the specified address.",
"coordinates": { "latitude": 55.610479, "longitude": 13.002873 }
}
}
}

3.2.1.4 Quick Reply Button Message

Uses the card_message object.

ObjectDescription
choicesArray of choice objects (max 10)
descriptionOptional description displayed below the title
heightCard size: UNSPECIFIED_HEIGHT, SHORT, MEDIUM, TALL
media_messageOptional image media component
titleTitle of the card message
{
"app_id": "01E9AHW7C686SN0HZ595BH1YYY",
"recipient": { "identified_by": { "channel_identities": [{ "channel": "WHATSAPP", "identity": "91931XXXXXXX" }] } },
"message": {
"card_message": {
"title": "Sign up for our newsletter",
"description": "Our weekly newsletter with deals and extra content!",
"media_message": { "url": "https://example.com/banner.png" },
"choices": [{ "text_message": { "text": "Sign up here" } }]
}
}
}

3.2.1.5 List Message

ObjectRequiredDescription
titleYesTitle displayed near the products or choices
sectionsYesArray of ListSection objects
descriptionNoOptional message description
message_propertiesNoRequired for product list messages
{
"app_id": "01E9AHW7C686SN0HZ595BH1YYY",
"recipient": { "identified_by": { "channel_identities": [{ "channel": "WHATSAPP", "identity": "917764863625" }] } },
"message": {
"list_message": {
"title": "Choose your ice cream flavor",
"description": "The best ice cream in town!",
"sections": [
{ "title": "Fruit flavors", "items": [{ "choice": { "title": "Strawberry", "postback_data": "Strawberry postback" } }, { "choice": { "title": "Blueberry", "postback_data": "Blueberry postback" } }] },
{ "title": "Other flavors", "items": [{ "choice": { "title": "Chocolate", "postback_data": "Chocolate postback" } }, { "choice": { "title": "Vanilla", "postback_data": "Vanilla postback" } }] }
],
"message_properties": { "menu": "Menu" }
}
}
}

3.2.1.6 Product Catalogue Message

Uses the list_message object with product items:

{
"app_id": "01E9AHW7C686SN0HZ595BH1YYY",
"recipient": { "identified_by": { "channel_identities": [{ "channel": "WHATSAPP", "identity": "91931XXXXXXX" }] } },
"message": {
"list_message": {
"title": "Title for the list message with products",
"sections": [{ "title": "Facebook product catalog item set name", "items": [{ "product": { "id": "retailer_id_1", "marketplace": "FACEBOOK" } }, { "product": { "id": "retailer_id_2", "marketplace": "FACEBOOK" } }] }],
"message_properties": { "catalog_id": "catalog_id" }
}
}
}

3.2.1.7 Templated Message

Sending a message outside a 24-hour customer care session requires an approved template. All marketing, utility, or authentication conversations must start with user opt-in.

The channel_template object for WhatsApp:

AttributeRequiredDescription
template_idYesThe ID of the template
versionYesTemplate version to use
language_codeNoBCP-47 language code
parametersNoConcrete values for all template variables

Parameter Key Format

<component_type>[<component_index>]<component_sub_type>[<parameter_index>]<parameter_field>
  • component_type: header, body, or button
  • component_index: 0-based index (for button components only)
  • component_sub_type: quick_reply or url (for button components only)
  • parameter_index: 1-based index
  • parameter_field: text, payload, document., image., or video.*

Case 1 — Text Template

{ "message": { "template_message": { "channel_template": { "WHATSAPP": { "template_id": "text_template", "language_code": "en", "parameters": { "body[1]text": "Value of first parameter", "body[2]text": "Value of second parameter" } } } } } }

Case 2 — Image Template

{ "message": { "template_message": { "channel_template": { "WHATSAPP": { "template_id": "text_template", "language_code": "en", "parameters": { "header[1]image.link": "https://example.com/image.jpg", "body[1]text": "Value of first parameter" } } } } } }

Case 3 — Video Template

{ "message": { "template_message": { "channel_template": { "WHATSAPP": { "template_id": "text_template", "language_code": "en", "parameters": { "header[1]video.link": "https://example.com/video.mp4", "body[1]text": "Value of first parameter" } } } } } }

Case 4 — Document Template

{ "message": { "template_message": { "channel_template": { "WHATSAPP": { "template_id": "text_template", "language_code": "en", "parameters": { "header[1]document.link": "https://example.com/document.pdf", "header[1]document.filename": "document.pdf", "body[1]text": "Value of first parameter" } } } } } }

Case 5 — Location Template

Parameter Field KeyDescriptionRequired
header[1]location.longitudeLongitudeYes
header[1]location.latitudeLatitudeYes
header[1]location.nameName of the locationNo
header[1]location.addressAddressNo

Case 7 — Interactive (Buttons) Template

Parameter Field KeyDescriptionRequired
button[n]url[1]textDynamic URL suffix for URL buttonYes, if URL button
button[m]quick_reply[1]payloadPostback payloadYes, if quick reply button

Quick Reply:

{ "parameters": { "body[1]text": "Value", "button[0]quick_reply[1]payload": "button0clicked", "button[1]quick_reply[1]payload": "button1clicked" } }

Call-to-Action:

{ "parameters": { "body[1]text": "Value", "button[0]url[1]text": "Value for URL suffix button 1" } }