我們即將停用內部部署 API。請參閱我們的內部部署 API 停用文件以取得詳細資訊,並瞭解如何轉移到我們的新一代雲端 API。
本指南說明傳送每一種互動式訊息選項的方式。互動式訊息讓用戶在使用 WhatsApp 時能以更簡便的方式尋找及選擇貴公司的產品和服務。在測試階段,使用互動式傳訊功能的聊天機器人,回覆率和轉換率都比文字聊天機器人高出許多。
互動式訊息的類型:
參閱文字訊息與互動式訊息的比較:

查看在同一個流程中合併運用「清單」訊息和「回覆」按鈕的範例:
相較於文字清單,互動式訊息的格式更簡單、更一致,可以讓用戶更容易尋找及選擇他們需要的商家產品或服務。在測試階段,用戶與這些功能互動時的理解程度較高。
在測試階段,使用互動式傳訊功能的聊天機器人,回覆率和轉換率都比文字聊天機器人高出許多。
可動態填入資訊,因此能針對顧客或情況進行個人化設計。例如,您可以顯示清單訊息,供用戶查看開放預約時段,也可以使用「回覆」按鈕顯示之前的投遞地址。
互動式訊息不必使用範本,也不需事先申請。
需要提供數個選項時最適合使用清單訊息,例如:
只提供特定幾組選項,方便快速回覆時,最適合使用回覆按鈕,例如:
「個人化」使用情境不適合採用通用回應,因此「回覆」按鈕特別重要。
Flows 訊息最適用於跨多個畫面的結構化通訊,例如:
Flows 訊息讓商家能夠提供更豐富、更具互動性的用戶體驗,幫助顧客不需切換到其他應用程式或瀏覽網站即可在 WhatsApp 上更快速地完成工作。
在 API 層級設定互動式訊息時,要將訊息的 type 指定為 interactive,並且新增 interactive 物件。這類訊息通常包含 4 個主要部分:header、body、footer 和 action:
{
"recipient_type": "individual",
"to" : "whatsapp-id",
"type": "interactive"
"interactive":{
"type": "list" | "button" | ...,
"header": {},
"body": {},
"footer": {},
"action": {}
}
}

請參閱下方,深入瞭解如何傳送這些訊息。
傳送每一則訊息之前,您需呼叫 /contacts 節點,取得訊息接收者的 WhatsApp 編號。
建議您設定使用 Webhook 接收訊息狀態和外來訊息通知。完成設定之後,您就可以追蹤訊息傳送進度以及您收到的回覆。詳情請見 Webhook。
interactive 物件若要傳送清單訊息,必須組合一個 list 類型的 interactive 物件與下列元件:
| 物件 | 說明 |
|---|---|
| 選用項目。 若決定要加入這個物件,必須將標頭類型設為文字,並且新增一個文字欄位並填入所需內容。不可超過 60 個字元。 |
| 必要項目。 訊息本文。不可超過 1024 個字元。 |
| 選用項目。 訊息註腳。 |
| 必要項目。 您必須在操作中加入下列巢狀結構:
您在 |
設定完成後,interactive 物件看起來應是如此:
"interactive":{
"type": "list",
"header": {
"type": "text",
"text": "your-header-content"
},
"body": {
"text": "your-text-message-content"
},
"footer": {
"text": "your-footer-content"
},
"action": {
"button": "cta-button-content",
"sections":[
{
"title":"your-section-title-content",
"rows": [
{
"id":"unique-row-identifier",
"title": "row-title-content",
"description": "row-description-content",
}
]
},
{
"title":"your-section-title-content",
"rows": [
{
"id":"unique-row-identifier",
"title": "row-title-content",
"description": "row-description-content",
}
]
},
...
]
}
}若要傳送回覆按鈕訊息,必須組合一個 button 類型的 interactive 物件與下列元件:
| 物件 | 說明 |
|---|---|
| 選用項目。 設定 選定
範例: "header": {
"type": "text" | "image" | "video" | "document",
"text": "your text"
# OR
"document": {
"id": "your-media-id",
"filename": "some-file-name"
}
# OR
"document": {
"link": "the-provider-name/protocol://the-url",
"provider": {
"name": "provider-name",
},
"filename": "some-file-name"
},
# OR
"video": {
"id": "your-media-id"
}
# OR
"video": {
"link": "the-provider-name/protocol://the-url",
"provider": {
"name": "provider-name"
}
}
# OR
"image": {
"id": "your-media-id"
}
# OR
"image": {
"link": "http(s)://the-url",
"provider": {
"name": "provider-name"
}
}
}
|
| 必要項目。 |
| 選用項目。 |
| 必要項目。 您至少必須新增一個 設定編號時不能有前置或後置空格。 範例: "action": {
"buttons": [
{
"type": "reply",
"reply": {
"id": "unique-postback-id",
"title": "First Button’s Title"
}
},
{
"type": "reply",
"reply": {
"id": "unique-postback-id",
"title": "Second Button’s Title"
}
}
]
}
|
設定完成後,interactive 物件看起來應是如此:
"interactive": {
"type": "button",
"header": { # optional
"type": "text" | "image" | "video" | "document",
"text": "your text"
# OR
"document": {
"id": "your-media-id",
"filename": "some-file-name"
}
# OR
"document": {
"link": "the-provider-name/protocol://the-url",
"provider": {
"name": "provider-name",
},
"filename": "some-file-name"
},
# OR
"video": {
"id": "your-media-id"
}
# OR
"video": {
"link": "the-provider-name/protocol://the-url",
"provider": {
"name": "provider-name"
}
}
# OR
"image": {
"id": "your-media-id"
}
# OR
"image": {
"link": "http(s)://the-url",
"provider": {
"name": "provider-name"
}
}
}, # end header
"body": {
"text": "your-text-body-content"
},
"footer": { # optional
"text": "your-text-footer-content"
},
"action": {
"buttons": [
{
"type": "reply",
"reply": {
"id": "unique-postback-id",
"title": "First Button’s Title"
}
},
{
"type": "reply",
"reply": {
"id": "unique-postback-id",
"title": "Second Button’s Title"
}
}
]
} # end action
} # end interactive
詢問位置訊息包含本文文字和一個可供用戶點擊的傳送位置按鈕。點擊該按鈕後會顯示一個位置分享畫面,用戶接下來就可以使用這個畫面分享自己的位置。

