消息

/v1/messages

使用 messages 节点向您的客户发送文本、媒体、联系人、位置、互动消息及消息模板。

如需了解您可以发送的特定消息类型的信息,请参阅以下指南:文本消息媒体消息联系人和位置消息互动消息消息模板媒体消息模板互动消息模板

准备工作

您需要:

  • 验证自己的身份并接收支持您访问此项服务的身份验证口令。如需有关操作方法的更多信息,请参阅登录和身份验证文档
  • 验证您希望会接收自己消息的 WhatsApp 帐户,并获取其 WhatsApp 用户编号。如需有关操作方法的更多信息,请参阅联系人文档
  • 符合消息阻断控制服务要求。

从 v2.39 版开始,不必在发送消息前先调用联系人节点

限制

  • 支持以下类型的消息:文本、消息模板、图片、文件和音频。
  • 文本消息的最大长度为 4,096 个字符。

创建

无论使用何种消息类型,系统均通过向 /messages 节点发出 POST 调用来发送消息。JSON 消息正文内容因消息类型(文本、图片等)而异。

参数

以下是 /messages POST 请求中使用的主要参数:

名称描述(点击左列中的箭头以获取支持的选项。)

audio

对象

type=audio 时,此为必要项。

包含音频的 media 对象

biz_opaque_callback_data

字符串

可选。

有助于追踪的任意字符串。


例如,您可以在此字段中传递消息模板编号,以从您发送的第一条消息开始追踪客户体验历程。然后,您可以追踪不同消息模板类型的投资回报 (ROI),以找出最有效的类型。


此字符串包含在 Webhooks 负载的 statuses 对象中,因此任何已在 WhatsApp Business 商业帐号中订阅 messages Webhooks 字段的应用均可获取此字符串。


云端 API 不会处理此字段,只会将其作为已发送/已送达/已读消息 Webhooks 的一部分返回。


不超过 512 个字符。


仅限云端 API

contacts

对象

type=contacts 时,此为必要项。

contacts 对象

context

对象

回复对话中任何消息时,此为必要项。

此对象包含您所回复的之前的消息的编号。例如:


{"message_id":"MESSAGE_ID"}


仅限云端 API

document

对象

type=document 时,此为必要项。

包含文档的 media 对象

hsm

对象

包含 hsm 对象。自 On-Premises API v2.39 起,此选项已停用。请改用 template 对象。


仅限 On-Premises 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


仅限 On-Premises API。云端 API 用户可通过文字对象中的 preview_url 字段使用相同功能

recipient_type

字符串

可选。

您目前仅可向个人发送消息。请将此设为 individual


默认:individual

status

字符串

消息状态。您可使用此字段将消息标为 read。请参阅以下指南了解相关信息:


sticker

对象

type=sticker 时,此为必要项。

包含贴图的 media 对象。


云端 API:除了所有传入消息的贴图类型外,还支持传出消息的第三方静态和动态贴图。静态贴图须为 512x512 像素,不得超过 100 KB。动态贴图须为 512x512 像素,不得超过 500 KB。


On-Premises API:除了所有传入消息的贴图类型外,仅支持传出消息的第三方静态贴图。静态贴图须为 512x512 像素,不得超过 100 KB。不支持动态贴图。

template

对象

type=template 时,此为必要项。

template 对象

text

对象

此为文字消息的必要项。

text 对象

to

字符串

必要。

要接收消息的客户的 WhatsApp 编号或电话号码。请参阅电话号码格式


如有需要,On-Premises API 用户可调用 contacts 端点以获取此号码。

type

字符串

可选。

要发送的消息类型。如略过,则默认为 text

文本对象

名称描述

body

必要。

包含消息的文本,其中可以包含网址和格式。

媒体对象

在本地 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 内部,您可以嵌套以下对象: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"
        }]
    }
]

位置对象

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 内部,您可以嵌套 componentslanguage 对象。

v2.27.8 开始,模板的 namespace 必须是与 WABA 有关的命名空间,且该 WABA 拥有当前 WhatsApp Business 本地客户端中的电话号码。否则,消息将发送失败。

此外,从 v2.41 开始,namespace 将是一个可选字段。

名称说明

namespace

必需

模板的命名空间。


v2.27.8 开始,与此命名空间相关联的 WhatsApp 企业帐户必须拥有与当前 WhatsApp Business API 客户端相关联的手机号,否则消息将无法发送。

name

必需

模板名称。

language

必需

指定模板可使用的显示语言。多媒体素材模板消息仅支持 deterministic 语言政策。详情请参阅语言部分。

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

必要。

按钮的位置索引。通过使用 0-9 的索引值,您最多可以拥有 10 个按钮。

parameters

必要。

按钮的参数,在商务管理平台中创建按钮时需要设置这些参数。在请求中添加下列参数:

  • type(必要):指示按钮的参数类型。支持的值:payloadtextcoupon_code
  • payload(对于 quick_reply 按钮为必要项):除按钮上的显示文本外,点击按钮时还将返回开发者定义的负载。
  • text(对于 url 按钮为必要项):开发者提供的后缀,将附加到之前创建的动态网址按钮。
  • 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 对象

