Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Payload" option on Facebook Bots buttons

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?

like image 737
Matheus208 Avatar asked Apr 25 '16 21:04

Matheus208


People also ask

What is payload in chatbot?

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.

What is Messenger payload?

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.

How do you customize chatbot on Facebook?

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.

What is postback message?

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.


1 Answers

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}}
like image 185
Juergen Avatar answered Sep 25 '22 00:09

Juergen