فيما يلي مثال على رسالة نصية استلمتها من أحد العملاء:
{ "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" } ] } ] }
فيما يلي مثال على رسالة التفاعلات التي تلقيتها من أحد العملاء. لن تتلقى حدث webhook هذا إذا كانت الرسالة التي يتفاعل معها العميل موجودة لأكثر من 30 يومًا.
{ "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" }] }] }
لاحظ أنه بالنسبة للتفاعلات، تشير القيمة timestamp
إلى وقت إرسال العميل للتفاعل، وليس وقت إنشاء حدث webhook.
عند تلقي رسالة تتضمن وسائط، ستقوم منصة واتساب للأعمال بتنزيل الوسائط. يتم إرسال إشعار إلى Webhook لديك بمجرد تنزيل الوسائط.
يحتوي إشعار Webhook على المعلومات التي تُحدد كائن الوسائط وتتيح لك العثور على الكائن واسترداده. استخدم نقاط نهاية الوسائط لاسترداد الوسائط.
{ "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" }] }] }
عندما تتلقى ملصقًا، ستستقبل الإشعار التالي:
{ "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" } ] } ] }
من الممكن أن تتلقى إشعار بوجود استدعاء رسالة غير معروف. على سبيل المثال، يمكن للعميل أن يرسل لك رسالة غير مدعومة، مثل رسالة مؤقتة (في تلك الحالة، نبلغ العميل بأن نوع الرسالة غير مدعوم).
فيما يلي مثال على رسالة تلقيتها من عميل غير مدعوم.
{ "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" }], }] }
فيما يلي مثال على رسالة الموقع التي تلقيتها من أحد العملاء:
{ "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" }] }] }
فيما يلي مثال على رسالة جهة اتصال استلمتها من أحد العملاء:
{ "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" }] }] }
عندما ينقر العميل لديك على زر الرد السريع في قالب رسالة تفاعلي، يتم إرسال استجابة. وفيما يلي مثال على تنسيق الاستدعاء.
{ "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" }] }] }
يتم استلام إشعار webhook التالي عندما ينقر المستخدم على عنصر من رسالة قائمة المعروضات التي أرسلتها:
{ "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" } ] } ] }
يتم استلام إشعار webhook التالي عندما ينقر المستخدم على زر الرد الذي أرسلته:
{ "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" } ] } ] }
يمكنك الحصول على حدث webhook التالي عند بدء المحادثة بعدما ينقر المستخدم على إعلان يتضمن زر دعوة لاتخاذ إجراء في واتساب:
{ "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" } ] } ] }
يتم استلام رسالة الاستعلام عن المنتج عندما يطلب العميل المزيد من المعلومات حول المنتج. ويمكن حدوث ذلك عندما:
يبدو إشعار webhooks لرسالة الاستعلام عن المنتج كما يلي:
{ "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" } ] } ] }
يبدو إشعار webhooks عندما يسجل العميل طلبًا كما يلي:
{ "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" } ] } ] }
عندما يغير المستخدم رقم هاتفه على واتساب، تتلقى إشعارًا برسالة نظام:
{ "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" }] }] }
ترسل منصة واتساب للأعمال إشعارات لإعلامك بحالة الرسائل بينك وبين المستخدمين. عند إرسال رسالة بنجاح، ستتلقى إشعارًا عند إرسال الرسالة وتسليمها وقراءتها. وربما لا يعكس ترتيب هذه الإشعارات في تطبيقك التوقيت الفعلي لحالة الرسالة. اعرض الطابع الزمني لتحديد التوقيت، إذا لزم الأمر.
{ "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" } ] } ] }
بالنسبة إلى محادثات نقاط الإدخال المجانية ويتم تعيين كل من origin.type
وpricing.category
على referral_conversion
، وتعيين pricing.billable
على 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": "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" } ] } ] }
بالنسبة إلى محادثات نقاط الإدخال المجانية ويتم تعيين كل من origin.type
وpricing.category
على referral_conversion
، وتعيين pricing.billable
على 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" } ] } ] }
لا تدعم API السحابة تحديثات حالة webhook للرسائل المحذوفة في الوقت الحالي. إذا حذف المستخدم رسالة، فستتلقى حدث webhook يتضمن رمز خطأ لنوع رسالة غير مدعوم:
{ "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" }] }] }
لاحظ أن هناك سلوكيات مستخدم أخرى يمكن أن تؤدي إلى ظهور رسالة الخطأ نفسها.
{ "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" } ] } ] }