/v1/messages
messages
ノードを使って、テキストメッセージ、メディアメッセージ、連絡先メッセージ、位置情報メッセージ、インタラクティブメッセージ、ならびにメッセージテンプレートをカスタマーに送信します。
送信可能なメッセージの具体的な種類については、テキストメッセージ、メディアメッセージ、連絡先メッセージと位置情報メッセージ、インタラクティブメッセージ、メッセージテンプレート、メディアメッセージテンプレート、インタラクティブメッセージテンプレートのガイドをご覧ください。
以下のことが必要です。
v2.39以降は、メッセージの送信前にcontactsノードを呼び出す必要がなくなりました。
メッセージを送信するには、メッセージの種類に関係なく、/messages
ノードにPOST
呼び出しを実行します。JSONメッセージ本文の内容は、メッセージの種類(テキストや画像など)によって異なります。
/messages
POSTリクエストで使用される主なパラメーターは以下のとおりです。
名前 | 説明(指定できるオプションについては、左側の列の矢印をクリックしてください。) |
---|---|
|
オーディオを含む |
| 任意。 トラッキングに便利な任意の文字列。 例えば、このフィールドにメッセージテンプレートIDを渡して、最初に顧客に送信したメッセージから始まるカスタマージャーニーを追跡できます。その後、様々なメッセージテンプレートタイプのROIを追跡して、最も効果的なタイプを決定できます。 WhatsApp Business Accountの クラウドAPIはこのフィールドを処理するのではなく、送信/配信/読み取りメッセージWebhookの一部として返します。 最大512文字。 クラウドAPIのみ。 |
|
|
| 会話中のいずれかのメッセージに返信する場合、必須。 返信先の以前のメッセージのIDを含むオブジェクト。以下はその例です。
クラウドAPIのみ。 |
|
ドキュメントを含む |
|
オンプレミスAPIのみ。 |
|
画像を含む |
|
|
|
|
| 必須 リクエストに使用されたメッセージサービス。 クラウドAPIのみ。 |
|
テキストメッセージでURLのプレビューを許可 — テキストメッセージでURLを送信するをご覧ください。メッセージにURLを含めない場合は、このフィールドは任意です。値: オンプレミスAPIのみ。クラウドAPIユーザーは、テキストオブジェクト内の |
| 任意。 現在、個人にしかメッセージを送信できません。これは デフォルト: |
| メッセージのステータス。このフィールドを使用してメッセージを
|
|
スタンプを含む クラウドAPI: あらゆる種類のインバウンドスタンプに加えて、静的およびアニメーション付きサードパーティアウトバウンドスタンプに対応しています。静的スタンプは512x512ピクセルである必要があり、100 KBを超えることはできません。アニメーション付きスタンプは512x512ピクセルである必要があり、500 KBを超えることはできません。 オンプレミスAPI: あらゆる種類のインバウンドスタンプに加えて、静的なサードパーティアウトバウンドスタンプのみに対応しています。静的スタンプは512x512ピクセルである必要があり、100 KBを超えることはできません。アニメーション付きスタンプはサポートされていません。 |
|
|
| テキストメッセージに必要。 |
| 必須。 メッセージを送信したい顧客のWhatsApp IDまたは電話番号。電話番号のフォーマットをご覧ください。 必要に応じて、オンプレミスAPIユーザーは、 |
| 任意。 送りたいメッセージのタイプ。省略すると、デフォルトで |
名前 | 説明 |
---|---|
| 必須。 メッセージのテキストが入ります。URLと書式設定を含めることができます。 |
オンプレミスAPIの場合、media
エンドポイントを通じてメディアがWhatsApp Businessオンプレミス/リファレンスのクライアントへのアップロードが成功した場合に、メディアオブジェクトトIDが返されます。
Name | Description |
---|---|
| Required when The media object ID. Do not use this field when message |
| Required when The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URLs. Do not use this field when message Cloud API users only:
|
| Optional. Media asset caption. Do not use with On-Premises API users:
|
| Optional. Describes the filename for the specific document. Use only with The extension of the filename will specify what format the document is displayed as in WhatsApp. |
| Optional. On-Premises API only. This path is optionally used with a |
contacts
の中には、addresses
、emails
、name
、org
、phone
、urls
をオブジェクトとして入れ子にすることができます。複数化オブジェクトは、以下の例に示すように配列でラッピングされます。
Name | Description |
---|---|
| Optional. Full contact address(es) formatted as an
|
| Optional.
|
| Optional. Contact email address(es) formatted as an
|
| Required. Full contact name formatted as a
*At least one of the optional parameters needs to be included along with the |
| Optional. Contact organization information formatted as an
|
| Optional. Contact phone number(s) formatted as a
|
| Optional. Contact URL(s) formatted as a
|
複数化オブジェクトが中に含まれている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" }] } ]
Name | Description |
---|---|
| Required. Location latitude in decimal degrees. |
| Required. Location longitude in decimal degrees. |
| Required. Name of the location. |
| Required. Address of the location. |
template
の中に、components
とlanguage
のオブジェクトをネストできます。
v2.27.8
以降、テンプレートのnamespace
は、現在のWhatsApp Businessオンプレミスクライアントの電話番号を所有するWABAに関連付けられたネームスペースでなければなりません。そうしないと、メッセージの送信に失敗します。
さらに、v2.41
以降はnamespace
が任意のフィールドになります。
名前 | 説明 |
---|---|
| 必須。 テンプレートのネームスペース。
|
| 必須。 テンプレートの名前。 |
| 必須。 テンプレートがレンダリングされる言語を指定します。メディアテンプレートメッセージでは、 |
| 任意。 メッセージのパラメーターを含む配列。 |
components
の中に、parameters
オブジェクトをネストできます。さらに、type
をbutton
に設定することができます。
名前 | 説明 |
---|---|
| 必須。
|
| 任意。 メッセージのコンテンツを含む配列。 |
名前 | 説明 |
---|---|
| 必須。
メディアタイプ(
|
components
オブジェクトの中で、type
をbutton
に設定できます。ボタンのパラメーターは次のとおりです。
名前 | 説明 |
---|---|
| 必須。 作成するボタンのタイプ: |
| 必須。 ボタンの位置インデックス。インデックス値として |
| 必須。 ボタンのパラメーター。ビジネスマネージャでの作成時に設定されます。次のパラメーターを指定します。
|
sub_typeがquick_reply
のbutton
タイプの例:
{ "type": "button", "sub_type": "quick_reply", "index": 0, "parameters": [{ "type": "payload", "payload": "Yes-Button-Payload" }] }
sub_typeがbutton
のcopy_code
タイプの例
{ "type": "button", "sub_type": "copy_code", "index": 0, "parameters": [{ "type": "coupon_code", "coupon_code": "DISCOUNT20" }] }
hsm
オブジェクトは、WhatsApp Businessオンプレミス/リファレンスのv2.39
で廃止されました。代わりにtemplate
オブジェクトを使ってください。
名前 | 説明 |
---|---|
| 必須。 使用するネームスペース。 |
| 必須。 ネームスペース内で使用されるテンプレートを示すエレメント名。 |
| 必須。 決定性言語を指定できます。詳しくは、languageセクションをご覧ください。 このフィールドで |
| 必須。 このフィールドは、テンプレート内の変数に適用される値の配列です。詳しくは、ローカライズ可能なパラメーターのセクションをご覧ください。 |
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:
header
, you can nest media
objects.action
, you can nest section
and button
objects.Name | Description |
---|---|
| Required. The type of interactive message you want to send. Supported values:
|
| Required for type Header content displayed on top of a message. You cannot set a The
|
| Optional for type An object with the body of the message. The
|
| Optional. An object with the footer of the message. The
|
| Required. An |
Name | Description |
---|---|
| 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. |
| Required for Reply Button Messages. A
IDを設定するときには、前後にスペースがあってはなりません。 |
| Required for List Messages and Multi-Product Messages. Array of |
| 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. |
| 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. |
| Optional for Flows Messages. The current mode of the Flow, either Default: |
| Required for Flows Messages. Must be |
| Required for Flows Messages. A token that is generated by the business to serve as an identifier. |
| Required for Flows Messages. Unique identifier of the Flow provided by WhatsApp. |
| Required for Flows Messages. Text on the CTA button, eg. "Signup". Maximum length: 20 characters (no emoji). |
| Optional for Flows Messages.
Default: |
| Optional for Flows Messages. Required only if
|
Name | Description |
---|---|
| Required if the message has more than one Title of the section. Maximum length: 24 characters. |
| Required for List Messages. Contains a list of row objects. Limited to 10 rows across all sections. Each
|
| Required for Multi-Product Messages. Array of Each
|
音声メッセージ:
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": { "catalog_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" } ... ]}, ... ] }, } }
応答のpayload
の例を以下に示します。簡略化のため、メタオブジェクトとエラーオブジェクトは省略しています。
{ "messages": [{ "id": "message-id" }] }
リクエストが成功すると、メッセージIDを含む応答が返されます。リクエストがerrors
セクションを返した場合は、送信したメッセージを確認して、エラーを修正してから、リクエストを再送してください。エラーについて詳しくは、WhatsApp Businessオンプレミス/リファレンスのクライアントのエラーコードと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では一部メッセージの書式設定ができます。次の書式設定記号を使ってメッセージの一部、または全体の書式を設定します。
書式 | 記号 | 例 |
---|---|---|
太字 | アスタリスク(*) | ご注文金額の合計は*¥1,050*になります。 |
斜体 | アンダースコア(_) | _WhatsApp_をご利用いただきありがとうございます! |
波線(~) | これは~日本一~世界一です。 | |
| 3連バッククォート(```) | ```print 'Hello World';``` |
このコンテキストにおけるパフォーマンスとは、WhatsApp Businessオンプレミス/リファレンスクライアントを使用して特定の1秒間で送信できるメッセージの数を表します。どこまで高いパフォーマンスを達成できるかは、さまざまな要素に応じて異なります。最も重要な要素はクライアント設定の選択、およびメッセージ送信先が新規ユーザーかそれとも既存ユーザーかという点です。暗号化セッションの設定の場合、新規ユーザーとのメッセージングにかかる時間が多少長くなります。
クライアントの設定 | 1秒間にサポートされるテキストメッセージ |
---|---|
単一シャード | 70 |
複数シャード(32シャード) | 250 |
注:WhatsApp Business APIを使用して、同じ受信者に同じメッセージを繰り返し送信しないでください。
配信率が100%でない場合は、いくつかの理由が考えられます。よくあるケースとしては、ネットワークにたまにしかアクセスしないユーザーや、一定期間アクティブでないユーザーがいることや、高品質のユーザーエクスペリエンスを作成すること が挙げられます。
WhatsAppで配信可能なメッセージには、配信率が非常に高いという傾向があります。しかし、メッセージが配信されなくなり得る理由はたくさんあります。コールバックをモニタリングすることで、メッセージの正確なステータスを把握することができます。しかし、これは、例えば、SMSでメッセージを送信する場合とは異なります。この場合、最終送信ステータスにアクセスできなかったため、メッセージを再送信すると、まったく異なる結果になる可能性があります。
ユーザーの携帯電話が故障している、バッテリ切れである、または携帯電話を紛失したユーザーが新しい携帯電話を入手して以前のSIMを停止したなどの理由で、メッセージが配信されないままになっていることがあります。ビジネスクライアントがネットワークに接続しようとするときにエラーが発生する可能性があります。コールバック(Webhooks)が配信されない可能性もあります。health
ノードを使えば、これらの状況をモニタリングすることができます。サーバーの受信コールバックをオンにして、メッセージがWhatsAppサーバークラウドに配信されたことを確認できます。
ユーザーがネットワークに再接続した場合は、送信したメッセージがすべてユーザーに送信されます。同じコンテンツのメッセージを何通も受信することは、ユーザーにとって気持ちのよいことではありません。ユーザーからブロックされたり、クレームを受けたりする確立が高まります。配信登録が解除されかねません。
送信したメッセージに対してAPIからメッセージIDを受け取ったなら、そのメッセージを送信するためにすべきことはすべて完了しています。同じコンテンツを同じ受信者に再送信しないでください。
長期にわたって配信率が低下している場合は、 ダイレクトサポートからサポートチケットを提出してください。
メッセージを送信するとメッセージIDが返されますが、それはメッセージリクエストがデータベースに格納されたことを意味します。WhatsAppビジネスAPIクライアントは、WhatsAppサーバーによって認識されるまで、そのメッセージの送信を試行し続けます。このプロセスに終了期限はありません。次に、WhatsAppサーバーは、メッセージをユーザーの携帯電話に配信しようとします。ユーザーの携帯電話がオンラインでない場合、メッセージは30日間保存された後、WhatsAppサーバーによって破棄されます。
はい、できます。WhatsAppでは、メッセージ内の選択したテキストに、太字、斜体、取り消し線、または等幅のフォーマットを設定することができます。
現時点では、何人のユーザーが、またどのユーザーが、ビジネスをブロックしたかを知る方法はありません。最良の指標としては、ステータスコールバックをリッスンし、delivered
ステータスを受け取らない場合、そのユーザーはビジネスをブロックしているか、ネットワーク接続がないかのいずれかであることがわかります。詳細については、Webhookに関するドキュメントをご覧ください。
ユーザーがビジネスをブロックしている場合でも、Contacts APIは引き続きその電話番号を有効なWhatsAppユーザーとして返します。しかし、メッセージを送信しても、配信されることはありません。それが有料メッセージの場合、料金は発生しません。
いいえ。メッセージが送信された順序で到着することは保証されていません。順序が重要な使用事例では、最初のメッセージの配信のコールバックをリッスンしてから、2つ目のメッセージを送信する方法を推奨します。
お客様の問い合わせを処理するのに通常よりも時間がかかる場合や、24時間後にしか回答できない場合があります。そのような場合のために、次のいずれかのメッセージテンプレートを作成することをおすすめします。
どちらの場合も、メッセージテンプレートに状況に関連する情報をできるだけ多く含めてください。例: