Dans cet exemple, un·e client·e vous a envoyé un message texte :
{ "object": "whatsapp_business_account", "entry": [ { "id": "<WHATSAPP_BUSINESS_ACCOUNT_ID>", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "<BUSINESS_DISPLAY_PHONE_NUMBER>", "phone_number_id": "<BUSINESS_PHONE_NUMBER_ID>" }, "contacts": [ { "profile": { "name": "<WHATSAPP_USER_NAME>" }, "wa_id": "<WHATSAPP_USER_ID>" } ], "messages": [ { "from": "<WHATSAPP_USER_PHONE_NUMBER>", "id": "<WHATSAPP_MESSAGE_ID>", "timestamp": "<WEBHOOK_SENT_TIMESTAMP>", "text": { "body": "<MESSAGE_BODY_TEXT>" }, "type": "text" } ] }, "field": "messages" } ] } ] }
Dans cet exemple, un·e client·e vous a envoyé un message de réaction. Vous ne recevrez pas ce webhook si le message auquel le client ou la cliente réagit date de plus de 30 jours.
{ "object": "whatsapp_business_account", "entry": [{ "id": "WHATSAPP_BUSINESS_ACCOUNT_ID", "changes": [{ "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": PHONE_NUMBER, "phone_number_id": PHONE_NUMBER_ID }, "contacts": [{ "profile": { "name": "NAME" }, "wa_id": PHONE_NUMBER }], "messages": [{ "from": PHONE_NUMBER, "id": "wamid.ID", "timestamp": TIMESTAMP, "reaction": { "message_id": "MESSAGE_ID", "emoji": "EMOJI" }, "type": "reaction" }] }, "field": "messages" }] }] }
Notez que pour les réactions, la valeur timestamp
indique la date d’envoi de la réaction par le client ou la cliente et non la date de génération du webhook.
Lorsqu’un message avec du contenu multimédia est reçu, la plateforme WhatsApp Business télécharge le contenu en question. Une notification est envoyée à votre webhook quand le téléchargement est terminé.
La notification Webhook contient des informations qui identifient l’objet multimédia et vous permettent de trouver et de récupérer l’objet. Utilisez les points de terminaison du contenu multimédia pour récupérer ce contenu.
{ "object": "whatsapp_business_account", "entry": [{ "id": "WHATSAPP_BUSINESS_ACCOUNT_ID", "changes": [{ "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": PHONE_NUMBER, "phone_number_id": PHONE_NUMBER_ID }, "contacts": [{ "profile": { "name": "NAME" }, "wa_id": "WHATSAPP_ID" }], "messages": [{ "from": PHONE_NUMBER, "id": "wamid.ID", "timestamp": TIMESTAMP, "type": "image", "image": { "caption": "CAPTION", "mime_type": "image/jpeg", "sha256": "IMAGE_HASH", "id": "ID" } }] }, "field": "messages" }] }] }
Lorsque vous recevez un sticker, la notification suivante vous parvient :
{ "object": "whatsapp_business_account", "entry": [ { "id": "ID", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "PHONE_NUMBER", "phone_number_id": "PHONE_NUMBER_ID" }, "contacts": [ { "profile": { "name": "NAME" }, "wa_id": "ID" } ], "messages": [ { "from": "SENDER_PHONE_NUMBER", "id": "wamid.ID", "timestamp": "TIMESTAMP", "type": "sticker", "sticker": { "mime_type": "image/webp", "sha256": "HASH", "id": "ID" } } ] }, "field": "messages" } ] } ] }
Il est possible de recevoir une notification de rappel de message inconnu. Par exemple, il se peut qu’un·e client·e vous envoie un message non pris en charge, tel qu'un message éphémère (auquel cas, nous l’avertirions que ce type de message n'est pas pris en charge).
Dans cet exemple, vous avez reçu un message d’un client ou d’une cliente qui n’est pas pris en charge.
{ "object": "whatsapp_business_account", "entry": [{ "id": "WHATSAPP_BUSINESS_ACCOUNT_ID", "changes": [{ "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "PHONE_NUMBER", "phone_number_id": "PHONE_NUMBER_ID" }, "contacts": [{ "profile": { "name": "NAME" }, "wa_id": "WHATSAPP_ID" }], "messages": [{ "from": "PHONE_NUMBER", "id": "wamid.ID", "timestamp": "TIMESTAMP", "errors": [ { "code": 131051, "details": "Message type is not currently supported", "title": "Unsupported message type" }], "type": "unknown" }] } "field": "messages" }], }] }
Dans cet exemple, vous avez reçu un message de localisation d’un client ou d’une cliente :
{ "object": "whatsapp_business_account", "entry": [{ "id": "WHATSAPP_BUSINESS_ACCOUNT_ID", "changes": [{ "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "PHONE_NUMBER", "phone_number_id": "PHONE_NUMBER_ID" }, "contacts": [{ "profile": { "name": "NAME" }, "wa_id": "WHATSAPP_ID" }], "messages": [{ "from": "PHONE_NUMBER", "id": "wamid.ID", "timestamp": "TIMESTAMP", "location": { "latitude": LOCATION_LATITUDE, "longitude": LOCATION_LONGITUDE, "name": LOCATION_NAME, "address": LOCATION_ADDRESS, } }] }, "field": "messages" }] }] }
Dans cet exemple, vous avez reçu un message de contact d’un client ou d’une cliente :
{ "object":"whatsapp_business_account", "entry":[{ "id":"WHATSAPP_BUSINESS_ACCOUNT_ID", "changes":[{ "value":{ "messaging_product":"whatsapp", "metadata": { "display_phone_number":"PHONE_NUMBER", "phone_number_id":"PHONE_NUMBER_ID" }, "contacts": [{ "profile":{ "name":"NAME" }, "wa_id":"WHATSAPP_ID" }], "messages":[{ "from":"PHONE_NUMBER", "id":"wamid.ID", "timestamp":"TIMESTAMP", "contacts":[{ "addresses":[{ "city":"CONTACT_CITY", "country":"CONTACT_COUNTRY", "country_code":"CONTACT_COUNTRY_CODE", "state":"CONTACT_STATE", "street":"CONTACT_STREET", "type":"HOME or WORK", "zip":"CONTACT_ZIP" }], "birthday":"CONTACT_BIRTHDAY", "emails":[{ "email":"CONTACT_EMAIL", "type":"WORK or HOME" }], "name":{ "formatted_name":"CONTACT_FORMATTED_NAME", "first_name":"CONTACT_FIRST_NAME", "last_name":"CONTACT_LAST_NAME", "middle_name":"CONTACT_MIDDLE_NAME", "suffix":"CONTACT_SUFFIX", "prefix":"CONTACT_PREFIX" }, "org":{ "company":"CONTACT_ORG_COMPANY", "department":"CONTACT_ORG_DEPARTMENT", "title":"CONTACT_ORG_TITLE" }, "phones":[{ "phone":"CONTACT_PHONE", "wa_id":"CONTACT_WA_ID", "type":"HOME or WORK>" }], "urls":[{ "url":"CONTACT_URL", "type":"HOME or WORK" }] }] }] }, "field":"messages" }] }] }
Une réponse est envoyée lorsque votre client·e clique sur un bouton de réponse rapide dans un modèle de message interactif. Voici un exemple de format de rappel.
{ "object": "whatsapp_business_account", "entry": [{ "id": "WHATSAPP_BUSINESS_ACCOUNT_ID", "changes": [{ "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": PHONE_NUMBER, "phone_number_id": PHONE_NUMBER_ID }, "contacts": [{ "profile": { "name": "NAME" }, "wa_id": "WHATSAPP_ID" }], "messages": [{ "context": { "from": PHONE_NUMBER, "id": "wamid.ID" }, "from": "16315551234", "id": "wamid.ID", "timestamp": TIMESTAMP, "type": "button", "button": { "text": "No", "payload": "No-Button-Payload" } }] }, "field": "messages" }] }] }
Un utilisateur ou une utilisatrice reçoit la notification webhook suivante lorsqu’il ou elle clique sur un élément dans un message de liste que vous avez envoyé :
{ "object": "whatsapp_business_account", "entry": [ { "id": "WHATSAPP_BUSINESS_ACCOUNT_ID", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "PHONE_NUMBER", "phone_number_id": "PHONE_NUMBER_ID", }, "contacts": [ { "profile": { "name": "NAME" }, "wa_id": "PHONE_NUMBER_ID" } ], "messages": [ { "from": PHONE_NUMBER_ID, "id": "wamid.ID", "timestamp": TIMESTAMP, "interactive": { "list_reply": { "id": "list_reply_id", "title": "list_reply_title", "description": "list_reply_description" }, "type": "list_reply" }, "type": "interactive" } ] }, "field": "messages" } ] } ] }
Un utilisateur ou une utilisatrice reçoit la notification webhook suivante lorsqu’il ou elle clique sur un bouton de réponse que vous avez envoyé :
{ "object": "whatsapp_business_account", "entry": [ { "id": "WHATSAPP_BUSINESS_ACCOUNT_ID", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "PHONE_NUMBER", "phone_number_id": PHONE_NUMBER_ID, }, "contacts": [ { "profile": { "name": "NAME" }, "wa_id": "PHONE_NUMBER_ID" } ], "messages": [ { "from": PHONE_NUMBER_ID, "id": "wamid.ID", "timestamp": TIMESTAMP, "interactive": { "button_reply": { "id": "unique-button-identifier-here", "title": "button-text", }, "type": "button_reply" }, "type": "interactive" } ] }, "field": "messages" } ] } ] }
Une conversation démarre dès qu’un·e utilisateur·ice a cliqué sur une publicité contenant un call-to-action de clic vers WhatsApp. Vous recevez alors le webhook suivant :
{ "object": "whatsapp_business_account", "entry": [ { "id": "ID", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "PHONE_NUMBER", "phone_number_id": "PHONE_NUMBER_ID" }, "contacts": [ { "profile": { "name": "NAME" }, "wa_id": "ID" } ], "messages": [ { "referral": { "source_url": "AD_OR_POST_FB_URL", "source_id": "ADID", "source_type": "ad or post", "headline": "AD_TITLE", "body": "AD_DESCRIPTION", "media_type": "image or video", "image_url": "RAW_IMAGE_URL", "video_url": "RAW_VIDEO_URL", "thumbnail_url": "RAW_THUMBNAIL_URL", "ctwa_clid": "CTWA_CLID" }, "from": "SENDER_PHONE_NUMBERID", "id": "wamid.ID", "timestamp": "TIMESTAMP", "type": "text", "text": { "body": "BODY" } } ] }, "field": "messages" } ] } ] }
Vous recevez un message de demande d’informations sur un produit lorsqu’un·e client·e demande des informations supplémentaires sur un produit. Cela peut se produire dans les cas suivants :
Une notification de webhooks pour un message de demande d’informations sur un produit se présente comme suit :
{ "object": "whatsapp_business_account", "entry": [ { "id": "ID", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "PHONE_NUMBER", "phone_number_id": "PHONE_NUMBER_ID", }, "contacts": [ { "profile": { "name": "NAME" }, "wa_id": "PHONE_NUMBER_ID" } ], "messages": [ { "from": "PHONE_NUMBER", "id": "wamid.ID", "text": { "body": "MESSAGE_TEXT" }, "context": { "from": "PHONE_NUMBER", "id": "wamid.ID", "referred_product": { "catalog_id": "CATALOG_ID", "product_retailer_id": "PRODUCT_ID" } }, "timestamp": "TIMESTAMP", "type": "text" } ] }, "field": "messages" } ] } ] }
Une notification webhooks pour le placement d’une commande par un·e client·e se présente comme suit :
{ "object": "whatsapp_business_account", "entry": [ { "id": "8856996819413533", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "16505553333", "phone_number_id": "phone-number-id", }, "contacts": [ { "profile": { "name": "Kerry Fisher" }, "wa_id": "16315551234" } ], "messages": [ { "from": "16315551234", "id": "wamid.ABGGFlCGg0cvAgo6cHbBhfK5760V", "order": { "catalog_id": "the-catalog_id", "product_items": [ { "product_retailer_id":"the-product-SKU-identifier", "quantity":"number-of-item", "item_price":"unitary-price-of-item", "currency":"price-currency" }, ... ], "text":"text-message-sent-along-with-the-order" }, "context": { "from": "16315551234", "id": "wamid.gBGGFlaCGg0xcvAdgmZ9plHrf2Mh-o" }, "timestamp": "1603069091", "type": "order" } ] }, "field": "messages" } ] } ] }
Lorsqu’un·e utilisateur·ice change son numéro de téléphone sur WhatsApp, vous recevez une notification de message système :
{ "object": "whatsapp_business_account", "entry": [{ "id": "WHATSAPP_BUSINESS_ACCOUNT_ID", "changes": [{ "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": PHONE_NUMBER, "phone_number_id": PHONE_NUMBER_ID }, "messages": [{ "from": PHONE_NUMBER, "id": "wamid.ID", "system": { "body": "NAME changed from PHONE_NUMBER to PHONE_NUMBER", "new_wa_id": NEW_PHONE_NUMBER, "type": "user_changed_number" }, "timestamp": TIMESTAMP, "type": "system" }] }, "field": "messages" }] }] }
La plateforme WhatsApp Business vous envoie des notifications vous informant du statut des messages échangés entre vous et les utilisateur·ices. Lorsqu’un message est bien envoyé, vous recevez une notification une fois que le message est envoyé, distribué et lu. L’ordre de ces notifications dans votre application peut ne pas correspondre au statut du message en temps réel. Il peut être nécessaire de s’en assurer en vérifiant l’horodatage.
{ "object": "whatsapp_business_account", "entry": [ { "id": "<WHATSAPP_BUSINESS_ACCOUNT_ID>", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "<BUSINESS_DISPLAY_PHONE_NUMBER>", "phone_number_id": "<BUSINESS_PHONE_NUMBER_ID>" }, "statuses": [ { "id": "<WHATSAPP_MESSAGE_ID>", "status": "sent", "timestamp": "<WEBHOOK_SENT_TIMESTAMP>", "recipient_id": "<WHATSAPP_USER_ID>", "conversation": { "id": "<CONVERSATION_ID>", "expiration_timestamp": "<CONVERSATION_EXPIRATION_TIMESTAMP>", "origin": { "type": "<CONVERSATION_CATEGORY>" } }, "pricing": { "billable": <IS_BILLABLE?>, "pricing_model": "CBP", "category": "<CONVERSATION_CATEGORY>" } } ] }, "field": "messages" } ] } ] }
Pour les conversations avec point d’entrée gratuit, origin.type
et pricing.category
sont tous deux définis sur referral_conversion
, et pricing.billable
est défini sur false
.
Vous recevez la notification suivante lorsqu’un message d’entreprise est distribué et qu’il fait partie d’une conversation lancée par un particulier (si cette conversation ne provient pas d’un point d’entrée gratuit) :
{ "object": "whatsapp_business_account", "entry": [ { "id": "<WHATSAPP_BUSINESS_ACCOUNT_ID>", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "<BUSINESS_DISPLAY_PHONE_NUMBER>", "phone_number_id": "<BUSINESS_PHONE_NUMBER_ID>" }, "statuses": [ { "id": "<WHATSAPP_MESSAGE_ID>", "status": "sent", "timestamp": "<WEBHOOK_SENT_TIMESTAMP>", "recipient_id": "<WHATSAPP_USER_ID>", "conversation": { "id": "<CONVERSATION_ID>", "origin": { "type": "<CONVERSATION_CATEGORY>" } }, "pricing": { "billable": <IS_BILLABLE?>, "pricing_model": "CBP", "category": "<CONVERSATION_CATEGORY>" } } ] }, "field": "messages" } ] } ] }
Pour les conversations avec point d’entrée gratuit, origin.type
et pricing.category
sont tous deux définis sur referral_conversion
, et pricing.billable
est défini sur false
.
{ "object": "whatsapp_business_account", "entry": [ { "id": "<WHATSAPP_BUSINESS_ACCOUNT_ID>", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "<BUSINESS_DISPLAY_PHONE_NUMBER>", "phone_number_id": "<BUSINESS_PHONE_NUMBER_ID>" }, "statuses": [ { "id": "<WHATSAPP_MESSAGE_ID>", "status": "read", "timestamp": "<WEBHOOK_SENT_TIMESTAMP>", "recipient_id": "<WHATSAPP_USER_ID>" } ] }, "field": "messages" } ] } ] }
Actuellement, l’API Cloud ne prend pas en charge les mises à jour de statut des webhooks pour les messages supprimés. Lorsqu’un utilisateur ou une utilisatrice supprime un message, vous recevez un webhook contenant un code d’erreur relatif à un type de message non pris en charge :
{ "object": "whatsapp_business_account", "entry": [{ "id": "WHATSAPP_BUSINESS_ACCOUNT_ID", "changes": [{ "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": PHONE_NUMBER, "phone_number_id": PHONE_NUMBER }, "contacts": [{ "profile": { "name": "NAME" }, "wa_id": PHONE_NUMBER }], "messages": [{ "from": PHONE_NUMBER, "id": "wamid.ID", "timestamp": TIMESTAMP, "errors": [{ "code": 131051, "details": "Message type is not currently supported", "title": "Unsupported message type" }], "type": "unsupported" }] }, "field": "messages" }] }] }
Veuillez noter qu’il existe d’autres comportements d’utilisateurs ou d’utilisatrices qui peuvent déclencher l’envoi du même message d’erreur.
{ "object": "whatsapp_business_account", "entry": [ { "id": "<WHATSAPP_BUSINESS_ACCOUNT_ID>", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "<BUSINESS_DISPLAY_PHONE_NUMBER>", "phone_number_id": "<BUSINESS_PHONE_NUMBER_ID>" }, "statuses": [ { "id": "<WHATSAPP_MESSAGE_ID>", "status": "failed", "timestamp": "<WEBHOOK_SENT_TIMESTAMP>", "recipient_id": "<WHATSAPP_USER_ID>", "errors": [ { "code": <ERROR_CODE>, "title": "<ERROR_TITLE>", "message": "<ERROR_MESSAGE>", "error_data": { "details": "<ERROR_DETAILS>" }, "href": "https://developers.facebook.com/docs/whatsapp/cloud-api/support/error-codes/" } ] } ] }, "field": "messages" } ] } ] }