使用 CreateWhatsAppMessageTemplate API 创建消息模板 - AWS 最终用户消息社交

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用 CreateWhatsAppMessageTemplate API 创建消息模板

您可以使用最终用户 WhatsApp 消息社交 API 创建自定义消息模板。本主题介绍如何使用创建各种 WhatsApp 消息模板。CreateWhatsAppMessageTemplate

消息模板组件

WhatsApp 消息模板可以包括以下组件:

  • 题:出现在顶部的标题文本

  • 正文:带有可变占位符的主消息内容

  • 页脚:底部的附加信息

  • 按钮:链接到的可点击元素 URLs

在以下示例中,将ENDPOINTWABA_ID替换为实际的终端节点 URL 和 WhatsApp 企业账户 ID。

创建基本的英语实用程序模板

此示例用英语创建了一个实用程序消息模板,该模板仅使用BODY组件,不包括HEADERFOOTER、或BUTTON组件。正文使用可变占位符。

$ 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" } ] } ] }'