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

訊息

使用 /PHONE_NUMBER_ID/messages 端點來向您的顧客傳送文字訊息、媒體訊息、聯絡人訊息、位置訊息、互動式訊息和訊息範本。進一步了解您能夠傳送的訊息

端點驗證

/PHONE_NUMBER_ID/messages

Developers can authenticate their API calls with the access token generated in the App Dashboard > WhatsApp > API Setup.


Solution Partners must authenticate themselves with an access token with the whatsapp_business_messaging permission.

訊息均有不重複的編號(WAMID)以作識別。您可在 Webhooks 透過訊息的 WAMID 來追蹤訊息狀態。您亦可以透過訊息端點,將收到的訊息標記為已讀。此 WAMID 的長度上限可達 128 個字元。

使用雲端 API 後,您便無法再明顯地檢查某個電話號碼是否具有 WhatsApp 編號。如要使用雲端 API 向他人傳送訊息,只需在顧客選擇接受後,直接將訊息傳送至其電話號碼即可。請參閱參考資料,訊息查看相關範例。

message 物件

若要傳送訊息,您必須首先以您要傳送的內容組裝 message 物件。以下是用於 message 物件的參數:

名稱說明(點擊左欄的箭咀以了解支援選項。)

audio

物件

type=audio 時,此為必要項目。

包含音訊的 media 物件

biz_opaque_callback_data

字串

此為選用項目。

任何字串,有助追蹤。


舉例來說,您可以在此欄位輸入訊息範本編號,以從您傳送的第一則訊息開始追蹤顧客體驗歷程。然後,您可以追蹤不同訊息範本類型的投資回報率,以找出哪個類型最有效。


此字串包含在 Webhook 裝載的 statuses 物件中,因此任何已在 WhatsApp Business 帳戶中訂閱 messages Webhook 欄位的應用程式均可取得此字串。


雲端 API 不會處理此欄位,只會將其作為已傳送/已送達/已讀訊息 Webhooks 的一部分傳回。


最多 512 個字元。


僅限雲端 API

contacts

物件

type=contacts 時,此為必要項目。

contacts 物件

context

物件

回覆對話中任何訊息時,此為必要項目。

此物件包含您所回覆的之前訊息其編號。例如:


{"message_id":"MESSAGE_ID"}


僅限雲端 API

document

物件

type=document 時,此為必要項目。

包含文件的 media 物件

hsm

物件

包含 hsm 物件。此選項已隨內部部署 API v2.39 停用。請改用 template 物件。


僅限內部部署 API

image

物件

type=image 時,此為必要項目。

包含圖像的 media 物件

interactive

物件

type=interactive 時,此為必要項目。

interactive 物件。每個 interactive 物件的元件一般遵循固定形式:headerbodyfooteraction

location

物件

type=location 時,此為必要項目。

location 物件

messaging_product

字串

此為必要項目

要求所用的訊息往來服務。使用 "whatsapp"


僅限雲端 API

preview_url

布林值

type=text 時,此為必要項目。

允許在文字訊息中顯示網址預覽。請參閱在文字訊息中傳送網址。如不在訊息中加入網址,此為可選欄位。值:true(預設)、false


僅限內部部署 API。雲端 API 用戶可透過文字物件中的 preview_url 欄位使用相同功能

recipient_type

字串

此為選用項目。

您目前僅可向個人用戶傳送訊息。請將此設定為 individual


預設:individual

status

字串

訊息狀態。您可使用此欄位將訊息標記為 read。請參閱以下指南了解相關資訊:


sticker

物件

type=sticker 時,此為必要項目。

包含貼圖的 media 物件。


雲端 API:除了所有傳入訊息的貼圖類型外,亦支援傳出訊息的第三方靜態和動態貼圖。靜態貼圖須為 512x512 像素,不得超過 100 KB。動態貼圖須為 512x512 像素,不得超過 500 KB。


