View a markdown version of this page

开始使用 “通知” - AWS 最终用户消息 SMS

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

开始使用 “通知”

本教程将引导您创建通知配置并发送第一条 OTP 消息。你可以在大约 5 分钟内完成本教程。

先决条件

以下 IAM 策略授予发送消息和浏览模板的权限:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "sms-voice:SendNotifyTextMessage", "sms-voice:SendNotifyVoiceMessage", "sms-voice:DescribeNotifyTemplates", "sms-voice:DescribeNotifyConfigurations", "sms-voice:ListNotifyCountries", "sms-voice:PutMessageFeedback" ], "Resource": "*" } ] }

以下策略授予完全的 “通知” 管理权限:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "sms-voice:CreateNotifyConfiguration", "sms-voice:UpdateNotifyConfiguration", "sms-voice:DeleteNotifyConfiguration", "sms-voice:DescribeNotifyConfigurations", "sms-voice:DescribeNotifyTemplates", "sms-voice:ListNotifyCountries", "sms-voice:SendNotifyTextMessage", "sms-voice:SendNotifyVoiceMessage", "sms-voice:SetNotifyMessageSpendLimitOverride", "sms-voice:DeleteNotifyMessageSpendLimitOverride", "sms-voice:PutMessageFeedback" ], "Resource": "*" } ] }

要将权限限制为特定 Notify 配置,请使用配置 ARN 进行资源级操作(例如SendNotifyTextMessage、、、SendNotifyVoiceMessageDescribeNotifyConfigurationsCreateNotifyConfigurationUpdateNotifyConfiguration和)。DeleteNotifyConfiguration不支持资源级权限(例如DescribeNotifyTemplates、、ListNotifyCountriesSetNotifyMessageSpendLimitOverrideDeleteNotifyMessageSpendLimitOverride、和PutMessageFeedback)的操作需要。"Resource": "*"

步骤 1:创建通知配置

Console
  1. 打开 AWS 最终用户消息 SMS 控制台,网址为https://console.aws.amazon.com/sms-voice/

  2. 在导航窗格的通知下,选择通知配置

  3. 选择创建通知配置

  4. 显示名称中,输入您的品牌名称(例如,AcmeCorp)。

  5. 对于用例,自动选择代码验证

  6. 对于频道,选择短信语音或两者兼而有之。

  7. (可选)展开高级设置以选择国家/地区、默认模板、关联池或启用删除保护。

  8. 选择创建通知配置

当系统验证您的账户时,您的配置将以 “待处理” 状态创建。验证后,状态将更改为 “有效”,您可以开始发送消息。

注意

配置创建包括自动账户验证和品牌名称检查。大多数配置将在几秒钟内激活。如果您的品牌名称需要验证,则状态将为 “需要验证”。

AWS CLI
aws pinpoint-sms-voice-v2 create-notify-configuration \ --display-name "AcmeCorp" \ --use-case CODE_VERIFICATION \ --enabled-channels SMS

配置状态:

PENDING

正在验证配置。

ACTIVE

准备发送消息。

需要验证

品牌名称需要在激活之前进行验证。

REJECTED

配置被拒绝。查看RejectionReason详情。

第 2 步:浏览可用模板

在发送之前,请检查您的等级和频道有哪些模板可用:

aws pinpoint-sms-voice-v2 describe-notify-templates \ --filters '[{"Name":"channels","Values":["SMS"]},{"Name":"tier-access","Values":["BASIC"]}]'

步骤 3:发送测试消息

Console
  1. 在通知配置列表中,选择您的配置。

  2. 选择测试选项卡。

  3. 从 “模板” 表格中选择一个模板。

  4. 目标电话号码中,输入 E.164 格式的电话号码(例如,+12065550100)。

  5. 填写模板变量(例如,123456代码变量输入)。

  6. 选择发送

AWS CLI
aws pinpoint-sms-voice-v2 send-notify-text-message \ --notify-configuration-id "nc-1234567890abcdef0" \ --destination-phone-number "+12065550100" \ --template-id "notify-code-verification-english-001" \ --template-variables '{"code":"123456"}'
Python (boto3)
import boto3 client = boto3.client('pinpoint-sms-voice-v2') response = client.send_notify_text_message( NotifyConfigurationId='nc-1234567890abcdef0', DestinationPhoneNumber='+12065550100', TemplateId='notify-code-verification-english-001', TemplateVariables={ 'code': '123456' } ) print(f"Message ID: {response['MessageId']}") print(f"Resolved body: {response['ResolvedMessageBody']}")

第 4 步:查看可用国家

使用ListNotifyCountries查看哪些国家/地区适用于您的等级和频道:

aws pinpoint-sms-voice-v2 list-notify-countries \ --channels SMS \ --tier BASIC

后续步骤