Message templates offer a way for you to offer a richer in-conversation experience than standard text messages by integrating buttons, images, lists, and more alongside text a single message. Templates can be use for many purposes, such as displaying product information, asking the message recipient to choose from a pre-determined set of options, and showing search results.
The following templates are available for sending structured messages:
https://graph.facebook.com/v21.0
/me/messages?access_token={PAGE_ACCESS_TOKEN}
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"<PSID>"
},
"message":{
"attachment":{
"type":"template",
"payload":{
"template_type":"generic",
"elements":[
{
"title":"Welcome!",
"image_url":"https://raw.githubusercontent.com/fbsamples/original-coast-clothing/main/public/styles/male-work.jpg",
"subtitle":"We have the right hat for everyone.",
"default_action": {
"type": "web_url",
"url": "https://www.originalcoastclothing.com/",
"webview_height_ratio": "tall"
},
"buttons":[
{
"type":"web_url",
"url":"https://www.originalcoastclothing.com/",
"title":"View Website"
},{
"type":"postback",
"title":"Start Chatting",
"payload":"DEVELOPER_DEFINED_PAYLOAD"
}
]
}
]
}
}
}
}' "https://graph.facebook.com/v15.0/me/messages?access_token=<PAGE_ACCESS_TOKEN>"
{ "recipient_id": "1254477777772919", "message_id": "AG5Hz2Uq7tuwNEhXfYYKj8mJEM_QPpz5jdCK48PnKAjSdjfipqxqMvK8ma6AC8fplwlqLP_5cgXIbu7I3rBN0P" }
recipient
Description of the message recipient. All requests must include one of the following properties to identify the recipient.
Property | Type | Description |
---|---|---|
| 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. |
| String | Used for the checkbox plugin and customer chat plugin. |
| String | Used for Private Replies to reference the visitor post to reply to. |
| String | Used for Private Replies to reference the post comment to reply to. |
message
Property | Type | Description |
---|---|---|
| Object | An object describing attachments to the message. |
message.attachment
Property | Type | Description |
---|---|---|
| String | Value must be |
| Object |
|
message.attachment.payload
Property | Type | Description |
---|---|---|
| String | Value indicating the template type |
| Mixed | The rest of |