Skip to content

Buttons

Most message templates, as well as the persistent menu, support buttons that invoke different types of actions. These buttons allow you to easily offer the message recipient actions they can take in response to the template, such as opening the Messenger webview, starting a payment flow, sending a postback message to your webhook, and more.

For message templates, buttons are included defined by objects in the buttons array. For the persistent menu, buttons are defined by objects in the call_to_actions array.

[source]

WebUrlButton

fbotics.models.buttons.WebUrlButton(type=web_url, title=None, webview_height_ratio=full, url=None)

The URL Button opens a webpage in the Messenger webview. This button can be used with the Button and Generic Templates.

Arguments

  • type: Type of button, which is web_url.
  • title: Button title. 20 character limit.
  • webview_height_ratio: Optional. Height of the Webview. Valid values: compact, tall, full. Defaults to full.
  • url: This URL is opened in a mobile browser when the button is tapped. Must use HTTPS protocol if messenger_extensions is true.

Examples

from fbotics.models.buttons import WebUrlButton
WebUrlButton(dict(title="hello", url="http://www.google.de"))

WebUrlButton


[source]

CallButton

fbotics.models.buttons.CallButton(type=phone_number, title=None, payload=None)

The call button dials a phone number when tapped. Phone number should be in the format +, e.g. +15105559999.

Arguments

  • type: Type of button, which is phone_number.
  • title: Button title, 20 character limit.
  • payload: Format must have "+" prefix followed by the country code, area code and local number. For example, +16505551234.

Examples

from fbotics.models.buttons import CallButton
CallButton(dict(title="Call Representative", payload="+15105551234"))


[source]

PostbackButton

fbotics.models.buttons.PostbackButton(type=postback, title=None, payload=None)

The postback button sends a messaging_postbacks event to your webhook with the string set in the payload property. This allows you to take an arbitrary actions when the button is tapped. For example, you might display a list of products, then send the product ID in the postback to your webhook, where it can be used to query your database and return the product details as a structured message.

Arguments

  • type: Type of button, which is postback.
  • title: Button title. 20 character limit.
  • payload: This data will be sent back to your webhook. 1000 character limit.

Examples

from fbotics.models.buttons import PostbackButton
PostbackButton(dict(title="Select Product", payload="a4f8#4k3"))