這份文件已更新。
中文(香港) 的翻譯尚未完成。
英文更新時間:2022年7月15日

Webhook 事件參考資料

Webhook 事件是 Messenger 平台向您的 Bot 發出通知的方式;當發生各種互動或事件(包括用戶傳送訊息)時,便會發出通知。Webhook 事件會以 POST 要求的形式,由 Messenger 平台傳送至您的 Webhook。

注意:您需要為企業的所有訊息應用程式訂閱訊息 Webhooks。

內容

Webhook 事件清單

以下是 Messenger 平台可向您的 Webhook 傳送的事件清單。

注意:建議您使用最新版本的 API 來接收每個 Webhook 的所有資訊。

Messaging Webhooks Field Description

message_deliveries

A notification is sent when a message that was sent by your business has been delivered to a customer. Only available for Messenger conversations.

message_echoes

A notification is sent when your business has sent a message. Only availalbe for Messenger conversations. For Instagram Messaging conversations, the message webhook will be triggered.

message_edits

A notification is sent when a customer edits a previously-sent message. Only availalbe for Messenger conversations.

message_reactions

A notification is sent when a customer reacts to a message sent by your business.

message_reads

A notification is sent when a customer reads a message sent by your business, for Messenger conversations. See messaging_seen for Instagram Messaging conversations.

messages

A notification is sent when your business has received a message from a customer from any conversation entry point. For Instagram Messaging, a notification is also sent when your Instagram Professional account has sent a message since message_echoes is not supported for Instagram Messaging.

messaging_account_linking

A notification is sent when a customer links or unlinks their Messenger account from their account with your business. Only available for Messenger conversations.

messaging_feedback

A notification is sent when a person has submitted feedback for your business. Only available for Messenger conversations.

messaging_game_plays

A notification is sent when a person has played a round of an Instant Game. Only available for Messenger conversations.

messaging_handovers

A notification is sent when a change has occurred during the Handover Protocol

messaging_optins

A notification is sent when a customer has clicked a Messenger plugin, accepted a message request using customer matching, or has opted in to receive messages via the checkbox plugin. Only available for Messenger conversations.

messaging_policy_enforcement

A notification is sent when a policy enforcement warning has been sent or a policy enforcement action has been taken on the app associated with the Page.

messaging_postbacks

A notification is sent when a customer clicks a postback button, Get Started button, or persistent menu item for Messenger conversations or an Icebreaker option or Generic Template button for Instagram Messaging conversations.

messaging_referrals

A notification is sent when a customer resumes a conversation with the Page by clicking an ig.me or m.me link, an ad or chat plugin.

messaging_seen

A notification is sent when a customer reads a message sent by your business, for Instagram Messaging conversations. See messaging_reads for Messenger conversations.

send_cart

A notification is sent when your business has received a message from a customer, when the message contains cart/order information. Only available for Messenger conversations.

standby

A notification is sent when a conversation is idle for an app during the Handover Protocol

事件格式

所有 Messenger 平台的回呼都有一組通用屬性,可提供所需資訊以讓您處理並回覆用戶使用您的 Bot 輸入的內容。除了下列屬性之外,每個事件也包含特定的屬性,用以說明該事件的詳細情況。

{
  "object":"page",
  "entry":[
    {
      "id":"<PAGE_ID>",
      "time":1458692752478,
      "messaging":[
        {
          "sender":{
            "id":"<PSID>"
          },
          "recipient":{
            "id":"<PAGE_ID>"
          },

          ...
        }
      ]
    }
  ]
}

屬性

屬性 類型 說明

object

字串

值為 page

entry

entry 的陣列

包含事件資料的陣列

entry

屬性 類型 說明

id

字串

專頁的專頁編號

time

數字

更新時間(以毫秒為單位的 Epoch 時間)

messaging

陣列<messaging>

包含一個 messaging 物件的陣列。請注意,雖然這是一個陣列,但只包含一個 messaging 物件。

entry.messaging

屬性 類型 說明

sender.id

字串

傳送者用戶編號

recipient.id

字串

傳送對象用戶編號