內部部署 API:除了所有傳入訊息的貼圖類型外,僅支援傳出訊息的第三方靜態貼圖。靜態貼圖須為 512x512 像素,不得超過 100 KB。不支援動態貼圖。

template

物件

type=template 時,此為必要項目。

template 物件

text

物件

此為文字訊息的必要項目。

text 物件

to

字串

此為必要項目。

作為訊息傳送對象的顧客之 WhatsApp 編號或手機號碼。請參閱手機號碼格式


如有需要,內部部署 API 用戶可呼叫 contacts 端點以取得此號碼。

type

字串

此為選用項目。

要傳送的訊息類型。如略過,則預設為 text

以下物件已嵌套至 message 物件:

contacts 物件

NameDescription

addresses

object

Optional.

Full contact address(es) formatted as an addresses object. The object can contain the following fields:

streetstringOptional. Street number and name.

citystringOptional. City name.

statestringOptional. State abbreviation.

zipstringOptional. ZIP code.

countrystringOptional. Full country name.

country_codestringOptional. Two-letter country abbreviation.

typestringOptional. Standard values are HOME and WORK.

birthday

Optional.

YYYY-MM-DD formatted string.

emails

object

Optional.

Contact email address(es) formatted as an emails object. The object can contain the following fields:

emailstringOptional. Email address.

typestringOptional. Standard values are HOME and WORK.

name

object

Required.

Full contact name formatted as a name object. The object can contain the following fields:

formatted_namestringRequired. Full name, as it normally appears.

first_namestringOptional*. First name.

last_namestringOptional*. Last name.

middle_namestringOptional*. Middle name.

suffixstringOptional*. Name suffix.

prefixstringOptional*. Name prefix.


*At least one of the optional parameters needs to be included along with the formatted_name parameter.

org

object

Optional.

Contact organization information formatted as an org object. The object can contain the following fields:

companystringOptional. Name of the contact's company.

departmentstringOptional. Name of the contact's department.

titlestringOptional. Contact's business title.

phones

object

Optional.

Contact phone number(s) formatted as a phone object. The object can contain the following fields:

phonestringOptional. Automatically populated with the `wa_id` value as a formatted phone number.

typestringOptional. Standard Values are CELL, MAIN, IPHONE, HOME, and WORK.

wa_idstringOptional. WhatsApp ID.

urls

object

Optional.

Contact URL(s) formatted as a urls object. The object can contain the following fields:

urlstringOptional. URL.

typestringOptional. Standard values are HOME and WORK.

interactive 物件

名稱說明

action

物件

此為必要項目。

您想用戶在閱讀訊息後執行的動作。

body

物件

product 類型的選用項目。其他訊息類型的必要項目。

含有訊息內文的物件。


body 物件包含以下欄位:

text 字串內文存在時為必要項目。訊息內容。支援表情符號和 Markdown。長度上限:1024 個字元。

footer

物件

此為選用項目。含有訊息頁尾的物件。


footer 物件包含以下欄位:

text 字串頁尾存在時為必要項目。頁尾內容。支援表情符號、Markdown 和連結。長度上限:60 個字元。

header

物件

product_list 類型的必要項目。其他類型的選用項目。

在訊息頂部顯示的標題內容。如果您的 interactive 物件為 product 類型,則無法設定頁首。詳情請參閱 header 物件

type

物件

此為必要項目。

要傳送的互動式訊息類型。支援的值:


  • button:用於「回覆」按鈕。
  • catalog_message:用於目錄訊息。
  • list:用於清單訊息。
  • product:用於單一商品訊息。
  • product_list:用於多商品訊息。
  • flow:用於流程訊息。

以下物件已嵌套至 interactive 物件:

action 物件

名稱說明

button

字串

清單訊息的必要項目。

按鈕內容。不能是空白字串,且在訊息中不得重複。支援表情符號,不支援 Markdown。


長度上限:20 個字元。

buttons

物件陣列

「回覆」按鈕的必要項目。

