davidchua / pymessenger

A Python Wrapper for the FB Messenger Bot API (Send/Receive API)
MIT License
457 stars 183 forks source link

Adding A Button To Generic Template #39

Open AlfredoSequeida opened 7 years ago

AlfredoSequeida commented 7 years ago

Is there a way to add a button to the generic view with the wrapper as it stands? I tried including a tuple in the generic view list with a button, but that didn't seem to do it.

iamnottheway commented 7 years ago

Hey, @AlfredoSequeida you can add a button using the send_button_message() function. The wrapper doesn't add the button payload for you, you have to do it manually. You can add one or more buttons by creating a dict, see the messenger docs.

 btn_payload = [
            {
                "type":"<type>",
                "title":"<text>",
                "payload":"USER_DEFINED_PAYLOAD"
             },
             ....
        ]
        bot.send_button_message(recipient_id = recipient_id,
            text = "<some text>",
            buttons = btn_payload
       )

Hope this helps :+1: :)