messages Webhook 事件參考資料

當訊息傳送到您的粉絲專頁時,將發生此回呼。訊息一律按順序傳送。您可能會收到文字訊息或具有附件的訊息。

imageaudiovideofilereel 附件類型是主要支援的類型。您也可能會收到 fallback 附件。「遞補」的一個常見範例是,當用戶與粉絲專頁分享網址時,會依據連結分享建立附件。對於用戶在您的粉絲專頁上進行不支援的分享,可能會傳送沒有 fallback 的裝載。

您可以在設定 Webhook 時透過選擇 message 訂閱此回呼。

範例

文字訊息

{
  "sender":{
    "id":"<PSID>"
  },
  "recipient":{
    "id":"<PAGE_ID>"
  },
  "timestamp":1458692752478,
  "message":{
    "mid":"mid.1457764197618:41d102a3e1ae206a38",
    "text":"hello, world!",
    "quick_reply": {
      "payload": "<DEVELOPER_DEFINED_PAYLOAD>"
    }
  }
}    

回覆訊息

{
  "sender":{
    "id":"<PSID>"
  },
  "recipient":{
    "id":"<PAGE_ID>"
  },
  "timestamp":1458692752478,
  "message":{
    "mid":"m_1457764197618:41d102a3e1ae206a38",
    "text":"hello, world!",
    "reply_to": {
      "mid":"m_1fTq8oLumEyIp3Q2MR-aY7IfLZDamVrALniheU"
    }
  }
}    

具有附件的訊息

{
  "id": "682498302938465",
  "time": 1518479195594,
  "messaging": [
    {
      "sender": {
        "id": "

具有產品範本的訊息

具有產品範本訊息 Webhook 僅適用於圖形 API v8.0 以上版本

該 Webhook 適用於用戶從其他貼文串分享產品或將流量分享到頁面的場景。此 Webhook 僅限於頁面擁有的產品。應用程式需要有經過核准的 catalog_management 權限,才能在 Webhooks 中接收產品詳細資料。

{
  "id": "682498302938465",
  "time": 1518479195594,
  "messaging": [
    {
      "sender": {
        "id": "

含遞補附件的訊息

適用於 +v6.0 版本 messages 的範例

{
    "object": "page",
    "entry": [
        {
            "id": "<PAGE_ID>",
            "time": 1583173667623,
            "messaging": [
                {
                    "sender": {
                        "id": "<PSID>"
                    },
                    "recipient": {
                        "id": "<PAGE_ID>"
                    },
                    "timestamp": 1583173666767,
                    "message": {
                        "mid": "m_toDnmD...",
                        "text": "This is where I want to go: https:\/\/youtu.be\/bbo_fZAjIhg",
                        "attachments": [
                            {
                                "type": "fallback",
                                "payload": {
                                    "url": "<ATTACHMENT_URL >",
                                    "title": "TAHITI - Heaven on Earth"
                                }
                            }
                        ]
                    }
                }
            ]
        }
    ]
}

來自商店產品詳細資訊頁面的訊息

來自商店產品詳細資訊頁面的訊息 Webhook 僅適用於圖形 API 8.0 以上版本

{
  "sender":{
    "id":"<PSID>"
  },
  "recipient":{
    "id":"<PAGE_ID>"
  },
  "timestamp":1458692752478,
  "message":{
    "mid":"mid.1457764197618:41d102a3e1ae206a38",
    "text":"hello, world!",
    "referral": {
      "product": {
        "id":"<PRODUCT_ID>"
      }
    }
  }
}    

具有指令的訊息

{
  "object": "page",
  "entry": [
    {
      "id": "<PAGE_ID>",
      "time": 1697643211842,
      "messaging": [
        {
          "sender": {
            "id": "<PSID>"
          },
          "recipient": {
            "id": "<PAGE_ID>"
          },
          "timestamp": 1697643027400,
          "message": {
            "mid": "m_3vs...",
            "text": "find flights from SFO to LAX next Thursday",
            "commands": [
              {
                "name": "flights"
              }
            ]
          }
        }
      ]
    }
  ]
}

屬性

sender

屬性型別說明

id

字串

觸發 Webhook 事件的用戶 PSID。

user_ref

字串

觸發 Webhook 事件的用戶 ser_ref,僅適用於洽談外掛程式的 Webhook 事件。

recipient

屬性型別說明

id

字串

您的粉絲專頁編號。

message

2020 年 3 月 4 日公告

對於 +v6.0 sticker_id 已從 message 移至 message.attachments.payload

屬性 類型 說明

mid

字串

訊息編號

text

字串

訊息文字

quick_reply

物件

進行傳送之應用程式提供的選用性自訂資料

reply_to

物件

此訊息正在回覆的訊息編號(mid)參考資料

attachments

陣列<attachment>

包含附件資料的陣列

referral

物件

從商店產品詳細資訊頁面轉介訊息。

message.quick_reply

只有當用戶點擊快速回覆按鈕時,才會透過文字訊息提供 quick_reply 裝載。

屬性 類型 說明

payload

字串

應用程式提供的自訂資料

message.reply_to

屬性 類型 說明

mid

字串

此訊息正在回覆的訊息編號參考資料

message.attachments

屬性 類型 說明

type

字串

audiofileimagevideofallbackreel

payload

字串

message.attachments.payload

message.attachments.payload

屬性 類型 說明

url

字串

附件類型的網址。適用附件類型:audiofileimagevideofallbackreel

title

字串

附件的標題。適用附件類型:fallbackreel

sticker_id

數字

此貼圖的永久編號,例如 369239263222822 引用「讚」貼圖。適用附件類型:image(僅在發送貼圖時)。

reel_video_id

數字

與附加連續短片相關聯的影片編號。適用附件類型:reel

message.attachments.payload.product.elements

屬性 類型 說明

id

字串

Facebook 商品目錄中的產品編號

retailer_id

字串

與產品相關聯的外部編號。(例如:SKU/內容編號)

image_url

字串

產品網址

title

字串

產品標題

subtitle

字串

產品副標題

message.referral

只有當用戶從商店產品詳細資訊頁面發送訊息時才提供 referral 裝載。

屬性 類型 說明

product

物件

產品資訊

message.referral.product

屬性 類型 說明

id

字串

產品編號

message.commands

屬性 類型 說明

name

字串

指令名稱