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 deeplinks.
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.
To use buttons, you need to submit a template that contains the buttons. Go to the Twilio console, navigate to Programmable Messaging > Senders > WhatsApp Templates, and click the New message template button. Here, you need to submit a message template containing buttons. For more information, please see Sending Notifications with Templates.
_14// Download the helper library from https://www.twilio.com/docs/node/install_14// Find your Account SID and Auth Token at twilio.com/console_14// and set the environment variables. See http://twil.io/secure_14const accountSid = process.env.TWILIO_ACCOUNT_SID;_14const authToken = process.env.TWILIO_AUTH_TOKEN;_14const client = require('twilio')(accountSid, authToken);_14_14client.messages_14 .create({_14 body: 'Thank you for submitting your order. To finalize your payment, please tap below to call or visit our website.',_14 from: 'whatsapp:+15005550006',_14 to: 'whatsapp:+14155238886'_14 })_14 .then(message => console.log(message.sid));
_24{_24 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",_24 "api_version": "2010-04-01",_24 "body": "Thank you for submitting your order. To finalize your payment, please tap below to call or visit our website.",_24 "date_created": "Thu, 24 Aug 2023 05:01:45 +0000",_24 "date_sent": "Thu, 24 Aug 2023 05:01:45 +0000",_24 "date_updated": "Thu, 24 Aug 2023 05:01:45 +0000",_24 "direction": "outbound-api",_24 "error_code": null,_24 "error_message": null,_24 "from": "whatsapp:+15005550006",_24 "num_media": "0",_24 "num_segments": "1",_24 "price": null,_24 "price_unit": null,_24 "messaging_service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",_24 "sid": "SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",_24 "status": "queued",_24 "subresource_uris": {_24 "media": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Media.json"_24 },_24 "to": "whatsapp:+14155238886",_24 "uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"_24}
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. For more information, please see Twilio's Webhook Requests.