要傳送詢問位置訊息,請先組合 interactive 物件與您想在訊息中顯示的文字:
{
"type": "location_request_message",
"body": {
"type": "text",
"text": "<TEXT>"
},
"action": {
"name": "send_location"
}
}
| 屬性 | 說明 |
|---|---|
| 設為 |
| 設為 |
| 設定您希望顯示在傳送位置按鈕上方的文字。 |
| 設為 |
Flows 訊息包含用戶可點按的行動呼籲按鈕。點按該按鈕將顯示您的自訂 Flow。
若要傳送 Flows 訊息,必須組合一個 flow 類型的 interactive 物件。詳情請見此處。
完成互動式物件後,就可以附加其他構成訊息的參數:recipient_type、to 及 type。請記得將 type 設為 interactive。
{
"recipient_type": "individual",
"to" : "whatsapp-id", // WhatsApp ID of your recipient
"type": "interactive",
"interactive":{
// Your interactive object
}
}請在此處查看所有訊息類型的通用參數。
/messages 發出 POST 呼叫利用您在步驟 1 與步驟 2 組合的 JSON 物件,向 /messages 端點發出 POST 呼叫。若訊息傳送成功,您會收到以下回覆:
{
"messages": [{
"id": "{message-id}"
}]
}若有設定 Webhook,請查看訊息狀態變更情形,以及用戶傳來的任何回覆。
用戶回覆互動式訊息的 Webhook 包括一項新的元件,名稱是 interactive,這個元件包含與用戶選擇相關的資訊。詳情請見 Webhook,元件。
例如,以下這個 Webhook 要求說明分享了位置的用戶。
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "12345",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "12345",
"phone_number_id": "12345"
},
"contacts": [
{
"profile": {
"name": "John Doe"
},
"wa_id": "12345"
}
],
"messages": [
{
"context": {
"from": "12345",
"id": "test-id"
},
"from": "123450",
"id": "test-id",
"timestamp": "16632",
"location": {
"address": "1071 5th Ave, New York, NY 10128", #Optional
"latitude": 37.421996751527,
"longitude": -122.08407156636,
"name": "Solomon R. Guggenheim Museum" #Optional
},
"type": "location"
}
]
},
"field": "messages"
}
]
}
]
}
承載中的 location 元件包含該用戶的緯度和經度。請注意,address 和 name 均非用戶必填項目,因此未必會包含在內。
"location": {
"address": "1071 5th Ave, New York, NY 10128", #Optional
"latitude": 40.782910059774,
"longitude": -73.959075808525,
"name": "Solomon R. Guggenheim Museum" #Optional
}