Messenger Platform

 
 
 

Quick Replies

Quick Replies provide a way to present buttons in a message. Quick Replies appear prominently above the composer, with the keyboard less prominent. When a quick reply is tapped, the message is sent in the conversation with developer-defined payload in the callback.

After the user taps one, they are dismissed, which prevents the scenario where users could tap on buttons attached to old messages in a conversation.

Quick Replies contain text and an optional image.



You can also use Quick Replies to prompt a person for their location.

Examples

Text only

    ...
      
    "quick_replies":[
      {
        "content_type":"text",
        "title":"Red",
        "payload":"DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_RED"
      }
    ]

    ...

Text and Image

       
    ...
      
    "quick_replies":[
      {
        "content_type":"text",
        "title":"Red",
        "image_url":"http://example.com/img/red.png",
        "payload":"DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_RED"
      }
    ]

    ...
    

Location

    ...
  
    "quick_replies":[
      {
        "content_type":"location"
      }
    ]
  
    ...
    

Example Request

curl -X POST -H "Content-Type: application/json" -d '{
  "recipient":{
    "id":"<PSID>"
  },
  "message":{
    "text": "Here's a quick reply!",
    "quick_replies":[
      {
        "content_type":"text",
        "title":"Search",
        "payload":"<POSTBACK_PAYLOAD>",
        "image_url":"http://example.com/img/red.png"
      },
      {
        "content_type":"location"
      },
      {
        "content_type":"text",
        "title":"Something Else",
        "payload":"<POSTBACK_PAYLOAD>"
      }
    ]
  }
}' "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

message object

Property Name Description Required

text

Non-empty message text

text or attachment must be set

attachment

attachment object

text or attachment must be set

quick_replies

Array of quick_reply to be sent with messages

N

  • quick_replies is limited to 11

attachment object

Property Name Description Required

type

Type of attachment, may be image or template

Y

payload

Payload of attachment

Y

Quick Replies work with all message types including text message, image and template attachments. Please refer to the Send API documentation for more information on how to use the attachment object.

quick_reply object

Property Name Description Type Required

content_type

text or location

String

Y

title

Caption of button

String

Only if content_type is text

payload

Custom data that will be sent back to you via webhook

String, Number

Only if content_type is text

image_url

URL of image for text quick replies

String

N

  • title has a 20 character limit, after that it gets truncated
  • payload has a 1000 character limit
  • If content_type is location, title and payload are not used
  • Image for image_url should be at least 24x24 and will be cropped and resized

Webhook Event

When a Quick Reply is tapped, a text message will be sent to your webhook Message Received Callback.

The text of the message will correspond to the title of the Quick Reply. The message object will also contain a field named quick_reply containing the payload data on the Quick Reply.

Text Webhook Event

{
  "object": "page",
  "entry": [
    {
      "id": "682498171943165",
      "time": 1502905976963,
      "messaging": [
        {
          "sender": {
            "id": "1254459154682919"
          },
          "recipient": {
            "id": "682498171943165"
          },
          "timestamp": 1502905976377,
          "message": {
            "quick_reply": {
              "payload": "DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_GREEN"
            },
            "mid": "mid.$cAAJsujCd2ORkHXKOOVd7C1F97Zto",
            "seq": 9767,
            "text": "Green"
          }
        }
      ]
    }
  ]
}

Location Webhook Event

{
  "object": "page",
  "entry": [
    {
      "id": "PAGE_ID",
      "time": 1472672934319,
      "messaging": [
        {
          "sender": {
            "id": "USER_ID"
          },
          "recipient": {
            "id": "PAGE_ID"
          },
          "timestamp": 1472672934259,
          "message": {
            "mid": "mid.1472672934017:db566db5104b5b5c08",
            "seq": 297,
            "attachments": [
              {
                "title": "Facebook HQ",
                "url": "https://www.facebook.com/l.php?u=https%....5-7Ocxrmg",
                "type": "location",
                "payload": {
                  "coordinates": {
                    "lat": 37.483872693672,
                    "long": -122.14900441942
                  }
                }
              }
            ]
          }
        }
      ]
    }
  ]
}