Send message with Buttons

The method is designed to send a message with buttons to a private or group chat

Button sending is currently available. For more details, visit the Button Status topic.

Peculiarities when working with buttons

  • the button name can have no more than 25 characters;

  • there can be no more than 3 buttons of this type;

  • the button can be pressed only 1 time.

  • for current nuances of button display, see the article Current status of Buttons on WhatsApp

You can send a message with the button to either private chat or group chat. The buttons, e.g. YES / NO, can be selected by the user and used as a response to the sent message.

Types of buttons

There are four types of buttons on WhatsApp:

  • Simple text button (Quick-reply)

  • List of options

  • Link Button

  • OTP Button (Copy Button)

  • Call Button

Sending requires a request to be made to:

POST https://gate.whapi.cloud/messages/interactive


Message with auto-reply buttons

curl --request POST \
     --url https://gate.whapi.cloud/messages/interactive \
     --header 'accept: application/json' \
     --header 'authorization: Bearer {Your_Token}' \
     --header 'content-type: application/json' \
     --data '
{
  "header": {
    "text": "Header with text"
  },
  "body": {
    "text": "Body message"
  },
  "footer": {
    "text": "Footer message"
  },
  "action": {
    "buttons": [
      {
        "type": "quick_reply",
        "title": "Button1",
        "id": "randomId1"
      },
      {
        "type": "quick_reply",
        "title": "Button2",
        "id": "randomId2"
      }
    ]
  },
  "type": "button",
  "to": "61371989950"
}
'

When the recipient clicks on a button, it automatically sends a reply to your message containing the buttonโ€™s text. If you've set up a webhook for the channel, you'll receive a callback with both the button ID and the text.

{
  "messages": [
    {
      "id": "g0jEG0ZsSobn4yNGGU3TAg-gDYOS60TLw",
      "from_me": false,
      "type": "reply",
      "chat_id": "61371989950@s.whatsapp.net",
      "timestamp": 1726126124,
      "source": "mobile",
      "reply": {
        "type": "buttons_reply",
        "buttons_reply": {
          "id": "ButtonsV3:",
          "title": ""
        }
      },
      "context": {
        "quoted_id": "yqIuucnAGOW2vSk-wO0OS60TLw",
        "quoted_author": "919984351847",
        "quoted_type": "interactive"
      },
      "from": "61371989950",
      "from_name": "Jonathan"
    }
  ],
  "event": {
    "type": "messages",
    "event": "post"
  },
  "channel_id": "MANTIS-PF238"
}

curl --request POST \
     --url https://gate.whapi.cloud/messages/interactive \
     --header 'accept: application/json' \
     --header 'authorization: Bearer {Your_Token}' \
     --header 'content-type: application/json' \
     --data '
{
  "header": {
    "text": "Header with text"
  },
  "body": {
    "text": "Body message"
  },
  "footer": {
    "text": "Footer message"
  },
  "action": {
    "buttons": [
      {
        "type": "cta_call",
        "title": "Call us",
        "id": "randomId1",
        "phone_number": "61371989950"
      },
      {
        "type": "cta_url",
        "title": "Look at the website",
        "id": "randomId2",
        "url": "https://whapi.cloud"
      }
    ]
  },
  "type": "button",
  "to": "61371989950"
}
'

Unfortunately, WhatsApp does not track the event of clicking these buttons. Therefore, it is not possible to get a webhook for pressing these buttons.


Message with copy button (OTP code)

You can pass any text to the snippet that will be copied after the button is clicked.

curl --request POST \
     --url https://gate.whapi.cloud/messages/interactive \
     --header 'accept: application/json' \
     --header 'authorization: Bearer {Your_Token}' \
     --header 'content-type: application/json' \
     --data '
{
  "header": {
    "text": "Header with text"
  },
  "body": {
    "text": "Body message"
  },
  "footer": {
    "text": "Footer message"
  },
  "action": {
    "buttons": [
      {
        "type": "cta_copy",
        "title": "Copy OTP",
        "id": "randomId1",
        "copy_code": "65545"
      }
    ]
  },
  "type": "button",
  "to": "61371989950"
}
'

Unfortunately, WhatsApp does not track the event of clicking these buttons. Therefore, it is not possible to get a webhook for pressing these buttons.


Message with list of options

curl --request POST \
     --url https://gate.whapi.cloud/messages/interactive \
     --header 'accept: application/json' \
     --header 'authorization: Bearer {Your_Token}' \
     --header 'content-type: application/json' \
     --data '
{
  "header": {
    "text": "Header with text"
  },
  "body": {
    "text": "Body message"
  },
  "footer": {
    "text": "Footer message"
  },
  "action": {
    "list": {
      "sections": [
        {
          "title": "Title",
          "rows": [
            {
              "title": "title-mini1",
              "description": "description1",
              "id": "r1"
            },
            {
              "title": "title-mini2",
              "description": "description2",
              "id": "r2"
            }
          ]
        }
      ],
      "label": "ButtonTest"
    }
  },
  "type": "list",
  "to": "61371989950"
}
'

When the recipient clicks on a button, it automatically sends a reply to your message containing the buttonโ€™s text. If you've set up a webhook for the channel, you'll receive a callback with both the button ID and the text.

{
  "messages": [
    {
      "id": "A5y7S8JfMsgaYiXZC6Royw-gMoOS60TLw",
      "from_me": false,
      "type": "reply",
      "chat_id": "61371989950@s.whatsapp.net",
      "timestamp": 1726127469,
      "source": "mobile",
      "reply": {
        "type": "list_reply",
        "list_reply": {
          "id": "ListV3:r1",
          "title": "title-mini1",
          "description": "description1"
        }
      },
      "context": {
        "quoted_id": "yqLCLj.8G12Q4P8-wAsOS60TLw",
        "quoted_author": "919984351847",
        "quoted_type": "interactive"
      },
      "from": "61371989950",
      "from_name": "Jonathan"
    }
  ],
  "event": {
    "type": "messages",
    "event": "post"
  },
  "channel_id": "MANTIS-PF238"
}

We continue to explore WhatsApp's capabilities and add to our methods for automation. In the upcoming updates we will have the ability to send messages with picture/media and buttons.

If you have any questions, our team is always available to help you.

Last updated