按鈕物件可包含以下參數:


  • type:唯一支援的類型為 reply(適用於「回覆」按鈕)
  • title:按鈕標題。不能是空白字串,且在訊息中不得重複。支援表情符號,不支援 Markdown。長度上限:20 個字元。
  • id:按鈕的不重複識別資料。用戶點擊按鈕時,Webhook 中就會傳回此編號。長度上限:256 個字元。

最多可有 3 個按鈕。設定編號時,頭尾不可留有空格。

catalog_id

字串

單一商品訊息和多商品訊息的必要項目。

與 WhatsApp Business 帳戶連結的 Facebook 目錄之不重複識別資料。此編號可經由 Meta 商務管理工具檢索。

product_retailer_id

字串

單一商品訊息和多商品訊息的必要項目。

目錄中產品的不重複識別資料。


若要取得此編號,請前往 Meta 商務管理工具並選擇您的 Meta 商業帳戶。您會看到連結至您帳戶的商店清單。點擊您想使用的商店。在左側面板上,點擊目錄 > 商品,然後找出您想提及的商品。商品的編號會顯示在商品名稱下方。

sections

物件陣列

清單訊息和多商品訊息的必要項目。

section 物件陣列。最少 1 項,最多 10 項。請參閱 section 物件

mode

字串

流程訊息的選用項目。

流程的現有模式,可為 draftpublished


預設:published

flow_message_version

字串

流程訊息的必要項目。

必須為 3

flow_token

字串

流程訊息的必要項目。

由商家產生的憑證,用作識別碼。

flow_id

字串

流程訊息的必要項目。

由 WhatsApp 提供的流程不重複識別資料。

flow_cta

字串

流程訊息的必要項目。

CTA 按鈕上的文字,例如「註冊」。


長度上限:20 個字元(不含表情符號)。

flow_action

字串

流程訊息的選用項目。

navigatedata_exchange。如要將第一個畫面預先定義為訊息的一部分,請使用 navigate。如果是進階使用案例,即第一個畫面由您的端點提供,請使用 data_exchange


預設:navigate

flow_action_payload

物件

流程訊息的選用項目。

只有當 flow_actionnavigate 時,此為必要項目。相關物件可包含以下參數:

screen 字串此為必要項目。流程第一個畫面的 id

data 物件此為選用項目。流程第一個畫面的輸入資料。必須為非空白物件。

header 物件

名稱說明

document

物件

如果 type 設為 document,此為必要項目。

含有這個文件的 media 物件。

image

物件

如果 type 設為 image,此為必要項目。

含有這張圖片的 media 物件。

text

字串

如果 type 設為 text,此為必要項目。

標題文字。格式接受表情符號,但不接受 Markdown。


長度上限:60 個字元。

type

字串

此為必要項目。

您想使用的標題類型。支援的值:


  • text:用於清單訊息、「回覆」按鈕和多商品訊息。
  • video:用於「回覆」按鈕。
  • image:用於「回覆」按鈕。
  • document:用於「回覆」按鈕。

video

物件

如果 type 設為 video,此為必要項目。

含有這段影片的 media 物件。

section 物件

名稱說明

product_items

物件陣列

多商品訊息的必要項目。

product 物件陣列。每個區塊最少要有 1 件商品,所有區塊合共最多可有 30 件商品。


每個 product 物件均包含以下欄位:


  • product_retailer_id 字串多商品訊息的必要項目。目錄中產品的不重複識別資料。若要取得此編號,請前往 Meta 商務管理工具,並選擇您的帳戶和要使用的商店。然後,點擊目錄 > 商品並找出您要提及的商品。商品的編號會顯示在商品名稱下方。

rows

物件陣列

清單訊息的必要項目。

含有多行清單。您可在所有區塊合共有 10 行。


每行都必須有標題(長度上限:24 個字元)和編號(長度上限:200 個字元)。您可選擇加入說明(長度上限:72 個字元)。


範例:

"rows": [
  {
   "id":"unique-row-identifier-here",
   "title": "row-title-content-here",
   "description": "row-description-content-here",           
   }
]

