messages
Webhook 事件參考資料當有訊息傳送到專頁時,此回呼便會出現。系統一律會順序傳送訊息。您可能會收到文字訊息或包含附件的訊息。
image
、audio
、video
或 file
是主要的支援附件類型。此外,您還可能收到 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 只適用於 Graph 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 只適用於 Graph API v8.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
sender Field | Description |
---|---|
| The Page-scoped ID for the person who sent a message to your business |
| The reference for a person who used the Chat Plugin to messsage your business |
recipient
recipient Field | Description |
---|---|
| The ID for your Facebook Page |
message
我們將 v6.0 版及以上版本的 sticker_id
從 message
移至 message.attachments.payload
屬性 | 類型 | 說明 |
---|---|---|
| 字串 | 訊息編號 |
| 字串 | 訊息文字 |
| 物件 | (選用項目)傳送內容的應用程式所提供的自訂資料 |
| 物件 | 此訊息要回覆的訊息編號(mid)之引用資料 |
| 陣列 < | 包含附件資料的陣列 |
| 物件 | 「商店」商品詳情頁面的訊息之引用來源。 |
message.quick_reply
當用戶點按快速回覆按鈕時,系統只會提供包含文字訊息的 quick_reply
裝載。
屬性 | 類型 | 說明 |
---|---|---|
| 字串 | 應用程式提供的自訂資料 |
message.reply_to
屬性 | 類型 | 說明 |
---|---|---|
| 字串 | 此訊息要回覆的訊息編號之引用資料 |
message.attachments
屬性 | 類型 | 說明 |
---|---|---|
| 字串 |
|
| 字串 |
message.attachments.payload
屬性 | 類型 | 說明 |
---|---|---|
| 字串 | 附件類型的網址。適用的附件類型: |
| 字串 | 附件標題。適用的附件類型: |
| 數字 | 此貼圖的永久編號,例如, |
message.attachments.payload.product.elements
屬性 | 類型 | 說明 |
---|---|---|
| 字串 | 來自 Facebook 商品目錄的商品編號 |
| 字串 | 與商品關聯的外部編號。(例如 SKU 或內容編號) |
| 字串 | 商品網址 |
| 字串 | 商品標題 |
| 字串 | 商品副標題 |
message.referral
僅在用戶從「商店」商品詳情頁面傳送訊息時,系統才會提供 referral
裝載。
屬性 | 類型 | 說明 |
---|---|---|
| 物件 | 商品資訊 |
message.referral.product
屬性 | 類型 | 說明 |
---|---|---|
| 字串 | 商品編號 |
message.commands
屬性 | 類型 | 說明 |
---|---|---|
| 字串 | 指令的名稱 |