All quick replies, 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, 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. For more information on the specific purpose and format of each button type, see below.
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"PAGE-SCOPED-ID"
},
"message":{
"attachment":{
"type":"template",
"payload":{
"template_type":"button",
"text":"Try the URL button!",
"buttons":[
{
// Button type payload
}
]
}
}
}
}' "https://graph.facebook.com/v21.0
/PAGE-ID/messages?access_token=PAGE-ACCESS-TOKEN"
{ "recipient_id": "1254477777772919", "message_id": "AG5Hz2Uq7tuwNEhXfYYKj8mJEM_QPpz5jdCK48PnKAjSdjfipqxqMvK8ma6AC8fplwlqLP_5cgXIbu7I3rBN0P" }
The URL Button opens a webpage in the Messenger webview. This button can be used with the Button and Generic Templates.
If the site contains App Links the button will click into a native app. If you just made the change, you can use the Sharing Debugger to request a new scrape of the site.
Messenger 웹 보기에서 Messenger Extensions SDK를 활성화하고 웹페이지를 표시하려면 반드시whitelisted_domains
봇의 Messenger 프로필 속성에서 도메인(하위 도메인 포함)을 화이트리스트에 추가해야 합니다. 그러면 신뢰하는 도메인만 SDK 함수를 통해 제공되는 사용자 정보에 액세스할 수 있습니다.
도메인을 화이트리스트에 추가하는 방법에 대한 자세한 내용은 whitelisted_domains
참고 자료를 참조하세요.
{
"type":"web_url",
"url":"URL_TO_OPEN",
"title":"BUTTON_TEXT",
"webview_height_ratio": "compact|tall|full",
"messenger_extensions": "true|false",
"fallback_url": "URL_TO_FALLBACK_TO"
}
Parameters | Description |
---|---|
| Type of button. Must be |
| Button title. 20 character limit. |
| This URL is opened in a mobile browser when the button is tapped. Must use HTTPS protocol if |
| Optional. Height of the Webview. Valid values: |
| Optional. Must be |
| The URL to use on clients that don't support Messenger Extensions. If this is not defined, the |
| Optional. Set to |
When the postback button is tapped, the Messenger Platform sends an event to your postback webhook. This is useful when you want to invoke an action in your bot. This button can be used with the Button Template and Generic Template.
For more information on using the postback button, see Postback Button.
{ "type":"postback", "title":"Postback Button", "payload":"DEVELOPER_DEFINED_PAYLOAD" }
Parameters | Description |
---|---|
| Type of button. Must be |
| Button title. 20 character limit. |
| This data will be sent back to your webhook. 1000 character limit. |
The Call Button can be used to initiate a phone call. This button can be used with the Button and Generic Templates.
For more information on using the call button, see Call Button.
{
"type":"phone_number",
"title":"<BUTTON_TEXT>",
"payload":"<PHONE_NUMBER>"
}
Parameter | Description |
---|---|
| Type of button. Must be |
| Button title, 20 character limit. |
| Format must have "+" prefix followed by the country code, area code and local number. For example, |
The game play button launches an Instant Game that is associated with the bot page.
For more information on using the game play button, see Game Play Button.
{
"type":"game_play",
"title":"Play",
"payload":"{
Property | Description |
---|---|
| Type of button. Must be |
| Button title, e.g. "Play". |
| Optional. This data will be sent to the game. |
| Optional. Parameters specific to Instant Games. By providing the optional |
player_id string | Optional. Player ID (Instant Game name-space) to play against. |
context_id string djkkcfildgngitknngklglglufergvdn | Optional. Context ID (Instant Game name-space) of the THREAD to play in |
Refer to Game Play webhook event for the event that will be sent to the bot when a user finishes a game round.
The log in button triggers the account linking authentication flow.
For more information on using the log in button, see Log In Button.
...
"buttons":[
{
"type": "account_link",
"url": "https://www.example.com/authorize"
}
]
...
Parameter | Description |
---|---|
| Must be |
| Authentication callback URL. Must use HTTPS protocol. |
The log out button triggers the account unlinking flow.
For more information on using the log out button, see Log Out Button.
{
"type": "account_unlink"
}
Parameter | Description |
---|---|
| Must be |
The Extension Button opens a webpage in the Messenger webview. This button can be used with the Persistent Menu and Generic Templates.
For more information on using buttons, see Buttons.
To display a webpage with the Facebook Extensions SDK enabled in the Messenger webview you must whitelist the domain, including sub-domain, in the whitelisted_domains
property of your Messenger Profile. This ensures that only trusted domains have access to user information available via SDK functions.
For more information on whitelisting domains, see the whitelisted_domains
reference.
{
"type":"extension",
"url":"<URL_TO_OPEN>",
"title":"<BUTTON_TEXT>",
"view_style": "<compact|tall|full>" (default full),
"fallback_url": "<URL_TO_FALLBACK_TO>" (optional),
"enable_share_button": "<true|false>" (default false),
}
Parameter | Description |
---|---|
| Type of button. Must be |
| Button title. 20 character limit. |
| This URL is opened in a mobile browser when the button is tapped. Must use HTTPS protocol. |
| Optional. Height of the Webview. Valid values: |
| The URL to use on clients that don't support Messenger Extensions. If this is not defined, the |
| Optional. Set to |