Share Button Reference

During F8 2019, we announced our plans to launch a lighter, better and simpler Messenger designed to build closer connections between people and businesses.

Starting August 15, 2019, updated versions of the Messenger app will no longer render Share Button. People can use the Messenger forward functionality instead of the Share Button. Refer to June 10, 2019 Announcement

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.

For more information on using the share button, see Share Button.

Contents

Button Syntax

{
  "type": "element_share",
  "share_contents": { 
    "attachment": {
      "type": "template",
      "payload": {
        "template_type": "generic",
        "elements": [
          {
            "title": "<TEMPLATE_TITLE>",
            "subtitle": "<TEMPLATE_SUBTITLE>",
            "image_url": "<IMAGE_URL_TO_DISPLAY>",
            "default_action": {
              "type": "web_url",
              "url": "<WEB_URL>"
            },
            "buttons": [
              {
                "type": "web_url",
                "url": "<BUTTON_URL>", 
                "title": "<BUTTON_TITLE>"
              }
            ]
          }
        ]
      }
    }
  }
}

Example Usage

curl -X POST -H "Content-Type: application/json" -d '{
  "recipient":{
    "id":"<PSID>"
  },
  "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",
                "share_contents": { 
                  "attachment": {
                    "type": "template",
                    "payload": {
                      "template_type": "generic",
                      "elements": [
                        {
                          "title": "I took the hat quiz",
                          "subtitle": "My result: Fez",
                          "image_url": "https://bot.peters-hats.com/img/hats/fez.jpg",
                          "default_action": {
                            "type": "web_url",
                            "url": "http://m.me/petershats?ref=invited_by_24601"
                          },
                          "buttons": [
                            {
                              "type": "web_url",
                              "url": "http://m.me/petershats?ref=invited_by_24601", 
                              "title": "Take Quiz"
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            ]
          }
        ]
      }
    }
  }
}' "https://graph.facebook.com/me/messages?access_token=<PAGE_ACCESS_TOKEN>"

Example Response

{
  "recipient_id": "1254477777772919",
  "message_id": "AG5Hz2Uq7tuwNEhXfYYKj8mJEM_QPpz5jdCK48PnKAjSdjfipqxqMvK8ma6AC8fplwlqLP_5cgXIbu7I3rBN0P"
}  

Properties

Property Type Description

type

String

Type of button. Must be element_share.

share_contents

Object

Optional. 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.


share_contents only supports the following:

  • Template used must be generic template.
  • Maximum of one URL button on the template. If no buttons are specified, the buttons property on the generic template must be set to an empty array.