title

字串

如果訊息有多於一個區塊,此為必要項目。

區塊標題。


長度上限:24 個字元。

location 物件

NameDescription

latitude

Required.

Location latitude in decimal degrees.

longitude

Required.

Location longitude in decimal degrees.

name

Required.

Name of the location.

address

Required.

Address of the location.

media 物件

若要了解如何取得 media 物件的編號,請查看取得 media 編號。若要了解雲端 API 支援的媒體類型詳情,請查看支援的媒體類型

NameDescription

id

string

Required when type is audio, document, image, sticker, or video and you are not using a link.


The media object ID. Do not use this field when message type is set to text.

link

string

Required when type is audio, document, image, sticker, or video and you are not using an uploaded media ID (i.e. you are hosting the media asset on your public server).

The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URLs.


Do not use this field when message type is set to text.


Cloud API users only:


  • See Media HTTP Caching if you would like us to cache the media asset for future messages.
  • When we request the media asset from your server you must indicate the media's MIME type by including the Content-Type HTTP header. For example: Content-Type: video/mp4. See Supported Media Types for a list of supported media and their MIME types.

caption

string

Optional.


Media asset caption. Do not use with audio or sticker media.


On-Premises API users:

  • For v2.41.2 or newer, this field is is limited to 1024 characters.
  • Captions are currently not supported for document media.

filename

string

Optional.


Describes the filename for the specific document. Use only with document media.


The extension of the filename will specify what format the document is displayed as in WhatsApp.

provider

string

Optional. On-Premises API only.

This path is optionally used with a link when the HTTP/HTTPS link is not directly accessible and requires additional configurations like a bearer token. For information on configuring providers, see the Media Providers documentation.

template 物件

基於對話的定價已變更。請參閱定價一文,了解全新基於對話的定價運作方式。

此外,metric_types 的檢視設定已變更,由 2023 年 7 月 1 日起生效。詳情請參閱對話分析資料表

NameDescription

name

Required.

Name of the template.

language

object

Required.

Contains a language object. Specifies the language the template may be rendered in.


The language object can contain the following fields:

policystringRequired. The language policy the message should follow. The only supported option is deterministic. See Language Policy Options.

codestringRequired. The code of the language or locale to use. Accepts both language and language_locale formats (e.g., en and en_US). For all codes, see Supported Languages.

components

array of objects

Optional.

Array of components objects containing the parameters of the message.

namespace

Optional. Only used for On-Premises API.

Namespace of the template.

以下物件已嵌套至 template 物件:

button parameter 物件

名稱說明(點擊左欄的箭咀以了解支援選項。)

type

字串

此為必要項目。

指明按鈕的參數類型。

支援選項

  • "payload"
  • "text"

payload

quick_reply 按鈕的必要項目。

用戶點擊按鈕後,系統除了按鈕上顯示的文字以外,所傳回的開發人員定義裝載。


請參閱點擊快速回覆按鈕所觸發的回呼,了解相關範例。

text

「網址」按鈕的必要項目。

由開發人員提供的尾碼,附加於範本中預先定義的前綴網址。

components 物件

NameDescription (Click the arrow in the left column for supported options.)

type

string

Required.

Describes the component type.


Example of a components object with an array of parameters object nested inside:

 "components": [{
   "type": "body",
   "parameters": [{
                "type": "text",
                "text": "name"
            },
            {
            "type": "text",
            "text": "Hi there"
            }]
      }] 

Supported Options

  • header
  • body
  • button

For text-based templates, we only support the type=body.

sub_type

string

Required when type=button. Not used for the other types.

Type of button to create.

Supported Options

  • quick_reply: Refers to a previously created quick reply button that allows for the customer to return a predefined message.
  • url: Refers to a previously created button that allows the customer to visit the URL generated by appending the text parameter to the predefined prefix URL in the template.
  • catalog: Refers to a previously created catalog button that allows for the customer to return a full product catalog.

parameters

array of objects

