這份文件已更新。
中文(台灣) 的翻譯尚未完成。
英文更新時間:2月4日

訊息

使用 /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 來追蹤 Webhooks 中的訊息狀態,也可以透過訊息端點將傳入訊息標記為已讀。此 WAMID 的最大長度為 128 個字元。

使用雲端 API 後,您將無法再另行查看電話號碼是否具有 WhatsApp 編號。若要透過雲端 API 傳送訊息給顧客,只要直接發送訊息至對方的電話號碼即可;前提是顧客必須已選擇接收訊息。如需相關範例,請參閱參考資料:訊息

訊息物件

若要傳送訊息,必須先將訊息物件與要傳送的內容組合在一起。以下是 message 物件中使用的參數:

名稱說明(點擊左欄中的箭頭可查看支援的選項。)

audio

物件

type=audio 時為必要項目。

包含音訊的 media 物件

biz_opaque_callback_data

字串

選用項目。

任意字串,適用於追蹤。


例如,您可以在此欄位中傳遞訊息範本編號,以追蹤從您傳送第一則訊息開始的顧客歷程。您後續可以追蹤不同訊息範本類型的 ROI,以決定最有效的訊息範本類型。


任何已訂閱 WhatsApp Business 帳號之 messages Webhook 欄位的應用程式都可以取得此字串,因其包含在 Webhook 承戴的 statuses 物件內。


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


最多 512 個字元。


僅適用於雲端 API

contacts

物件

type=contacts 時為必要項目。

contacts 物件

context

物件

如果回覆對話中的任何訊息,則為必要項目。

物件,其中包含您要回覆之上一則訊息的編號。例如:


{"message_id":"MESSAGE_ID"}


僅適用於雲端 API

document

物件

type=document 時為必要項目。

包含文件的 media 物件

hsm

物件

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


僅適用於內部部署 API

image

物件

type=image 時為必要項目。

包含圖像的 media 物件

interactive

物件

type=interactive 時為必要項目。

interactive 物件。每個 interactive 物件的元件通常遵循一致的模式:headerbodyfooteraction

location

物件

type=location 時為必要項目。

location 物件

messaging_product

字串

必要項目

用於要求的傳訊服務。使用 "whatsapp"


僅適用於雲端 API

preview_url

布林值

type=text 時為必要項目。

允許在簡訊中預覽網址 - 請參閱在簡訊中傳送網址。如果訊息中不包含網址,此欄位為選用項目。值:false(預設值)、true


僅適用於內部部署 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

以下物件會以巢狀方式包含在訊息物件內:

聯絡人物件

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.

互動式物件

名稱說明

action

物件

必要項目。

您希望用戶在讀取訊息後執行的動作。

body

物件

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

包含訊息內文的物件。


body 物件包含以下欄位:

text字串 - 如果內文存在,則為必要項目。訊息的內容。支援表情符號和 Markdown。最大長度:1024 個字元。

footer

物件

選用項目。包含訊息頁尾的物件。


footer 物件包含以下欄位:

text字串 - 如果頁尾存在,則為必要項目。頁尾內容。支援表情符號、Markdown 和連結。最大長度:60 個字元。

header

物件

product_list 類型時為必要項目。其他類型選填。

顯示於訊息頂端的標頭內容。如果互動式物件的類型為 product,則無法設定標頭。如需詳細資訊,請參閱 header 物件

type

物件

必要項目。

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


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

以下物件會以巢狀方式包含在 interactive 物件內:

動作物件

名稱說明

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 按鈕上的文字,例如:「Signup」。


最大長度:20 個字元(非表情符號)。

flow_action

字串

流程訊息時為選用項目。

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


預設:navigate

flow_action_payload

物件

流程訊息時為選用項目。

僅當 flow_actionnavigate 時才需要。該物件可以包含下列參數:

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

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

標頭物件

名稱說明

document

物件

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

包含本文件的多媒體物件。

image

物件

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

包含本圖像的多媒體物件。

text

字串

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

標頭文字。格式設定允許使用表情符號,但不允許使用 Markdown。


最大長度:60 個字元。

type

字串

必要項目。

您想要用的標頭類型。支援的值:


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

video

物件

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

包含本影片的多媒體物件。

區塊物件

名稱說明

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 個字元。

地點物件

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.

多媒體物件

請參閱取得多媒體編號,瞭解如何取得多媒體物件編號的資訊。如需瞭解雲端 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.

範本物件

對話型定價已變更。請參閱定價,瞭解新對話型定價模式的運作方式。

此外,自 2023 年 7 月 1 日起,metric_types 的能見度已變更。如需詳細資訊,請參閱對話分析資料表

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 物件內:

按鈕參數物件

名稱說明(點擊左欄中的箭頭可查看支援的選項。)

type

字串

必要項目。

指示按鈕的參數類型。

支援的選項

  • "payload"
  • "text"

payload

quick_reply 按鈕時為必要項目。

除了顯示在按鈕上的文字,點擊按鈕時,系統將傳回開發人員所定義的承載。


請參閱快速回覆按鈕點擊次數的回呼以取得範例。

text

網址按鈕時為必要項目。

開發人員提供的後綴,其附加至範本中之預先定義的前綴網址。

元件物件

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.

幣別物件

名稱說明

fallback_value

必要項目。

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

code

必要項目。

ISO 4217 定義的幣別代碼。

amount_1000

必要項目。

乘以 1,000 的金額。

Date_Time 物件

名稱說明

fallback_value

必要項目。

預設文字。針對雲端 API,我們一律使用遞補值,且不會嘗試使用其他選用欄位進行本地化。

參數物件

名稱說明

type

字串

必要項目。

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


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

若是文字型範本,唯一支援的參數類型為 currencydate_timetext

text

字串

type=text 時為必要項目。

訊息的文字。字元限制因以下包含的元件類型而異。


若是 header 元件類型:

  • 60 個字元

若是 body 元件類型:

  • 1024 個字元(若包含其他元件類型)
  • 32768 個字元(若 body 是唯一包含的元件類型)

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 物件。用於多媒體範本時不支援說明文字。

文字物件

名稱說明

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。請參閱參數

心情物件

名稱說明

message_id

字串

必要項目

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


  • 訊息已超過 30 天
  • 訊息為心情訊息
  • 訊息已遭刪除

如果編號是已刪除訊息的編號,系統將不會傳遞該訊息。

emoji

字串

必要項目

出現在訊息中的表情符號。


  • 支援 Android 和 iOS 裝置所支援的任何表情符號。
  • 支援轉譯的表情符號。
  • 如果使用表情符號 Unicode 值,該值必須採用 Java-escape 或 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"
          }
        }
      ]
    }
  }
}'

範本訊息

對話型定價已變更。請參閱定價,瞭解新對話型定價模式的運作方式。

此外,自 2023 年 7 月 1 日起,metric_types 的能見度已變更。如需詳細資訊,請參閱對話分析資料表

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",
        }
      ]
    }