本文件說明如何傳送含一次性密碼按鈕的驗證範本。
使用 WhatsApp Business 電話號碼 > 訊息端點,傳送含一次性密碼按鈕的驗證範本訊息。
POST /<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>/messages
{ "messaging_product": "whatsapp", "recipient_type": "individual", "to": "<CUSTOMER_PHONE_NUMBER>", "type": "template", "template": { "name": "<TEMPLATE_NAME>", "language": { "code": "<TEMPLATE_LANGUAGE_CODE>" }, "components": [ { "type": "body", "parameters": [ { "type": "text", "text": "<ONE-TIME PASSWORD>" } ] }, { "type": "button", "sub_type": "url", "index": "0", "parameters": [ { "type": "text", "text": "<ONE-TIME PASSWORD>" } ] } ] } }
預留位置 | 說明 | 範例值 |
---|---|---|
| 顧客的 WhatsApp 電話號碼。 |
|
| 要傳遞給顧客的一次性密碼或驗證碼。 請注意,此值必須在承載中出現兩次。 最多 15 個字元。 |
|
| 範本的語言和地區設定代碼。 |
|
| 範本的名稱。 |
|
成功時,API 會回應:
{ "messaging_product": "whatsapp", "contacts": [ { "input": "<INPUT>", "wa_id": "<WA_ID>" } ], "messages": [ { "id": "<ID>" } ] }
預留位置 | 說明 | 範例值 |
---|---|---|
字串 | 接收訊息之顧客的電話號碼,可能與 |
|
字串 | 接收訊息之顧客的 WhatsApp 編號,可能與 |
|
字串 | WhatsApp 訊息編號。您可以使用列在「wamid.」後面的編號來追蹤訊息狀態。 |
|
curl -L 'https://graph.facebook.com/v19.0
/105954558954427/messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "12015553931",
"type": "template",
"template": {
"name": "verification_code",
"language": {
"code": "en_US"
},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "J$FpnYnP"
}
]
},
{
"type": "button",
"sub_type": "url",
"index": "0",
"parameters": [
{
"type": "text",
"text": "J$FpnYnP"
}
]
}
]
}
}'
{ "messaging_product": "whatsapp", "contacts": [ { "input": "12015553931", "wa_id": "12015553931" } ], "messages": [ { "id": "wamid.HBgLMTY1MDM4Nzk0MzkVAgARGBI4Qzc5QkNGNTc5NTMyMDU5QzEA" } ] }