Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Using Buttons In WhatsApp



What are WhatsApp buttons?

WhatsApp lets you add buttons to message templates. There are two types of buttons: Quick replies and Call to action buttons. These buttons open up many opportunities for businesses worldwide to engage with their customers on WhatsApp, one of the most popular messaging applications.

Quick replies let businesses define buttons that users can tap to respond. When a Quick reply is tapped, a message containing the button text is sent in the conversation.

Call to action buttons trigger a phone call or open a website when tapped. Please note that at this time, WhatsApp does not support deep links.

To use buttons, you need to submit them as part of a message template to WhatsApp. Once approved, templates containing buttons can be sent by sending the message text in your API request.


Creating templates with buttons

To use buttons, you need to submit a template that contains the buttons. Go to the Twilio console, navigate to Messaging > Content Template Builder, and click the Create new button. Here, you need to submit a message template containing buttons.

The content types that can contain buttons are:

  • Call to action
  • Quick reply
  • Card
  • WhatsApp Card

For more information, please see Sending Notifications with Templates and Content Types Overview.

whatsapp-button-template.

Sending templates with buttons

Once your template with buttons has been approved, you can send buttons as part of your WhatsApp messages. To send a button, send the template like any other Content Template. To see how to send Content Templates, see Send Templates Created with Content Template Builder.

whatsapp-callaction-buttons.
quick-reply-button.
Call to action buttonsQuick reply button
(information)

Info

Quick reply buttons can be sent without approval within a 24 hour session. To send quick reply buttons, create the template but do not submit it for approval. You can then send the quick reply template directly without approval in a 24 hour session.

Sending Content Templates

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_22
// Download the helper library from https://www.twilio.com/docs/node/install
_22
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_22
_22
// Find your Account SID and Auth Token at twilio.com/console
_22
// and set the environment variables. See http://twil.io/secure
_22
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_22
const authToken = process.env.TWILIO_AUTH_TOKEN;
_22
const client = twilio(accountSid, authToken);
_22
_22
async function createMessage() {
_22
const message = await client.messages.create({
_22
contentSid: "HXXXXXXXXX",
_22
contentVariables: JSON.stringify({ 1: "Name" }),
_22
from: "whatsapp:+15551234567",
_22
messagingServiceSid: "MGXXXXXXXX",
_22
to: "whatsapp:+18551234567",
_22
});
_22
_22
console.log(message.body);
_22
}
_22
_22
createMessage();

Output

_28
{
_28
"account_sid": "ACXXXXXXXXX",
_28
"api_version": "2010-04-01",
_28
"body": "Hello! 👍",
_28
"date_created": "Thu, 24 Aug 2023 05:01:45 +0000",
_28
"date_sent": "Thu, 24 Aug 2023 05:01:45 +0000",
_28
"date_updated": "Thu, 24 Aug 2023 05:01:45 +0000",
_28
"direction": "outbound-api",
_28
"error_code": null,
_28
"error_message": null,
_28
"from": "whatsapp:+15551234567",
_28
"num_media": "0",
_28
"num_segments": "1",
_28
"price": null,
_28
"price_unit": null,
_28
"messaging_service_sid": "MGXXXXXXXX",
_28
"sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_28
"status": "queued",
_28
"subresource_uris": {
_28
"media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json"
_28
},
_28
"tags": {
_28
"campaign_name": "Spring Sale 2022",
_28
"message_type": "cart_abandoned"
_28
},
_28
"to": "whatsapp:+18551234567",
_28
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
_28
}


Receiving Quick Replies

When end-users tap on one of your Quick replies, this automatically triggers a message that is sent to your business with the button text. If you have a webhook configured for incoming messages to the WhatsApp sender that the Quick reply was sent to, then you can get the text of the button tapped in the ButtonText parameter from the callback. Additionally you can set and get the a unique identifier for each quick reply button using the id field. For more information, please see Twilio's Webhook Requests.


Additional information

  • Message templates with buttons incur standard template charges wherever applicable.
  • Buttons are supported in Twilio Studio, Flex and Conversations API by sending a message with a text body that matches the corresponding template with buttons.

Rate this page: