Share Button

The Share Button enables people to share your content in Messenger.


Messages shared this way show an attribution to your bot that recipients can tap to learn more about your bot:




Implementation

In the message passed to the Send API, set the button type to element_share. Tapping the button will share the message it is attached to.

  ...
    "buttons":[
      {
        "type":"element_share"
      }              
    ]
  ...

New in Platform v1.4: You may also wish to specify contents different than the message the "Share" button is attached to. For instance, you might want to send an invitation, challenge, or other custom flow for the recipient to see.

To do this, set the optional share_contents attribute. Note that although the format for share_contents is identical to the that used in the Send API, we only support sharing generic templates with a maximum of 1 URL button.

The button you add to share_contents may use the webview to show a page, or use m.me to deep-link to your bot.

buttons Fields

Property Name Description Type Required

type

Type of button. Must be element_share.

String

Y

share_contents

The message that you wish the recipient of the share to see, if it is different from the one this button is attached to. The format follows that used in Send API, but must be a generic template with up to one URL button.

Object

N


Policy Reminder Messages shared via this API are subject to Facebook Platform Policy. Bots may not incentivize sharing, require it, or lead users to share in a deceptive manner.

Example

curl -X POST -H "Content-Type: application/json" -d '{
  "recipient":{
    "id":"USER_ID"
  },
  "message":{
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"generic",
        "elements":[
          {
            "title":"Breaking News: Record Thunderstorms",
            "subtitle":"The local area is due for record thunderstorms over the weekend.",
            "image_url":"https://thechangreport.com/img/lightning.png",
            "buttons":[
              {
                "type":"element_share"
              }              
            ]
          }
        ]
      }
    }
  }
}' "https://graph.facebook.com/me/messages?access_token=PAGE_ACCESS_TOKEN"      

Example showing share_contents attribute:

  ...
    "buttons": [
      {
        "type": "element_share",
        "share_contents": { 
          "attachment": {
            "type": "template",
            "payload": {
              "template_type": "generic",
              "elements": [
                {
                  "title": "I took Peter's 'Which Hat Are You?' Quiz",
                  "subtitle": "My result: Fez",
                  "image_url": "https://bot.peters-hats.com/img/hats/fez.jpg",
                  "default_action": {
                    "type": "web_url",
                    "url": "https://m.me/petershats?ref=invited_by_24601"
                  },
                  "buttons": [
                    {
                      "type": "web_url",
                      "url": "https://m.me/petershats?ref=invited_by_24601", 
                      "title": "Take Quiz"
                    }
                  ]
                }
              ]
            }
          }
        }
      }
    ]
  ... 

Caveats

  • Only individual message bubbles can be shared.
  • The Share Button can only be sent inside the Generic Template.
  • If your message bubble has a URL Button that uses Messenger Extensions (without a fallback URL), then the behavior of postback and buy buttons will change. When the recipient taps on one of these buttons, they will start a new thread with the bot.
    • In the case of a URL Button using Messenger Extensions, the fallback URL will be opened if specified. Share, URL, and Phone Number buttons will behave normally.