The generic template allows you to send a structured message that includes an image, text and buttons. A generic template with multiple options described in the Before you startThis guide assumes you have set up your webhooks server to receive notifications and subscribed your app to Instagram You will need:
LimitationsThis feature is currently not available on desktop. Host URL
|
To send a template message send a POST
request to the /<IG_ID>/messages
endpoint with the following parameters:
recipient.id
set to the Instagram-scoped ID of the person you are sending the messagemessage.attachment
object with:
type
set to template
payload
object with:
template_type
set to generic
elements
set to an array of objects that the recipient can select such as links, buttons, and images
curl -X POST "https://graph.instagram.com/v21.0
/<IG_ID>/messages"
-H "Content-Type: application/json"
-d '{
"recipient":{
"id":"<IGSID>"
},
"message":{
"attachment":{
"type":"template",
"payload":{
"template_type":"generic",
"elements":[
{
"title":"<THE_MESSAGE_TITLE>",
"image_url":"<THE_IMAGE_URL>",
"subtitle":"<THE_MESSAGE_SUBTITLE>",
"default_action": {
"type": "web_url",
"url": "<THE_WEBSITE_URL>",
},
"buttons":[
{
"type":"web_url",
"url":"<THE_WEBSITE_URL>",
"title":"<FIRST_BUTTON_TITLE>"
},
{
"type":"postback",
"title":"<SECOND_BUTTON_TITLE>",
"payload":"PAYLOAD_TO_INCLUDE_FOR_BUTTON_2"
}
]
}
]
}
}
}
}'
On success your app receives a JSON response with the Instagram-scoped ID for the reciepient and the ID for the message.
{ "recipient_id": "1254477777772919", "message_id": "AG5Hz2Uq7tuwNEhXfYYKj8mJEM_QPpz5jdCK48PnKAjSdjfipqxqMvK8ma6AC8fplwlqLP_5cgXIbu7I3rBN0P" }
Property | Type | Description |
---|---|---|
| String | The Instagram-scoped ID ( |
| 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 must be |
| Array | An array of |
message.attachment.payload.elements
The generic template supports a maximum of 10 elements per message. At least one property must be set in addition to title
.
Property Name | Type | Description |
---|---|---|
| String | The title to display in the template. 80 character limit. |
| String | Optional. The subtitle to display in the template. 80 character limit. |
| String | Optional. The URL of the image to display in the template. |
| Object | Optional. The default action executed when the template is tapped. Accepts the same properties as URL button, except |
| Array | Optional. An array of buttons to append to the template. A maximum of 3 buttons per element is supported. Only |
Visit the message.attachment.data
for GIFs and Stickers.