WhatsApp Business API(详情请参见“本地 API”>“参考文档”)v2.39 已停用 hsm 对象。请改为使用 template 对象。

名称 描述

namespace

必要。

要使用的命名空间。从 v2.2.7 开始,如果命名空间与 element_name 不匹配,消息发送将失败。

element_name

必要。

元素名称,表示要在命名空间中使用哪个模板。从 v2.2.7 开始,如果 element_name 与命名空间不匹配,消息发送将失败。

language

必要。

允许指定 deterministic 语言。详情请参阅语言部分。


此字段用于支持 fallback 选项,但 v2.27.8 中已停用该选项。

localizable_params

必要。

此字段为值数组,会应用于模板中的变量之中。详情请参阅可本地化参数部分。

互动对象

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.

操作对象

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 客户端错误代码HTTP 状态代码(“本地 API”>“参考文档”)。

从 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

三个倒引号 (```)

```print 'Hello World';```

表现

在此上下文中,“表现”代表在指定秒数内使用 WhatsApp Business API(详情请参见“本地 API”>“参考文档”)客户端可以发送的消息数量。可实现的最佳表现程度取决于不同因素,最重要的因素是您的客户端设置选项以及消息是发送给新用户还是现有用户——在向新用户发送消息时,加密会话设置需要的时间较长一些。

客户端设置每秒支持的文本消息数量

单个分片

70

多个分片(32 片)

250

常见问题

注意:请勿使用 WhatsApp Business API 向同一位收信人重复发送相同消息。

送达率不是 100% 可能有很多原因。其中一些常见情况包括:用户的网络断断续续、用户在一段时间内没有任何活动,或为建立 优质用户体验

可以通过 WhatsApp 送达的消息有非常高的送达率。但也存在很多原因可能导致消息送达失败。您可以通过监控回调,了解消息的确切状态。这与通过短信发送消息不同,例如,对于短信,您无法访问最终的送达状态,而再次发送消息可能确实会产生不同的成效。

消息未能成功送达的原因可能是用户的手机停机、没电,或者用户的手机遗失,并在更换新手机时弃用了 SIM 卡。也有可能是公司的客户端出错,因而无法连接到网络,或者是因为回调 (Webhook) 没有送达。您可使用 health 节点监控这些状况。您可以开启服务器接收回调,以便在消息进入 WhatsApp 服务器云时收到通知。

当用户重新连接到网络时,您之前发送的所有消息都会送达给用户。对用户而言,收到多条内容相同的消息会是非常糟糕的体验。因此,用户很可能会将您拉黑或者投诉您。您可能会遭到禁言。

如果您在发送消息后收到 API 发送的消息 ID,则说明您已经完成对此消息的发送。请勿向同一个收信人重复发送相同内容。

如果您发现送达率长期偏低,请提交支持工单至 站内支持

在发送消息时,只要您获得了消息编号,便意味着系统已将该消息请求存储在数据库中。WhatsApp Business API 客户端会不断尝试发送该消息,直至收到 WhatsApp 服务器的确认为止。这一过程没有结束期限。然后 WhatsApp 服务器会尝试将该消息发送至用户的手机。如果用户的手机不在线,则消息将在 WhatsApp 服务器中存储 30 天,然后失效。

可以!WhatsApp 支持您对消息中的选中文本作加粗、斜体、加删除线处理,或对其采用等宽字体。

目前,您无法知道有多少用户,或者哪些用户已屏蔽您的公司。获知这一信息的最佳方法是侦听回调状态,如果您未收到 delivered 状态,则表明用户已屏蔽贵公司,或者用户未连接到网络。详情请参阅 Webhook 文档。

如果用户已屏蔽贵公司,联系人 API 会继续返回“该手机号是有效的 WhatsApp 用户”这一消息。然而,在您发送消息时,系统永远不会将其传送出去。如果是付费消息,则您无需付费。

不能,我们无法保证消息的接收顺序与发送顺序相同。如果排序对您的用例十分重要,我们建议您在侦听到第一条消息的已发送回调后,再触发第二条消息。

使用 messages 节点时,您需要将 Content-Type 标头设置为 application/json,以便 WhatsApp Business API 客户端能够妥善解析消息正文。此外,您还需要设置 Authorization 标头,该标头必须包含一个未过期的访问口令。请参阅登录和身份验证文档,了解如何获取口令,以及口令将于何时过期。

在某些情况下,您可能需要更多时间来处理消费者查询,或者您只能在 24 小时后回复消息。我们建议您创建消息模板,以:

  • 将结果发送给用户,或
  • 提醒用户回复以开启客户服务窗口。

在这两种情况中,请务必为消息模板提供尽可能多的上下文。例如:

  • “{{1}},您好,关于您之前报告的问题,我们很遗憾地通知您 {{2}}。对于给您带来的任何不便,我们深表歉意。”
  • 我们已更新您的请求单。如果您想继续获得支持服务,请回复。”