Open Graph Template Reference

On July 29, 2019 we deprecated the Open Graph Template for V4.0

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 support Open Graph Template. As a fallback, a generic template which links to the URL will be rendered. When a user clicks on the song that is shared in Messenger, the user will be directed to the audio streaming platform's website or app. Refer to June 10, 2019 Announcement.

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. For implementation details, see Open Graph Template.

Contents

Request URI

https://graph.facebook.com/v5.0/me/messages?access_token=<PAGE_ACCESS_TOKEN>

Example Request

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": "AG5Hz2Uq7tuwNEhXfYYKj8mJEM_QPpz5jdCK48PnKAjSdjfipqxqMvK8ma6AC8fplwlqLP_5cgXIbu7I3rBN0P"
}  

Properties

recipient

Description of the message recipient. All requests must include one of the following properties to identify the recipient.

Property Type Description

recipient.id

String

Page Scoped User ID (PSID) of the message recipient. The user needs to have interacted with any of the Messenger entry points in order to opt-in into messaging with the Page. Note that Facebook Login integrations return user IDs are app-scoped and will not work with the Messenger platform.

recipient.user_ref

String

Used for the checkbox plugin.

recipient.post_id

String

Used for Private Replies to reference the visitor post to reply to.

recipient.comment_id

String

Used for Private Replies to reference the post comment to reply to.

message

Description of the message to be sent.
Property Type Description

message.attachment

Object

An object describing attachments to the message.

message.attachment

Property Type Description

type

String

Value must be template

payload

Object

payload of the template.

message.attachment.payload

Property Type Description

template_type

String

Value must be open_graph

elements

Array<element>

Array of maximum 1 object that describes the open graph object to display.

message.attachment.payload.elements

The elements array supports a maximum of 1 entry.

Property Type Description

url

String

String to display as the title of the list item. 80 character limit. May be truncated if the title spans too many lines.

buttons

String

An array of buttons to append to the template.


Open graph templates sent via beginShareFlow() support a maximum of 1 button with `"type": "web_url".


Open graph templates sent via the Send API support a maximum of 3 buttons of any type.