訊息

/v1/messages

使用 messages 節點來向您的顧客傳送文字訊息、媒體、聯絡人、位置、互動式訊息和訊息範本。

請參閱下列指南,了解有關您可傳送的特定訊息類型之資訊:文字訊息媒體訊息聯絡人和地點訊息互動式訊息訊息範本媒體訊息範本,以及互動式訊息範本

準備工作

您需要以下事項:

  • 驗證自己的身分,然後接收可以用來存取此服務的驗證憑證。如要進一步了解如何執行此操作,請參閱登入和驗證文件
  • 如要驗證您想向其傳送訊息的 WhatsApp 帳戶,並獲取其 WhatsApp 用戶帳號,請參閱聯絡人聯絡人文件了解相關操作。
  • 符合訊息阻斷控制服務要求。

由 v2.39 版本及以上版本起,您在傳送訊息之前無需再呼叫聯絡人節點

限制

  • 系統支援以下訊息類型:文字、訊息範本、圖像、文件和音訊。
  • 文字訊息長度不得多於 4096 個字元。

建立

無論是何種訊息類型,系統都會向 /messages 節點傳送 POST 呼叫來傳送訊息。對於每種類型的訊息(文字、圖像等),JSON 訊息內文的內容會有所不同。

參數

/messages POST 要求中使用的主要參數如下:

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

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

text 物件

名稱說明

body

此為必要項目。

包含訊息文字,其中包含網址和格式。

media 物件

對於內部部署 API,媒體物件編號是使用 media 端點將媒體成功上載至 WhatsApp Business API(詳見「內部部署 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.

contacts 物件

contacts 中,您可以嵌套以下物件:addressesemailsnameorgphoneurls多個物件封裝在一個陣列中,如下例所示。

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.

contacts 物件範例,其中嵌套了多個物件:

"contacts": [
    {
        "addresses": [
            {
                "city": "city name",
                "country": "country name",
                "country_code": "code",
                "state": "Contact's State",
                "street": "Contact's Street",
                "type": "Contact's Address Type",
                "zip": "Contact's Zip Code"
            }
        ],
        "birthday": "birthday",
        "emails": [
            {
                "email": "email",
                "type": "HOME"
            },
            {
                "email": "email",
                "type": "WORK"
            }
        ],
        "name": {
            "first_name": "first name value",
            "formatted_name": "formatted name value",
            "last_name": "last name value",
            "suffix": "suffix value"
        },
        "org": {
            "company": "company name",
            "department": "dep name",
            "title": "title"
        },
        "phones": [
            {
                "phone": "Phone number",
                "wa-id": "WA-ID value",
                "type": "MAIN"
            },
            {
                "phone": "Phone number",
                "type": "HOME"
            },
            {
                "phone": "Phone number",
                "type": "WORK"
            }
        ],
        "urls": [{
            "url": "some url",
            "type": "WORK"
        }]
    }
]

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.

template 物件

template 中,您可以嵌套 componentslanguage 物件。

v2.27.8 開始,範本的 namespace 必須是與 WhatsApp Business 帳戶相關的命名空間,且該帳戶必須擁有與目前 WhatsApp Business 內部部署用戶端相關的手機號碼,否則訊息將無法成功傳送。

此外,由 v2.41 起,namespace 將為選用欄位。

名稱描述

namespace

此為必要項目。

範本的命名空間。


v2.27.8 開始,這個參數必須為與 WhatsApp Business 帳戶相關的命名空間,且該帳戶必須擁有與目前 WhatsApp Business API 用戶端相關的手機號碼,否則訊息會傳送失敗。

name

此為必要項目。

範本名稱。

language

此為必要項目。

指明範本可用於顯示內容的語言。媒體範本訊息只支援 deterministic 語言政策。詳情請參閱語言部分。

components

此為選用項目。

包含訊息參數的陣列。

components 物件

components 中,您可以嵌套 parameters 物件。此外,您還可以將 type 設定為 button

名稱描述

type

此為必要項目。

描述 component 類型。
值:headerbodyfooter

parameters

此為選用項目。

包含訊息內容的陣列。

參數物件

名稱描述

type

此為必要項目。

描述 parameter 類型。
值:textcurrencydate_timeimagedocumentvideo


媒體類型(imagedocumentvideo)須採用與標準媒體訊息相同的格式,詳情請參閱媒體文件。目前僅支援在媒體訊息範本中使用 PDF 文件。


如需更多有關 currencydate_time 的資訊,請參閱可本地化參數部分。template 訊息的 currencydate_time 參數會使用 fallback_value 來代替 default。請參閱上述要求範例以了解詳情。

按鈕類型

components 物件中,您可以將 type 設定為 button。按鈕參數如下:

名稱說明

sub_type

此為必要項目。

所建立的按鈕類型。
值:quick_replyurlcopy_code (available from 2.49 and onwards)

index

此為必要項目。

按鈕的位置索引。您最多可以擁有 10 個使用 0-9 索引值的按鈕。

parameters

此為必要項目。

此為按鈕的參數,在企業管理平台中建立時設定,其中包含下列參數:

  • type(必要項目):指明按鈕的參數類型。支援的值為 payloadtextcoupon_code
  • payloadquick_reply 按鈕的必要項目):點擊按鈕後,系統會傳回按鈕所顯示的文字,以及由開發人員定義的裝載。
  • texturl 按鈕的必要項目):開發人員提供的後綴,此後綴將附加至之前建立的動態網址按鈕。
  • coupon_code(copy_code 按鈕的必要項目)(自 2.49 起適用):開發人員提供的優惠券代碼,用戶點擊「複製代碼」按鈕後便可複製此代碼。

