Open Graph Template

The Open Graph template allows you to send a structured message with an Open Graph URL, plus an optional button. Currently, only sharing songs is supported. The song will appear in a bubble that allows the message recipient to see album art and preview the song.

Contents

Template Payload

For a complete list of template properties, see the Open Graph Template reference.

"payload": {
  "template_type":"open_graph",
  "elements":[
     {
      "url":"<OPEN_GRAPH_URL>",
      "buttons":[<BUTTON_OBJECT>]             
    }
  ]
}

Supported Open Graph Metadata

The URL you provide for the Open Graph template must provide Open Graph-formatted song details. The Messenger Platform will read the following metadata properties:

  • og:title
  • og:audio
  • music:musician
  • og:site_name
  • og:image.

Checking Webview Support

To share an Open Graph template from the Messenger webview with beginShareFlow(), you must first call getSupportedFeatures() and verify the sharing_open_graph feature is available.

Example Request

For complete request details and properties, see the Open Graph Template Reference.

curl -X POST -H "Content-Type: application/json" -d '{
  "recipient":{
    "id":"USER_ID"
  },
  "message":{
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"open_graph",
        "elements":[
           {
            "url":"https://open.spotify.com/track/7GhIk7Il098yCjg4BQjzvb",
            "buttons":[
              {
                "type":"web_url",
                "url":"https://en.wikipedia.org/wiki/Rickrolling",
                "title":"View More"
              }              
            ]      
          }
        ]
      }
    }
  }
}' "https://graph.facebook.com/v2.6/me/messages?access_token=PAGE_ACCESS_TOKEN"

Example Response

{
  "recipient_id": "1254477777772919",
  "message_id": "mid.$cAAJsujCd2ORj_1qmrFdzhVa-4cvO"
}