

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 AWS 最終使用者傳訊社交中傳送範本訊息的範例
<a name="send-message-text"></a>

如需可傳送的訊息範本類型詳細資訊，請參閱 *WhatsApp Business Platform Cloud API 參考*中的[訊息範本](https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates)。如需可傳送的訊息類型清單，請參閱 *WhatsApp Business Platform Cloud API 參考*中的[訊息](https://developers.facebook.com/docs/whatsapp/conversation-types/)。

下列範例示範如何使用 範本，使用 [傳送訊息](https://docs.aws.amazon.com//social-messaging/latest/APIReference/API_SendWhatsAppMessage.html)給您的客戶 AWS CLI。如需設定 的詳細資訊 AWS CLI，請參閱[AWS Command Line Interface 《 使用者指南](https://docs.aws.amazon.com/cli/latest/userguide/)》中的[設定 AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)。

**注意**  
使用 第 2 AWS CLI 版時，您必須指定 base64 編碼。這可以透過新增 AWS CLI 參數`--cli-binary-format raw-in-base64-out`或變更 AWS CLI 全域組態檔案來完成。如需詳細資訊，請參閱《 第 *AWS 2 版命令列界面使用者指南*[https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-settings)》中的 。

```
aws socialmessaging send-whatsapp-message --message '{"messaging_product":"whatsapp","to":"'{PHONE_NUMBER}'","type":"template","template":{"name":"statement","language":{"code":"en_US"},"components":[{"type":"body","parameters":[{"type":"text","text":"1000"}]}]}}' --origination-phone-number-id {ORIGINATION_PHONE_NUMBER_ID} --meta-api-version v20.0
```

針對上述命令執行以下事項：
+ 使用客戶的電話號碼取代 *\$1PHONE\$1NUMBER\$1*。
+ 將 *\$1ORIGINATION\$1PHONE\$1NUMBER\$1ID\$1* 取代為您的電話號碼 ID。

下列範例示範如何傳送不包含任何元件的範本訊息。

```
aws socialmessaging send-whatsapp-message --message '{"messaging_product": "whatsapp","to": "'{PHONE_NUMBER}'","type": "template","template": {"name":"simple_template","language": {"code": "en_US"}}}' --origination-phone-number-id {ORIGINATION_PHONE_NUMBER_ID} --meta-api-version v20.0
```
+ 使用客戶的電話號碼取代 *\$1PHONE\$1NUMBER\$1*。
+ 將 *\$1ORIGINATION\$1PHONE\$1NUMBER\$1ID\$1* 取代為您的電話號碼 ID。