Messenger Platform

 
 
 

Button Template

Use the Button Template with the Send API to send a text and buttons attachment to request input from the user. The buttons can open a URL, or make a back-end call to your webhook.

Example Request

curl -X POST -H "Content-Type: application/json" -d '{
  "recipient":{
    "id":"<PSID>"
  },
  "message":{
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"button",
        "text":"What do you want to do next?",
        "buttons":[
          {
            "type":"web_url",
            "url":"https://www.messenger.com",
            "title":"Visit Messenger"
          },
          {
            ...
          },
          {...}
        ]
      }
    }
  }
}' "https://graph.facebook.com/v2.6/me/messages?access_token=<PAGE_ACCESS_TOKEN>"

Example Response

{
  "recipient_id": "1254477777772919",
  "message_id": "mid.$cAAJsujCd2ORj_1qmrFdzhVa-4cvO"
}  

Fields

attachment object

Property Name Description Required

type

Value must be template

Y

payload

payload of button template

Y

payload object

Property Name Description Type Required

template_type

Value must be button

String

Y

text

UTF-8-encoded text of up to 640 characters that appears above the buttons

String

Y

buttons

Set of 1-3 buttons that appear as call-to-actions

Array of button

Y

button object

See the Message Buttons reference doc for details on the button object.