Required when type=button.

Array of parameter objects with the content of the message.

For components of type=button, see the button parameter object.

index

Required when type=button. Not used for the other types.

Position index of the button. You can have up to 10 buttons using index values of 0 to 9.

currency 物件

名稱說明

fallback_value

此為必要項目。

本地化失敗時所顯示的預設文字。

code

此為必要項目。

ISO 4217 定義的貨幣代碼。

amount_1000

此為必要項目。

貨幣金額,以 1,000 作為倍數。

date_time 物件

名稱說明

fallback_value

此為必要項目。

預設文字。在雲端 API 中,我們一律使用遞補值,而不會嘗試以其他選用欄位作本地化。

parameter 物件

名稱說明

type

字串

此為必要項目。

說明參數類型。支援的值:


  • currency
  • date_time
  • document
  • image
  • text
  • video

文字型範本支援的參數類型僅限 currencydate_timetext

text

字串

type=text 時,此為必要項目。

訊息的文字。字元上限取決於以下包含的元件類型。


header 元件類型:

  • 60 個字元

body 元件類型:

  • 如包含其他元件類型,上限為 1024 個字元
  • 如只包含 body 元件類型,上限則為 32768 個字元

currency

物件

type=currency 時,此為必要項目。

currency 物件

date_time

物件

type=date_time 時,此為必要項目。

date_time 物件

image

物件

type=image 時,此為必要項目。

image 類型的 media 物件。用於媒體範本時不支援說明文字。

document

物件

type=document 時,此為必要項目。

document 類型的 media 物件。媒體型訊息範本目前僅支援 PDF 文件。用於媒體範本時不支援說明文字。

video

物件

type=video 時,此為必要項目。

video 類型的 media 物件。用於媒體範本時不支援說明文字。

text 物件

名稱說明

body

字串

文字訊息的必要項目。

文字訊息的文字,可包含以 http:// 或 https:// 開頭的網址和格式。在此查看適用的格式選項。


如您在文字中包含網址,並想在文字訊息中包含預覽框(preview_url: true),請確保網址以 http://https:// 開頭,最好是 https:// 網址。由於系統不會配對 IP 位址,因此您必須包含主機名稱。


長度上限:4096 個字元

preview_url

布林值

此為選用項目。僅適用於雲端 API。

設為 true 以便 WhatsApp Messenger 和 WhatsApp Business 應用程式嘗試在 body 文字字串顯示任何網址的連結預覽。網址必須以 http://https:// 開頭。如 body 文字字串內有多個網址,系統只會顯示首個網址。


如省略 preview_url 或無法檢索預覽,系統會改為顯示可點擊的連結。


內部部署 API 用戶可在最高級別訊息裝載改為使用 preview_url。請查看參數

reaction 物件

名稱說明

message_id

字串

此為必要項目

應要顯示心情回應的訊息之 WhatsApp 訊息編號(WAMID)。如果出現以下情況,心情回應不會傳送:


  • 有關訊息時間超過 30 天前
  • 有關訊息是心情回應訊息
  • 有關訊息己被刪除

如果編號屬於已刪除的訊息,有關訊息不會送達。

emoji

字串

此為必要項目

顯示在訊息上的表情符號。


  • 支援由 Android 和 iOS 裝置支援的所有表情符號。
  • 支援以圖像顯示的表情符號。
  • 如使用表情符號 unicode 值,相關值必須以 Java- 或 JavaScript-escape 編碼。
  • 每則心情回應只能傳送一個表情符號
  • 請使用空白字串以移除先前已傳送的表情符號。

概覽

指南

請查看以下指南,以了解有關如何使用 /messages 端點來傳送訊息的詳情:

範例

文字訊息

curl -X  POST \
'https://graph.facebook.com/v19.0/FROM_PHONE_NUMBER_ID/messages' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '
    {
      "messaging_product": "whatsapp",
      "recipient_type": "individual",
      "to": "PHONE_NUMBER",
      "type": "text",
      "text": { // the text object
        "preview_url": false,
        "body": "MESSAGE_CONTENT"
        }
    }'