帶有 sub_type quick_replybutton 類型範例:

 {
    "type": "button",
    "sub_type": "quick_reply",
    "index": 0,
    "parameters": 
     [{
    	"type": "payload",
    	"payload": "Yes-Button-Payload"
     }]
 } 

帶有 sub_type copy_codebutton 類型範例

    
 { 
    "type": "button", 
    "sub_type": "copy_code", 
    "index": 0, 
    "parameters": 
    [{ 
     "type": "coupon_code", 
     "coupon_code": "DISCOUNT20" 
    }] 
 }

hsm 物件

我們已在推出 v2.39 版 WhatsApp Business API(詳見「內部部署 API」>「參考資料」)後停用 hsm 物件。請改用 template 物件。

名稱 說明

namespace

此為必要項目。

要使用的命名空間。由 v2.2.7 起,如果命名空間與 element_name 不一致,訊息便無法成功傳送。

element_name

此為必要項目。

表明命名空間內使用哪個範本的元素名稱。由 v2.2.7 起,如果 element_name 與命名空間不一致,訊息便無法成功傳送。

language

此為必要項目。

允許指定確定性語言。如需更多資訊,請參閱語言部分。


此欄位用於支援 fallback 選項,但 v2.27.8 中已停用此選項。

localizable_params

此為必要項目。

此欄位為套用於範本變數的值陣列。如需更多資訊,請參閱可本地化參數部分。

interactive 物件

The interactive object generally contains 4 main components: header, body, footer, and action. Additionally, some of those components can contain one or more different objects:

  • Inside header, you can nest media objects.
  • Inside action, you can nest section and button objects.
NameDescription

type

string

Required.

The type of interactive message you want to send. Supported values:

  • list: Use it for List Messages.
  • button: Use it for Reply Buttons.
  • product: Use it for Single-Product Messages.
  • product_list: Use it for Multi-Product Messages.
  • catalog_message: Use it for Catalog Messages.
  • flow: Use it for Flows Messages.

header

object

Required for type product_list. Optional for other types.

Header content displayed on top of a message. You cannot set a header if your interactive object is of product type.


The header object contains the following fields:

documentobjectRequired if type is set to document. Contains the media object with the document.

imageobjectRequired if type is set to image. Contains the media object with the image.

videoobjectRequired if type is set to video. Contains the media object with the video.

textstringRequired if type is set to text. Text for the header. Formatting allows emojis, but not markdown. Maximum length: 60 characters.

typestringRequired. The header type you would like to use. Supported values are:

text – for List Messages, Reply Buttons, and Multi-Product Messages.

video – for Reply Buttons.

image – for Reply Buttons.

document – for Reply Buttons.

body

object

Optional for type product. Required for other message types.

An object with the body of the message.


The body object contains the following field:

textstringRequired if body is present. The content of the message. Emojis and markdown are supported. Maximum length: 1024 characters.

footer

object

Optional.

An object with the footer of the message.


The footer object contains the following field:

textstringRequired if footer is present. The footer content. Emojis, markdown, and links are supported. Maximum length: 60 characters.

action

object

Required.

An action object with what you want the user to perform after reading the message. See action object for full information.

