使用 CreateWhatsAppMessageTemplate API 建立訊息範本 - AWS 最終使用者傳訊社交

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

使用 CreateWhatsAppMessageTemplate API 建立訊息範本

您可以使用最終使用者傳訊社交 API 建立自訂的 WhatsApp 訊息範本。本主題說明如何使用 CreateWhatsAppMessageTemplate 來建立各種 WhatsApp 訊息範本。

訊息範本元件

WhatsApp 訊息範本可以包含下列元件:

  • 標題:標題文字顯示在頂端

  • 內文:具有變數預留位置的主要訊息內容

  • 頁尾:底部的其他資訊

  • 按鈕:連結至 URLs可點選元素

在下列範例中,將 ENDPOINTWABA_ID 取代為您的實際端點 URL 和 WhatsApp 商業帳戶 ID。

建立基本英文公用程式範本

此範例會建立僅使用 BODY元件的英文公用程式訊息範本,且不包含 HEADERFOOTERBUTTON元件。內文文字使用變數預留位置。

$ aws social-messaging create-whats-app-message-template --region us-east-1 --endpoint-url ENDPOINT_URL \ --id WABA_ID \ --template-definition '{ "name": "order_update_basic", "language": "en_US", "allow_category_change": true, "category": "UTILITY", "components": [ { "type": "BODY", "text": "Hi {{1}}, your order #{{2}} has been shipped. Track your delivery below." } ] }'

使用 按鈕建立基本英文公用程式範本

此範例會建立包含 BODYBUTTON元件的英文公用程式訊息範本。

$ aws social-messaging create-whats-app-message-template --region us-east-1 --endpoint-url ENDPOINT_URL \ --id WABA_ID \ --template-definition '{ "name": "order_update_with_button", "language": "en_US", "allow_category_change": true, "category": "UTILITY", "components": [ { "type": "BODY", "text": "Hi {{1}}, your order #{{2}} has been shipped. Track your delivery below." }, { "type": "BUTTONS", "buttons": [ { "type": "URL", "text": "Track Order", "url": "https://example.com/track" } ] } ] }'

使用標頭、內文和按鈕建立複雜的英文公用程式訊息範本

此範例會建立包含 HEADERBODY、 和 BUTTON元件的英文公用程式訊息範本。

$ aws social-messaging create-whats-app-message-template --region us-east-1 --endpoint-url ENDPOINT_URL \ --id WABA_ID \ --template-definition '{ "name": "account_creation_confirmation_3333", "category": "UTILITY", "language": "en_US", "status": "APPROVED", "components": [ { "type": "HEADER", "format": "TEXT", "text": "Finalize account set-up" }, { "type": "BODY", "text": "Hi {{1}},\n\nYour new account has been created successfully. \n\nPlease verify {{2}} to complete your profile.", "example": { "body_text": [ [ "John", "your email address" ] ] } }, { "type": "BUTTONS", "buttons": [ { "type": "URL", "text": "Verify account", "url": "https://www.example.com/" } ] } ] }'

建立基本行銷訊息範本

此範例會建立僅包含BODY元件的基本行銷訊息範本。

$ aws social-messaging create-whats-app-message-template --region us-east-1 --endpoint-url ENDPOINT_URL \ --id WABA_ID \ --template-definition '{ "id": "1290345849293233", "name": "holiday_special_1395238", "category": "MARKETING", "language": "en_US", "status": "PENDING", "components": [ { "type": "BODY", "text": "Season's Greetings {{1}}!\n\nCelebrate {{2}} with amazing deals up to {{3}} off.\n\nPlus, get free gift wrapping on all orders above $50.", "example": { "body_text": [ [ "Pawan", "Christmas", "30%" ] ] } } ], "metaTemplateId": "1290345849293233" }'

建立複雜的行銷訊息範本

此範例會建立包含 HEADERBODY、 和 BUTTON元件的英文行銷訊息範本。

$ aws social-messaging create-whats-app-message-template --region us-east-1 \ --endpoint-url ENDPOINT_URL \ --id WABA_ID \ --template-definition '{ "name": "summer_sale_1", "category": "MARKETING", "language": "en_US", "status": "APPROVED", "components": [ { "type": "HEADER", "format": "TEXT", "text": "Summer Sale!" }, { "type": "BODY", "text": "Hi {{1}}! Get {{2}} off all summer items. Shop now before stock runs out!" }, { "type": "FOOTER", "text": "Valid until August 31st" }, { "type": "BUTTONS", "buttons": [ { "type": "URL", "text": "Shop Now", "url": "https://example.com/sale" } ] } ] }'