心情回應訊息

curl -X  POST \
 'https://graph.facebook.com/v19.0/FROM_PHONE_NUMBER_ID/messages' \
 -H 'Authorization: Bearer ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "PHONE_NUMBER",
  "type": "reaction",
  "reaction": {
    "message_id": "wamid.HBgLM...",
    "emoji": "\uD83D\uDE00"
  }
}'

媒體訊息

curl -X  POST \
 'https://graph.facebook.com/v19.0/FROM-PHONE-NUMBER-ID/messages' \
 -H 'Authorization: Bearer ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "PHONE-NUMBER",
  "type": "image",
  "image": {
    "id" : "MEDIA-OBJECT-ID"
  }
}'

位置訊息

curl -X  POST \
 'https://graph.facebook.com/v19.0/FROM_PHONE_NUMBER_ID/messages' \
 -H 'Authorization: ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
  "messaging_product": "whatsapp",
  "to": "PHONE_NUMBER",
  "type": "location",
  "location": {
    "longitude": LONG_NUMBER,
    "latitude": LAT_NUMBER,
    "name": LOCATION_NAME,
    "address": LOCATION_ADDRESS
  }
}'

聯絡人訊息

curl -X  POST \
 'https://graph.facebook.com/v19.0/FROM_PHONE_NUMBER_ID/messages' \
 -H 'Authorization: ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
  "messaging_product": "whatsapp",
  "to": "PHONE_NUMBER",
  "type": "contacts",
  "contacts": [{
      "addresses": [{
          "street": "STREET",
          "city": "CITY",
          "state": "STATE",
          "zip": "ZIP",
          "country": "COUNTRY",
          "country_code": "COUNTRY_CODE",
          "type": "HOME"
        },
        {
          "street": "STREET",
          "city": "CITY",
          "state": "STATE",
          "zip": "ZIP",
          "country": "COUNTRY",
          "country_code": "COUNTRY_CODE",
          "type": "WORK"
        }],
      "birthday": "YEAR_MONTH_DAY",
      "emails": [{
          "email": "EMAIL",
          "type": "WORK"
        },
        {
          "email": "EMAIL",
          "type": "HOME"
        }],
      "name": {
        "formatted_name": "NAME",
        "first_name": "FIRST_NAME",
        "last_name": "LAST_NAME",
        "middle_name": "MIDDLE_NAME",
        "suffix": "SUFFIX",
        "prefix": "PREFIX"
      },
      "org": {
        "company": "COMPANY",
        "department": "DEPARTMENT",
        "title": "TITLE"
      },
      "phones": [{
          "phone": "PHONE_NUMBER",
          "type": "HOME"
        },
        {
          "phone": "PHONE_NUMBER",
          "type": "WORK",
          "wa_id": "PHONE_OR_WA_ID"
        }],
      "urls": [{
          "url": "URL",
          "type": "WORK"
        },
        {
          "url": "URL",
          "type": "HOME"
        }]
    }]
}'

互動式訊息

單一商品訊息

curl -X  POST \
 'https://graph.facebook.com/v19.0/FROM_PHONE_NUMBER/messages' \
 -H 'Authorization: Bearer ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
   "messaging_product": "whatsapp",
   "recipient_type": "individual",
   "to": "PHONE_NUMBER",
   "type": "interactive",
   "interactive": {
     "type": "product",
     "body": {
       "text": "optional body text"
     },
     "footer": {
       "text": "optional footer text"
     },
     "action": {
       "catalog_id": "CATALOG_ID",
       "product_retailer_id": "ID_TEST_ITEM_1"
     }
   }
 }'

多商品訊息