action 物件

NameDescription

button

string

Required for List Messages.

Button content. It cannot be an empty string and must be unique within the message. Emojis are supported, markdown is not. Maximum length: 20 characters.

buttons

object

Required for Reply Button Messages.

A button object. The object can contain the following parameters:

type – The only supported option is reply for Reply Button Messages.

title – Button title. It cannot be an empty string and must be unique within the message. Emojis are supported, markdown is not. Maximum length: 20 characters.

id – Unique identifier for your button. This ID is returned in the webhook when the button is clicked by the user. Maximum length: 256 characters.


在您設定此編號時,開頭和末尾均不能有空格。

sections

array of objects

Required for List Messages and Multi-Product Messages.

Array of section objects. There is a minimum of 1 and maximum of 10. See section object.

catalog_id

string

Required for Single-Product Messages and Multi-Product Messages.

Unique identifier of the Facebook catalog linked to your WhatsApp Business Account. This ID can be retrieved via Commerce Manager.

product_retailer_id

string

Required for Single-Product Messages and Multi-Product Messages.

Unique identifier of the product in a catalog. Maximum 100 characters for both Single-Product and Multi-Product messages.


To get this ID, go to Commerce Manager, select your Facebook Business account, and you will see a list of shops connected to your account. Click the shop you want to use. On the left-side panel, click Catalog > Items, and find the item you want to mention. The ID for that item is displayed under the item's name.

mode

string

Optional for Flows Messages.

The current mode of the Flow, either draft or published.


Default: published

flow_message_version

string

Required for Flows Messages.

Must be 3.

flow_token

string

Required for Flows Messages.

A token that is generated by the business to serve as an identifier.

flow_id

string

Required for Flows Messages.

Unique identifier of the Flow provided by WhatsApp.

flow_cta

string

Required for Flows Messages.

Text on the CTA button, eg. "Signup".


Maximum length: 20 characters (no emoji).

flow_action

string

Optional for Flows Messages.

navigate or data_exchange. Use navigate to predefine the first screen as part of the message. Use data_exchange for advanced use-cases where the first screen is provided by your endpoint.


Default: navigate

flow_action_payload

object

Optional for Flows Messages.

Required only if flow_action is navigate. The object can contain the following parameters:

screenstringRequired. The id of the first screen of the Flow.

dataobjectOptional. The input data for the first screen of the Flow. Must be a non-empty object.

Section Object

NameDescription

title

string

Required if the message has more than one section.

Title of the section. Maximum length: 24 characters.

rows

array of objects

Required for List Messages.

Contains a list of row objects. Limited to 10 rows across all sections.


Each row object contains the following fields:

titlestringRequired. Maximum length: 24 characters.

IDstringRequired. Maximum length: 200 characters.

descriptionstringOptional. Maximum length: 72 characters.

product_items

array of objects

Required for Multi-Product Messages.

Array of product objects. There is a minimum of 1 product per section and a maximum of 30 products across all sections.


Each product object contains the following field:

product_retailer_idstringRequired for Multi-Product Messages. Unique identifier of the product in a catalog. To get this ID, go to Commerce Manager, select your account and the shop you want to use. Then, click Catalog > Items, and find the item you want to mention. The ID for that item is displayed under the item's name.

範例

音訊訊息:

POST /v1/messages
{
  "recipient_type": "individual",
  "to": "whatsapp-id",
  "type": "audio",
  "audio": {
      "id": "your-media-id",
  }
}

文件訊息,使用 filename

POST /v1/messages
{
  "recipient_type": "individual",
  "to": "whatsapp-id",
  "type": "document",
  "document": {
      "id": "your-media-id",
      "filename": "your-document-filename"
  }
}

文件訊息,使用 link

POST /v1/messages
{
  "recipient_type": "individual",
  "to": "whatsapp-id",
  "type": "document",
  "document": {
      "link": "http(s)://the-url"
      "provider": {
          "name" : "provider-name"
      }     
    }
}

影片訊息,使用 link

POST /v1/messages
{
  "recipient_type": "individual",
  "to": "whatsapp-id",
  "type": "video",  
  "video": {
      "link": "http(s)://the-url"
      "provider": {
          "name" : "provider-name"
      }
    }
  }
}

文字訊息:

POST /v1/messages
{
  "recipient_type": "individual",
  "to": "whatsapp-id",
  "type": "text",
  "text": {
      "body": "your-message-content"
  }
}

