fbbotw.post_generic_template

fbbotw.post_generic_template(fbid, title, image_url=None, subtitle=None, buttons=None, default_action=None, sharable=True, image_aspect_ratio=’horizontal’, messaging_type=’RESPONSE’, tag=None)[source]

Sends a single generic template for the specified User

Usage:
>>> # This function sends only one element of a generic template
>>> # You can set the user id, the template title, image, subtitle
>>> # buttons and other parameers just by the function
>>> fbid = "<user page scoped id>"
>>> buttons = [
        {
            'type': 'web_url',
            'url': 'https://petersfancybrownhats.com',
            'title': 'View Website'
        },
        {
            'type': 'postback',
            'title': 'Start Chatting',
            'payload': 'DEVELOPER_DEFINED_PAYLOAD'
        }
    ]
>>> # Send the template
>>> response = fbbotw.post_generic_template(
        fbid=fbid,
        title="This is a generic template",
        image_url="http://i.imgur.com/uAUm3VW.jpg",
        buttons=buttons,
        image_aspect_ratio='square'
    )
Parameters:
  • fbid (str) – User id to send the generic template.
  • title (str) – Bubble title (80 Chars).
  • image_url (str) – Bubble image (Optional)(Ratio 1.91:1).
  • subtitle (str) – Bubble subtitle (Optional)(80 Chars).
  • default_action (dict) – Default action to be triggered when user taps on the element. See the docs for reference (Optional).
  • buttons (list) –

    (Optional)(Max 3) format :

    >>> buttons = [
        {
            ‘type’: ‘web_url’,
            ‘url’: ‘https://petersfancybrownhats.com’,
            ‘title’: ‘View Website’
        },
        {
            ‘type’: ‘postback’,
            ‘title’: ‘Start Chatting’,
            ‘payload’: ‘DEVELOPER_DEFINED_PAYLOAD’
        }
    ]
    
  • sharable (bool) – Able/Disable native share button in Messenger for the template message (Default: True).
  • image_aspect_ratio (str) – Aspect ratio used to render images specified by image_url in element objects. Must be ‘horizontal’ or ‘square’. (Default ‘horizontal’)
  • 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:

/generic-template