curl -X  POST \
 'https://graph.facebook.com/v19.0/FROM_PHONE_NUMBER/messages' \
 -H 'Authorization: Bearer ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
 "messaging_product": "whatsapp",
   "recipient_type": "individual",
   "to": "PHONE_NUMBER",
   "type": "interactive",
   "interactive": {
     "type": "product_list",
     "header":{
       "type": "text",
       "text": "header-content"
     },
     "body": {
       "text": "body-content"
     },
     "footer": {
       "text": "footer-content"
     },
     "action": {
       "catalog_id": "CATALOG_ID",
       "sections": [
         {
           "title": "section-title",
           "product_items": [
             { "product_retailer_id": "product-SKU-in-catalog" },
             { "product_retailer_id": "product-SKU-in-catalog" },
             ...
           ]
         },
         {
           "title": "section-title",
           "product_items": [
             { "product_retailer_id": "product-SKU-in-catalog" },
             { "product_retailer_id": "product-SKU-in-catalog" },
             ...
           ]
         }
       ]
     }
   }
 }

目錄訊息

curl -X  POST \
 'https://graph.facebook.com/v19.0/FROM_PHONE_NUMBER/messages' \
 -H 'Authorization: Bearer ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "PHONE_NUMBER",
  "type": "interactive",
  "interactive" : {
    "type" : "catalog_message",
    "body" : {
      "text": "Thanks for your order! Tell us what address you’d like this order delivered to."
    },
    "action": {
      "name": "catalog_message",
      "parameters": { 
        "thumbnail_product_retailer_id": "<Product-retailer-id>"
      }
    }
  }
}'

流程訊息

curl -X  POST \
 'https://graph.facebook.com/v19.0/FROM_PHONE_NUMBER/messages' \
 -H 'Authorization: Bearer ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "PHONE_NUMBER",
  "type": "interactive",
  "interactive" : {
    "type": "flow",
    "header": {
      "type": "text",
      "text": "Flow message header"
    },
    "body": {
      "text": "Flow message body"
    },
    "footer": {
      "text": "Flow message footer"
    },
    "action": {
      "name": "flow",
      "parameters": {
        "flow_message_version": "3",
        "flow_token": "AQAAAAACS5FpgQ_cAAAAAD0QI3s",
        "flow_id": "<FLOW_ID>",
        "flow_cta": "Book!",
        "flow_action": "navigate",
        "flow_action_payload": {
          "screen": "<SCREEN_ID>",
          "data": {
            "user_name": "name",
            "user_age": 25
          }
        }
      }
    }
  }
}'
  

清單訊息

curl -X  POST \
 'https://graph.facebook.com/v19.0/FROM_PHONE_NUMBER_ID/messages' \
 -H 'Authorization: Bearer ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "PHONE_NUMBER",
  "type": "interactive",
  "interactive": {
    "type": "list",
    "header": {
      "type": "text",
      "text": "HEADER_TEXT"
    },
    "body": {
      "text": "BODY_TEXT"
    },
    "footer": {
      "text": "FOOTER_TEXT"
    },
    "action": {
      "button": "BUTTON_TEXT",
      "sections": [
        {
          "title": "SECTION_1_TITLE",
          "rows": [
            {
              "id": "SECTION_1_ROW_1_ID",
              "title": "SECTION_1_ROW_1_TITLE",
              "description": "SECTION_1_ROW_1_DESCRIPTION"
            },
            {
              "id": "SECTION_1_ROW_2_ID",
              "title": "SECTION_1_ROW_2_TITLE",
              "description": "SECTION_1_ROW_2_DESCRIPTION"
            }
          ]
        },
        {
          "title": "SECTION_2_TITLE",
          "rows": [
            {
              "id": "SECTION_2_ROW_1_ID",
              "title": "SECTION_2_ROW_1_TITLE",
              "description": "SECTION_2_ROW_1_DESCRIPTION"
            },
            {
              "id": "SECTION_2_ROW_2_ID",
              "title": "SECTION_2_ROW_2_TITLE",
              "description": "SECTION_2_ROW_2_DESCRIPTION"
            }
          ]
        }
      ]
    }
  }
}'

回覆按鈕

