Search code examples
facebook-messenger

Facebook Messenger API: What's Does a Quick Reply Payload Do?


If I send Facebook quick reply JSON like the following:

"quick_replies":[
    {"content_type":"text","payload":"RED","title":"Red"},
    {"content_type":"text","payload":"BLUE","title":"Blue"},
    {"content_type":"text","payload":"GREEN","title":"Special"},
]

and the user picks the "Special" reply, I get back

{"recipient_id":5555,"text":"Special"}

I thought the whole point of the payload field was to provide a value other than the title which would be sent back, but it seems like Facebook just sends the title of the selected reply, which begs the question ... what's the point of the payload field?


Solution

  • Yes - you are right you should have so a response with the payload. As you can see in here: https://developers.facebook.com/docs/messenger-platform/send-api-reference/quick-replies#callback

    The response should be:

    {
      "sender": {
        "id": "USER_ID"
      },
      "recipient": {
        "id": "PAGE_ID"
      },
      "timestamp": 1464990849275,
      "message": {
        "mid": "mid.1464990849238:b9a22a2bcb1de31773",
        "seq": 69,
        "text": "Red",
        "quick_reply": {
          "payload": "DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_RED"
        }
      }
    }  
    

    and as @Keith Coughtrey mentioned you should enable messaging_postbacks permission.