aws-social-messaging
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAWS End User Messaging Social — WhatsApp
AWS End User Messaging Social — WhatsApp
Overview
概述
WhatsApp messaging via AWS End User Messaging Social: template management, sending, media handling, event destinations, and delivery troubleshooting.
Recommended setup: Use the AWS MCP server for sandboxed execution, audit logging, and enterprise controls.
Without AWS MCP: This skill works with any agent that has AWS CLI access. All commands use standard AWS CLI syntax.
通过AWS End User Messaging Social实现WhatsApp消息功能:模板管理、消息发送、媒体处理、事件目标配置以及投递故障排查。
推荐配置: 使用AWS MCP server实现沙箱执行、审计日志记录和企业级管控。
不使用AWS MCP的情况: 该技能可与任何具备AWS CLI访问权限的Agent配合使用。所有命令均采用标准AWS CLI语法。
Common Tasks
常见任务
1. Verify Dependencies
1. 验证依赖项
Constraints:
- The AWS MCP server is recommended for seamless API execution but not required — all commands use standard AWS CLI syntax
- You MUST verify the AWS CLI is installed and configured with appropriate credentials
- You SHOULD recommend the user assume an IAM role with ephemeral credentials
- You MUST inform the user if any required tool is missing and how to install/configure it
- You MUST ask the user if they want to proceed despite any missing tools
- If the subcommand is not recognized, the user must update to the latest AWS CLI version
aws socialmessaging - Required IAM permissions (scope to specific WABA and phone number ARNs):
- Templates: ,
social-messaging:CreateWhatsAppMessageTemplate,social-messaging:GetWhatsAppMessageTemplate,social-messaging:ListWhatsAppMessageTemplates,social-messaging:UpdateWhatsAppMessageTemplate,social-messaging:DeleteWhatsAppMessageTemplate,social-messaging:ListWhatsAppTemplateLibrarysocial-messaging:CreateWhatsAppMessageTemplateFromLibrary - Sending:
social-messaging:SendWhatsAppMessage - Media: ,
social-messaging:PostWhatsAppMessageMedia,social-messaging:CreateWhatsAppMessageTemplateMedia,social-messaging:GetWhatsAppMessageMediasocial-messaging:DeleteWhatsAppMessageMedia - Events:
social-messaging:PutWhatsAppBusinessAccountEventDestinations - Diagnostics: ,
social-messaging:GetLinkedWhatsAppBusinessAccount,social-messaging:GetLinkedWhatsAppBusinessAccountPhoneNumbersocial-messaging:ListLinkedWhatsAppBusinessAccounts - Supporting: ,
sns:ListSubscriptionsByTopic(for event destination role)iam:PassRole
- Templates:
约束条件:
- 推荐使用AWS MCP server以实现无缝API执行,但非必需——所有命令均采用标准AWS CLI语法
- 必须验证AWS CLI已安装并配置了适当的凭证
- 应建议用户使用带有临时凭证的IAM角色
- 若缺少任何必需工具,必须告知用户并说明安装/配置方法
- 必须询问用户是否要在缺少工具的情况下继续操作
- 若子命令无法被识别,用户必须升级到最新版本的AWS CLI
aws socialmessaging - 所需IAM权限(限定于特定WABA和电话号码ARN):
- 模板:,
social-messaging:CreateWhatsAppMessageTemplate,social-messaging:GetWhatsAppMessageTemplate,social-messaging:ListWhatsAppMessageTemplates,social-messaging:UpdateWhatsAppMessageTemplate,social-messaging:DeleteWhatsAppMessageTemplate,social-messaging:ListWhatsAppTemplateLibrarysocial-messaging:CreateWhatsAppMessageTemplateFromLibrary - 消息发送:
social-messaging:SendWhatsAppMessage - 媒体:,
social-messaging:PostWhatsAppMessageMedia,social-messaging:CreateWhatsAppMessageTemplateMedia,social-messaging:GetWhatsAppMessageMediasocial-messaging:DeleteWhatsAppMessageMedia - 事件:
social-messaging:PutWhatsAppBusinessAccountEventDestinations - 诊断:,
social-messaging:GetLinkedWhatsAppBusinessAccount,social-messaging:GetLinkedWhatsAppBusinessAccountPhoneNumbersocial-messaging:ListLinkedWhatsAppBusinessAccounts - 支持:,
sns:ListSubscriptionsByTopic(用于事件目标角色)iam:PassRole
- 模板:
2. Manage Templates
2. 管理模板
Create, update, and delete message templates (utility, marketing, authentication).
- : base64-encode
create-whatsapp-message-template(blob type)--template-definition - : use pre-approved Meta library templates
create-whatsapp-message-template-from-library - : browse available library templates
list-whatsapp-template-library - : retrieve template details by
get-whatsapp-message-template(WABA) and--id--meta-template-id - : modify existing template content
update-whatsapp-message-template - : requires
delete-whatsapp-message-template(NOT--template-name); always include--meta-template-name--delete-all-languages - : response fields are
list-whatsapp-message-templatesandtemplateStatus(NOTtemplateCategory/status)category - Templates with parameters MUST include
{{N}}(exception: AUTHENTICATION — Meta handles OTP parameters automatically) and"parameter_format": "positional""example" - Meta reviews all templates (minutes to 24h); MUST NOT send with PENDING/REJECTED
- Choosing the wrong category causes reclassification (UTILITY → MARKETING) which changes pricing — see managing-templates.md — Choosing the Right Category for guidance on selecting UTILITY vs MARKETING vs AUTHENTICATION
- You MUST confirm the intended category (UTILITY, MARKETING, or AUTHENTICATION) with the user before creating a template — explain the categorization criteria and reclassification risk if the choice is ambiguous
See managing-templates.md.
创建、更新和删除消息模板(实用类、营销类、认证类)。
- :需对
create-whatsapp-message-template进行base64编码(blob类型)--template-definition - :使用Meta预审批的模板库模板
create-whatsapp-message-template-from-library - :浏览可用的库模板
list-whatsapp-template-library - :通过
get-whatsapp-message-template(WABA)和--id检索模板详情--meta-template-id - :修改现有模板内容
update-whatsapp-message-template - :需要
delete-whatsapp-message-template(而非--template-name);必须始终包含--meta-template-name参数--delete-all-languages - :响应字段为
list-whatsapp-message-templates和templateStatus(而非templateCategory/status)category - 包含参数的模板必须添加
{{N}}(例外:认证类模板——Meta会自动处理OTP参数)以及"parameter_format": "positional"字段"example" - Meta会审核所有模板(耗时数分钟至24小时);不得使用处于PENDING/REJECTED状态的模板
- 选择错误的模板类别会导致重新分类(如UTILITY→MARKETING),进而影响定价——请参考managing-templates.md — 选择正确类别以了解UTILITY、MARKETING和AUTHENTICATION类别的选择指南
- 在创建模板前,必须与用户确认预期的类别(UTILITY、MARKETING或AUTHENTICATION)——若用户选择不明确,需解释分类标准及重新分类的风险
详情请见managing-templates.md。
3. Send Messages
3. 发送消息
Template Messages (no 24h restriction)
模板消息(无24小时限制)
- Use for: transactional updates (utility), promotions (marketing), verification codes (authentication)
- Collect: phone number ID, recipient (E.164 with ), template name, language, parameters
+ - Marketing templates may include image headers
- is blob type — MUST base64-encode JSON
--message
- 适用场景:交易更新(实用类)、促销活动(营销类)、验证码(认证类)
- 需要收集的信息:电话号码ID、收件人(带的E.164格式)、模板名称、语言、参数
+ - 营销类模板可包含图片头部
- 为blob类型——必须对JSON进行base64编码
--message
Freeform Messages (24h window required)
自由格式消息(需在24小时窗口内)
- Use for: customer service replies within 24h of customer's last inbound message
- Supports: text, image, document, video, audio — see WhatsApp Cloud API media reference for supported format and size constraints
- No API to check window status — user must confirm from logs or event history
- Media URLs MUST be publicly accessible HTTPS and remain available for the full 30-day message availability window (Meta can re-fetch anytime). For sensitive content (receipts, invoices, PII), upload via and reference by media ID instead — presigned URLs cannot satisfy the 30-day availability requirement
post-whatsapp-message-media
Constraints for all sends:
- Before executing any API call, validate parameter formats:
- Phone number IDs match pattern
phone-number-id-* - WABA IDs match pattern
waba-* - Recipient numbers are E.164 with prefix (e.g.,
+), or Business-Scoped User ID (BSUID) via the+14155551234field"recipient" - Template names contain only lowercase letters, numbers, and underscores
- Language codes use Meta's locale format with underscores (e.g., ,
en_US)pt_BR - is
--meta-api-versionformat (e.g.,v{Major}.{Minor})v21.0
- Phone number IDs match
- MUST be
"messaging_product"in the JSON body; check Meta's Graph API changelog for the supported Meta Graph API version"whatsapp" - is blob type — MUST base64-encode the JSON payload
--message - A successful means queued, not delivered
messageId - You MUST ask for all required parameters upfront in a single prompt
- You MUST accept parameters as individual values, JSON objects, or file references
- You MUST explain each step before executing
- You SHOULD confirm all parameters with the user before executing
- You MUST respect the user's decision to abort
- You MUST NOT send more than 5 messages per batch without user confirmation
- You MUST NOT create or access credentials directly
See sending-messages.md.
- 适用场景:在用户最后一条入站消息的24小时内回复客户服务请求
- 支持类型:文本、图片、文档、视频、音频——请参考WhatsApp Cloud API媒体参考了解支持的格式和大小限制
- 无API可检查窗口状态——用户必须通过日志或事件历史确认
- 媒体URL必须是可公开访问的HTTPS链接,且在消息有效期30天内保持可用(Meta可随时重新获取)。对于敏感内容(收据、发票、个人身份信息),请通过上传并通过媒体ID引用——预签名URL无法满足30天可用性要求
post-whatsapp-message-media
所有消息发送的约束条件:
- 在执行任何API调用前,需验证参数格式:
- 电话号码ID需匹配格式
phone-number-id-* - WABA ID需匹配格式
waba-* - 收件人号码为带前缀的E.164格式(例如
+),或通过+14155551234字段使用业务范围用户ID(BSUID)"recipient" - 模板名称仅包含小写字母、数字和下划线
- 语言代码使用Meta的下划线分隔格式(例如,
en_US)pt_BR - 为
--meta-api-version格式(例如v{Major}.{Minor})v21.0
- 电话号码ID需匹配
- JSON体中的必须设置为
"messaging_product";请查看Meta Graph API更新日志了解支持的Meta Graph API版本"whatsapp" - 为blob类型——必须对JSON负载进行base64编码
--message - 成功返回仅表示消息已进入队列,不代表已投递
messageId - 必须一次性提示用户提供所有必填参数
- 必须接受以单个值、JSON对象或文件引用形式提供的参数
- 执行前必须解释每个步骤
- 执行前应与用户确认所有参数
- 必须尊重用户终止操作的决定
- 未经用户确认,批量发送消息不得超过5条
- 不得直接创建或访问凭证
详情请见sending-messages.md。
4. Manage Media
4. 管理媒体
Upload, retrieve, and delete media for messages and template headers.
- : upload media, returns reusable media ID
post-whatsapp-message-media - : upload media specifically for template headers
create-whatsapp-message-template-media - : retrieve media metadata/URL by ID
get-whatsapp-message-media - : remove uploaded media
delete-whatsapp-message-media
See managing-media.md.
上传、检索和删除用于消息及模板头部的媒体文件。
- :上传媒体,返回可重复使用的媒体ID
post-whatsapp-message-media - :专门为模板头部上传媒体
create-whatsapp-message-template-media - :通过ID检索媒体元数据/URL
get-whatsapp-message-media - :删除已上传的媒体
delete-whatsapp-message-media
详情请见managing-media.md。
5. Configure Event Destinations
5. 配置事件目标
Set up delivery tracking, template status notifications, and reclassification alerts.
Set up delivery tracking, template status notifications, and reclassification alerts. A WABA can only have one event destination. See configuring-event-destinations.md for prerequisites (IAM role, SNS topic with KMS encryption, HTTPS-only subscription endpoints, condition keys) and full security controls.
设置投递追踪、模板状态通知和重新分类告警。
设置投递追踪、模板状态通知和重新分类告警。一个WABA只能配置一个事件目标。请参考configuring-event-destinations.md了解前提条件(IAM角色、带KMS加密的SNS主题、仅HTTPS的订阅端点、条件键)及完整安全管控措施。
6. Troubleshoot Delivery
6. 排查投递问题
Diagnostic flow: WABA status → phone number → templates → event destinations → quotas.
- : registration MUST be COMPLETE
get-linked-whatsapp-business-account - : verify phone number health
get-linked-whatsapp-business-account-phone-number - : list all WABAs
list-linked-whatsapp-business-accounts - Template reclassified: detectable via event destinations (real-time) or by listing templates and comparing categories; delete and recreate
- 24h window expired: use template message instead
- Rate limiting: new WABAs have lower limits; increases with quality
- Recipient without WhatsApp: silently dropped
See troubleshooting-delivery.md.
诊断流程:WABA状态 → 电话号码 → 模板 → 事件目标 → 配额。
- :注册状态必须为COMPLETE
get-linked-whatsapp-business-account - :验证电话号码健康状态
get-linked-whatsapp-business-account-phone-number - :列出所有WABA
list-linked-whatsapp-business-accounts - 模板被重新分类:可通过事件目标(实时)或列出模板并对比类别检测;需删除并重新创建模板
- 24小时窗口已过期:改用模板消息
- 速率限制:新WABA的限制较低;限制会随消息质量提升而增加
- 收件人未使用WhatsApp:消息会被静默丢弃
详情请见troubleshooting-delivery.md。
Quick Reference — Common Errors
快速参考——常见错误
- Access denied: verify IAM permissions scoped to WABA/phone number ARNs
- Template rejected: body must match category; include and
parameter_formatexample - Template reclassified: configure event destinations to detect; delete and recreate
- 24h window expired: use template message instead of freeform
- Send fails: is the ID (not phone number); recipient E.164 with
--origination-phone-number-id+ - Queued but not delivered: 200 = queued; configure event destinations for status
- Media URL inaccessible: must be publicly accessible HTTPS
- 访问被拒绝:验证IAM权限是否限定于WABA/电话号码ARN
- 模板被拒绝:模板内容必须匹配类别;需包含和
parameter_format字段example - 模板被重新分类:配置事件目标以检测;删除并重新创建模板
- 24小时窗口已过期:改用模板消息而非自由格式消息
- 发送失败:是ID(而非电话号码);收件人需为带
--origination-phone-number-id的E.164格式+ - 已入队列但未投递:200状态码表示已入队列;配置事件目标以获取状态
- 媒体URL无法访问:必须是可公开访问的HTTPS链接
Security Considerations
安全注意事项
- Use least-privilege IAM policies scoped to specific actions and WABA/phone number ARNs
social-messaging: - Use ephemeral credentials (IAM roles) instead of long-lived access keys
- Store secrets in AWS Secrets Manager or Parameter Store — never in code or environment variables
- Enable CloudTrail for auditing all API calls; encrypt logs with KMS CMK
social-messaging - Encrypt SNS topics for event destinations with KMS (callbacks contain recipient metadata)
- Encrypt CloudWatch Logs with KMS if monitoring social-messaging activity
- Avoid sensitive data in template parameters and freeform message content (they appear in CloudTrail logs)
- Validate recipient phone numbers to prevent unauthorized messaging
- Verify SNS subscription endpoints are authorized by your team — validate that all subscribed email addresses and systems belong to personnel/systems that should receive sensitive delivery status and recipient metadata before confirming subscriptions. Use HTTPS-only endpoints
- Add condition keys (,
aws:SourceArn) to SNS topic policies to prevent confused deputy attacksaws:SourceAccount - Implement rate limiting via service quotas and CloudWatch alarms on send rates
- 使用最小权限IAM策略,限定于特定操作及WABA/电话号码ARN
social-messaging: - 使用临时凭证(IAM角色)而非长期访问密钥
- 将密钥存储在AWS Secrets Manager或Parameter Store中——切勿存储在代码或环境变量中
- 启用CloudTrail以审计所有API调用;使用KMS CMK加密日志
social-messaging - 对事件目标的SNS主题进行KMS加密(回调包含收件人元数据)
- 若监控social-messaging活动,使用KMS加密CloudWatch日志
- 避免在模板参数和自由格式消息内容中包含敏感数据(它们会出现在CloudTrail日志中)
- 验证收件人电话号码以防止未经授权的消息发送
- 验证SNS订阅端点是否经团队授权——在确认订阅前,验证所有订阅的电子邮件地址和系统是否属于有权接收敏感投递状态和收件人元数据的人员/系统。仅使用HTTPS端点
- 为SNS主题策略添加条件键(,
aws:SourceArn)以防止混淆代理攻击aws:SourceAccount - 通过服务配额和CloudWatch告警对发送速率实施速率限制