Facebook Send API mentions a "payload" type you can set for buttons on the Generic Response Template. However, they don't say how it works, other than:
For postback buttons, this data will be sent back to you via webhook
But how is it sent back? I don't receive any messages when I click the payload button. Has anyone successfully used it?
the 'payload' field is a user-defined field that enables you to call an action whenever a postback with this payload is received. for example; if I create a persistent menu in my bot that contains 2 buttons: 'Home' and 'Contact', and the payload for each of them is the same as the name of the button.
A bot Facebook payload (or Ref-Parameter) is a way for you to allow services outside of your bot to trigger specific Facebook Messenger Conversations in the bot for a user.
After you log into your Facebook account, click the + sign to start a new chatbot. Start a new chatbot on Chatfuel. Next, choose a template to edit or create a blank chatbot from scratch. Enter a name for the chatbot in the text box and click the red Create a Chatbot button to create it.
In web development, a postback is an HTTP POST to the same page that the form is on. In other words, the contents of the form are POSTed back to the same URL as the form. Postbacks are commonly seen in edit forms, where the user introduces information in a form and hits "save" or "submit", causing a postback.
I tested it and it works for me. The payload of a button acts like the value on a html button. This means it's not visible to the user but it's the value that's send back to you.
If you create a button like that:
'attachment': {
'type': 'template',
'payload': {
'template_type': 'button',
'text': 'This is the description',
'buttons': [
{
'type': 'postback',
'title': 'This is the visible text',
'payload': 'This is the value you get back'
}
]
}
A callback including a payload looks like that:
{'timestamp': 1461697120850, 'postback': {'payload': 'this is the value you get back'}, 'recipient': {'id': xxxxxxxx}, 'sender': {'id': xxxxxxxx}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With