Gracias a los webhooks, podrás recibir notificaciones HTTP en tiempo real sobre los cambios que se produzcan en determinados objetos de la gráfica social de Meta. Por ejemplo, te podemos enviar una notificación cuando un cliente envíe un mensaje a tu cuenta profesional de Instagram. Gracias a las notificaciones de los webhooks, podrás hacer un seguimiento de los cambios en los mensajes y evitar los límites de frecuencia que se podrían producir si consultas los extremos de la plataforma de Messenger para hacer un seguimiento de los cambios.
Deberás implementar los requisitos siguientes para recibir las notificaciones de los webhooks para los mensajes de Instagram.
instagram_basic
, instagram_manage_messages
y pages_manage_metadata
.Nota: Deberás suscribir todas las aplicaciones de mensajes para tu empresa a los webhooks de mensajes.
Obtén más información sobre los niveles de acceso , los modos de aplicaciones y los roles de las aplicaciones.
Campo de webhooks | Descripción |
---|---|
| Se envía una notificación cuando un cliente reacciona a un mensaje o anula su reacción. La versión 12.0 de la API Graph y las versiones posteriores admiten las reacciones |
| Se envía una notificación cuando un cliente envía a tu empresa:
También se envía una notificación cuando tu empresa envía un mensaje a un cliente. No se enviará ninguna notificación cuando tu empresa reaccione a un mensaje de un cliente o anule la reacción. Esta devolución de llamada se producirá cuando tu cuenta de Instagram envíe un mensaje. La marca |
| Se envía una notificación cuando un cliente hace clic en una opción de pregunta para romper el hielo o el botón de plantilla genérica. Requiere la versión 8.0 o posteriores. Requiere la versión 11.0 o posteriores para incluir el campo |
| Se envía una notificación cuando el destinatario ha leído un mensaje. |
| Se envía una notificación cuando un cliente hace clic en un enlace |
| Cuando el flujo de mensajes tiene varias aplicaciones, se envía una notificación cuando un cliente envía un mensaje a tu empresa, pero la aplicación no controla la conversación en el momento en que se envió el mensaje. |
A continuación, se incluyen ejemplos de los tipos de notificaciones de webhooks que puedes recibir.
{ "object": "instagram", "entry": [ { "id": "IGID", // ID of your Instagram Professional account "time": 1569262486134, "messaging": [ { "sender": { "id": "IGSID" }, // Instagram-scoped ID for the customer who sent the message "recipient": { "id": "IGID" }, // ID of your Instagram Professional account "timestamp": 1569262485349, "message": { "mid": "MESSAGE-ID", // ID of the message sent to your business "text": "MESSAGE-TEXT" // Included when a customer sends a message containing text "attachments": [ // Included when a customer sends multiple media attachments or a URL for a story mention or share { "type":"image", // Can be audio, file, image (image or sticker), share, story_mention, or video "payload":{ "url":"LINK" } }, { "type":"video", "payload":{ "url":"LINK" } } ] "is_deleted": true // Included when a customer deletes a message "is_echo": true // Included when your business sends a message to the customer "is_unsupported": true, // Included when a customer sends a message with unsupported media "quick_reply": { // Included when a customer clicks a quick reply "payload": "CUSTOMER-RESPONSE-PAYLOAD" // The payload with the option selected by the customer }, "referral": { // Included when a customer clicks an Instagram Shop product "product": { "id": "PRODUCT-ID" } "referral": { // Included when a customer clicks an CTD ad "ref": "REF-DATA-IN-AD-IF-SPECIFIED" "ad_id": AD-ID, "source": "ADS", "type": "OPEN_THREAD", "ads_context_data": { "ad_title": TITLE-FOR-THE-AD, "photo_url": IMAGE-URL-THAT-WAS-CLICKED, "video_url": THUMBNAIL-URL-FOR-THE-AD-VIDEO, } } "reply_to":{ // Included when a customer sends an inline reply "mid":"MESSAGE-ID" } "reply_to": { // Included when a customer replies to a story "story": { "url":"CDN-URL", "id":"STORY-ID" } } } } ] } ] }
{ "object": "instagram", "entry": [ { "id": "IGID", // ID for your Instagram Professional account "time": 1569262486134, "messaging": [ { "sender": { "id": "IGSID" // Instagram-scoped ID for the customer who sent the message }, "recipient": { "id": "IGID" // ID for your Instagram Professional account }, "timestamp": 1569262485349, "reaction" :{ "mid" : "MESSAGE-ID", "action": "react", // or unreact "reaction": "love", // optional, to unreact if there is no reaction field "emoji": "\u{2764}\u{FE0F}" // optional, to unreact if there is no emoji field } } ] } ] }
{ "object": "instagram", "entry": [ { "id": "IGSID", // ID of your Instagram Professional account "time": 1502905976963, "messaging": [ { "sender": { "id": "IGSID" }, // Instagram-scoped ID for the customer who sent the message "recipient": { "id": "IGID" }, // ID of your Instagram Professional account "timestamp": 1502905976377, "postback": { "mid":"MESSAGE-ID", // ID for the message sent to your business "title": "SELECTED-ICEBREAKER-REPLY-OR-CTA-BUTTON", "payload": "CUSTOMER-RESPONSE-PAYLOAD", // The payload with the option selected by the customer } } ] } ] }
{ "object": "instagram", "entry": [ { "id": "IGSID", // ID of your Instagram Professional account "time": 1502905976963, "messaging": [ { "sender": { "id": "IGSID" // Instagram-scoped ID for the customer who sent the message }, "recipient": { "id": "IGID" // ID of your Instagram Professional account }, "timestamp": 1502905976377, "referral": { "ref": "INFORMATION-INCLUDED-IN-REF-PARAMETER-OF-IGME-LINK" "source": "IGME-SOURCE-LINK" "type": "OPEN_THREAD" // Only supported for existing conversations } } ] } ] }
{ "object":"instagram", "entry":[ { "id":"IGID", // ID for your Instagram Professional account "time":1569262486134, "messaging":[ { "sender":{ "id":"IGSID" // Instagram-scoped ID for the customer who sent the message }, "recipient":{ "id":"IGID" // ID for your Instagram Professional account }, "timestamp":1569262485349, "read":{ "mid":"MESSAGE-ID" } } ] } ] }