互動式訊息(清單):

POST /v1/messages
{
  "recipient_type": "individual",
  "to": "whatsapp-id",
  "type": "interactive",
  "interactive":{
    "type": "list",
    "header": {
      "type": "text",
      "text": "your-header-content-here"
    },
    "body": {
      "text": "your-text-message-content-here"
    },
    "footer": {
      "text": "your-footer-content-here"
    },
    "action": {
      "button": "cta-button-content-here",
      "sections":[
        {
          "title":"your-section-title-content-here",
          "rows": [
            {
              "id":"unique-row-identifier-here",
              "title": "row-title-content-here",
              "description": "row-description-content-here",           
            }
          ]
        },
        {
          "title":"your-section-title-content-here",
          "rows": [
            {
              "id":"unique-row-identifier-here",
              "title": "row-title-content-here",
              "description": "row-description-content-here",           
            }
          ]
        },
        ...
      ]
    }
  }

}

互動式訊息(「回覆」按鈕):

POST /v1/messages
{
  "recipient_type": "individual",
  "to": "whatsapp-id",
  "type": "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

}

互動式訊息(多商品訊息和單一商品訊息):

{ 
  "recipient_type": "individual",
  "to" : "{{Recipient-WA-ID}}",
  "type": "interactive",
  "interactive": {
    "type": "product",
    "body": {
      "text": "body text"
    },
    "footer": {
      "text": "footer text"
    },
    "action": {
      "
      
      _id": "catalog-ID",
      "product_retailer_id": "product-ID"
    }
  }
}

互動式訊息(多商品訊息):

{ 
  "recipient_type": "individual",
  "to" : "whatsapp-id",
  "type": "interactive",
  "interactive": 
    {
    "type": "product_list",
    "Header":{
       "type": "text",
        "text": "text-header-content"
     },
     "body":{
        "text": "text-body-content"
      },
     "footer":{
        "text":"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": "the-section-title",
              "product_items": [
                 { "product_retailer_id": "product-SKU-in-catalog" }
                           ...
              ]},
               ...
       ]
     },  
    }
}

互動式訊息(目錄訊息):

{ 
  "recipient_type": "individual",
  "to" : "whatsapp-id",
  "type": "interactive",
  "interactive": 
    {
    "type": "catalog_message",
     "body":{
        "text": "text-body-content"
      },
     "footer":{
        "text":"text-footer-content"
     },
     "action":{
        "name": "catalog_message",
      	"parameters":{ 
      	  "thumbnail_product_retailer_id": "product-SKU-in-catalog"
      	}
     },  
    }
}

互動式訊息(流程):

{
  "recipient_type": "individual",
  "to": "{{Recipient-WA-ID}}",
  "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": { # optional
            "user_name": "name",
            "user_age": 25
          }
        }
      }
    }
  }
}

以下是回覆中的 payload 範例。為簡潔表達起見,我們省略了中繼資料和錯誤物件。

{
  "messages": [{ 
    "id": "message-id" 
  }]    
}

如果這項要求成功,您會收到包含訊息編號的回應。如果這項要求傳回 errors 部分,請查看原始訊息並更正錯誤,然後再重新傳送要求。如需有關錯誤的詳細資訊,請參閱 WhatsApp Business API(詳見「內部部署 API」>「參考資料」)用戶端錯誤代碼HTTP 狀態代碼

由 2023 年 9 月 12 日開始適用於巴西、哥倫比亞和新加坡境內的企業。由 2023 年 10 月 12 日開始適用於所有企業。

如這項要求因品質評估而暫緩傳送,您就會在回應中收到 message_status 屬性,以及一則指明訊息未能立即傳送並會在驗證品質後傳送或遭棄置的訊息。您只會在訊息遭暫緩傳送的情況下看到此屬性。

    {
      "messages": [{ 
        "id": "message-id",
        "message_status": "Message has been held because quality assessment is pending",
      }]    
    }
    

設定文字訊息的格式

WhatsApp 允許您在訊息加入格式。如要為訊息的全部或部分內容設定格式,請使用下列格式符號:

格式符號範例

粗體

星號(*)

總金額為 *$10.50 美元*。

斜體

底線(_)

歡迎使用 _WhatsApp_!

刪除線

波浪號(~)

這是 ~更好~ 最好的!

Code

