fbbotw.post_button_template

fbbotw.post_button_template(fbid, text, buttons, sharable=True, messaging_type=’RESPONSE’, tag=None)[source]

Sends a button template with the specified text and buttons. Check the docs to see the diffrent types of buttons.

Usage:
>>> # Set the user id and text to send with the template
>>> fbid = "<user page scoped id>"
>>> text = "Would you like to login?"
>>> # Set the buttons list
>>> buttons = [
        {
            'type': 'postback',
            'title': 'Meh',
            'payload': 'USER_DOESNT_WANT_LOGGIN'
        },
        {
            'type': 'web_url',
            'url': 'https://petersapparel.parseapp.com',
            'title': "LOG ME IN"
        }
    ]
>>> # Send the template
>>> response = fbbotw.post_button_template(
        fbid=fbid,
        text=text,
        buttons=buttons
    )
Parameters:
  • fbid (str) – User id to send the buttons.
  • text (str) – Message to be displayed with the buttons (640 Chars).
  • buttons (list) –

    Dict of buttons that appear as call-to-actions, format :

    >>> buttons = [
        {
            ‘type’: ‘web_url’,
            ‘url’: ‘https://petersapparel.parseapp.com’,
            ‘title’: ‘Show Website’
        },
        {
            ‘type’: ‘postback’,
            ‘title’: ‘Start Chatting’,
            ‘payload’: ‘USER_DEFINED_PAYLOAD’
        }
        {
            ‘type’: ‘element_share’,
        }
    ]
    
  • sharable (bool) – Able/Disable native share button in Messenger for the template message (Default: True).
  • messaging_type (str) – Identifies the message type from: RESPONSE, UPDATE AND MESSAGE_TAG (Default: RESPONSE, if MESSAGE_TAG, tag param is required)
  • tag (str) – Tag classifying the message, must be one of the following tags
Returns:

Response object.

Facebook docs:

/button-template