curl -X  POST \
 'https://graph.facebook.com/v19.0/FROM_PHONE_NUMBER_ID/messages' \
 -H 'Authorization: Bearer ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "PHONE_NUMBER",
  "type": "interactive",
  "interactive": {
    "type": "button",
    "body": {
      "text": "BUTTON_TEXT"
    },
    "action": {
      "buttons": [
        {
          "type": "reply",
          "reply": {
            "id": "UNIQUE_BUTTON_ID_1",
            "title": "BUTTON_TITLE_1"
          }
        },
        {
          "type": "reply",
          "reply": {
            "id": "UNIQUE_BUTTON_ID_2",
            "title": "BUTTON_TITLE_2"
          }
        }
      ]
    }
  }
}'

範本訊息

基於對話的定價已變更。請參閱定價一文,了解全新基於對話的定價運作方式。

此外,metric_types 的檢視設定已變更,由 2023 年 7 月 1 日起生效。詳情請參閱對話分析資料表

curl -X  POST \
 'https://graph.facebook.com/v19.0/FROM_PHONE_NUMBER_ID/messages' \
 -H 'Authorization: Bearer ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "PHONE_NUMBER",
  "type": "template",
  "template": {
    "name": "TEMPLATE_NAME",
    "language": {
      "code": "LANGUAGE_AND_LOCALE_CODE"
    },
    "components": [
      {
        "type": "header",
        "parameters": [
          {
            "type": "image",
            "image": {
              "link": "http(s)://URL"
            }
          }
        ]
      },
      {
        "type": "body",
        "parameters": [
          {
            "type": "text",
            "text": "TEXT_STRING"
          },
          {
            "type": "currency",
            "currency": {
              "fallback_value": "VALUE",
              "code": "USD",
              "amount_1000": NUMBER
            }
          },
          {
            "type": "date_time",
            "date_time": {
              "fallback_value": "MONTH DAY, YEAR"
            }
          }
        ]
      },
      {
        "type": "button",
        "sub_type": "quick_reply",
        "index": "0",
        "parameters": [
          {
            "type": "payload",
            "payload": "PAYLOAD"
          }
        ]
      },
      {
        "type": "button",
        "sub_type": "quick_reply",
        "index": "1",
        "parameters": [
          {
            "type": "payload",
            "payload": "PAYLOAD"
          }
        ]
      }
    ]
  }
}'

回覆訊息

curl -X POST \
 'https://graph.facebook.com/v19.0/FROM_PHONE_NUMBER/messages' \
 -H 'Authorization: Bearer ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
  "messaging_product": "whatsapp",
  "context": {
     "message_id": "MESSAGE_ID"
  },
  "to": "PHONE_NUMBER",
  "type": "text",
  "text": {
    "preview_url": false,
    "body": "your-text-message-content"
  }
}’

成功回覆

    {
      "messaging_product": "whatsapp",
      "contacts": [
        {
          "input": "16505555555",
          "wa_id": "16505555555"
        }
      ],
      "messages": [
        {
          "id": "wamid.HBgLMTY1MDUwNzY1MjAVAgARGBI5QTNDQTVCM0Q0Q0Q2RTY3RTcA"
        }
      ]
    }
    

Applies to businesses in Brazil, Colombia, and Singapore, starting September 12, 2023. Applies to all businesses starting October 12, 2023.

Messages will have one of the following statuses which will be returned in each of the messages objects

  • "message_status":"accepted" : means the message was sent to the intended recipient
  • "message_status":"held_for_quality_assessment": means the message send was delayed until quality can be validated and it will either be sent or dropped at this point

      {
      "messaging_product": "whatsapp",
      "contacts": [
        {
          "input": "16505555555",
          "wa_id": "16505555555"
        }
      ],
      "messages": [
        {
          "id": "wamid.HBgLMTY1MDUwNzY1MjAVAgARGBI5QTNDQTVCM0Q0Q0Q2RTY3RTcA",
          "message_status": "accepted",
        }
      ]
    }