三個倒引號(```)

```列印「Hello World」;```

成效

在本建議的背景中,「成效」表示可透過 WhatsApp Business API(詳見「內部部署 API」>「參考資料」)用戶端在任何既定秒數內傳送的訊息數量。可達到的最高成效視乎多種因素而定,而其中最重要的因素是您的用戶端設定選擇,以及接收訊息的對象是新用戶還是現有用戶。例如,在向新用戶傳送訊息時,系統需要多一點時間來設定加密連線階段。

用戶端設定每秒支援的文字訊息數量

單個分片

70

多個分片(32 個分片)

250

常見問題

備註:請勿使用 WhatsApp Business API 向同一位傳送對象重複傳送相同訊息。

訊息送達率不是 100% 的原因有很多種。其中一些常見情況包括:用戶的網絡斷斷續續、用戶在一段時間內沒有任何活動,或建立 優質用戶體驗

可以透過 WhatsApp 送達的訊息有非常高的送達率。可是,也有很多原因會導致訊息傳送失敗。您可以監察回呼,以了解訊息的具體狀態。由於您無法存取最後送達狀態,而再次傳送訊息可能反而會產生不同成效,因此這方式有別於短訊等其他訊息傳送方式。

訊息可能會因為用戶手機停機、沒電,或用戶在遺失手機後更換新手機並停用 SIM 卡,而無法送達至用戶。另此,企業的用戶端網絡連線功能也有可能出錯,系統也有可能無法送達回呼(Webhooks)。您可使用此 health 節點監察這些狀況。只需開啟伺服器接收回呼,即可知道訊息有否成功進入 WhatsApp 伺服器雲端。

當用戶重新連接至網絡時,您之前所傳送的所有訊息都將會送達至他們。對用戶而言,重複收到內容相同的訊息會令體驗欠佳。他們較有可能會封鎖或投訴您,而您亦較有可能會被停權。

如果您在傳送訊息後收到了來自 API 的訊息編號,則代表您已經完成可做的操作來傳送此訊息。請勿向同一位傳送對象重複傳送相同內容。

如果您發現送達率長期偏低,請提交支援工作單至 直接支援服務

當您傳送訊息時,只要您獲得訊息編號,便代表系統已將該訊息要求儲存在資料庫中。WhatsApp Business API 用戶端會不斷嘗試傳送該訊息,直至收到 WhatsApp 伺服器的確認為止。這個過程不設任何結束期限。然後,WhatsApp 伺服器會嘗試將該訊息傳送至用戶的手機。如果用戶的手機不在線,則系統會將訊息存儲在 WhatsApp 伺服器 30 天,然後將之捨棄。

可以!WhatsApp 允許您為訊息的所選文字使用粗體、斜體、刪除線或等寬字體。

您目前無法知道有多少用戶,或哪些用戶已查看您的企業。獲取此資訊的最佳方法是偵聽狀態回調;如果您沒有收到 delivered 狀態,則代表用戶已封鎖貴公司,或者用戶沒有連接至網絡。如需更多資訊,請參閱 Webhooks 文件。

如果用戶已封鎖貴公司,聯絡人 API 會繼續傳回內容,以表示該手機號碼是有效的 WhatsApp 用戶。然而,在您傳送訊息時,該則訊息將永遠不會送達。如果是付費訊息,則您無需付費。

不能,我們無法保證訊息的送達順序會與它們的傳送順序相同。如果訊息排序對您的使用案例十分重要,則我們建議您先偵聽第一則訊息的送達回調,然後再觸發第二則訊息。

使用 messages 節點時,您需要將 Content-Type 標題設定為 application/json,以便 WhatsApp Business API 用戶端正確地解析訊息正文。另外,您亦需要設定 Authorization 標題,而且它必須包含一個未過期的存取憑證。請參閱登入和身份驗證文件,以了解如何獲取憑證,以及如何查看它的有效期。

在某些情況下,您可能需要更多時間來處理顧客的查詢,或者您只能在 24 小時後回覆其訊息。我們建議您建立訊息範本,以用於下列兩個用途:

  • 將結果傳送給用戶,或者
  • 提醒用戶作出回覆,以啟動客戶服務期限。

在這兩種情況中,請務必盡可能為訊息範本提供最多的背景資訊。例如:

  • 「{{1}},您好!關於您先前回報的問題,我們很遺憾地通知您 {{2}}。如有任何不便之處,敬請原諒。」
  • 您的問題單已有所更新。如果您想繼續使用支援服務,請回覆。」