View a markdown version of this page

通知入門 - AWS 最終使用者傳訊簡訊

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

通知入門

本教學課程會逐步引導您建立通知組態並傳送您的第一個 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": "*" } ] }

若要限制特定通知組態的許可,請將組態 ARN 用於資源層級動作 (例如 SendNotifyTextMessageSendNotifyVoiceMessageDescribeNotifyConfigurationsCreateNotifyConfigurationUpdateNotifyConfiguration、 和 DeleteNotifyConfiguration)。不支援資源層級許可 (例如 DescribeNotifyTemplatesListNotifyCountriesDeleteNotifyMessageSpendLimitOverrideSetNotifyMessageSpendLimitOverridePutMessageFeedback) 的動作需要 "Resource": "*"

步驟 1:建立通知組態

Console
  1. 在 https://https://console.aws.amazon.com/sms-voice/ 開啟 AWS 最終使用者傳訊簡訊主控台。

  2. 在導覽窗格的通知下,選擇通知組態

  3. 選擇建立通知組態

  4. 顯示名稱中,輸入您的品牌名稱 (例如,AcmeCorp)。

  5. 對於使用案例,會自動選取程式碼驗證

  6. 針對頻道,選取 SMSVOICE 或兩者。

  7. (選用) 展開進階設定以選取國家/地區、預設範本、相關聯的集區,或啟用刪除保護。

  8. 選擇建立通知組態

當系統驗證您的帳戶時,您的組態會以定狀態建立。驗證後,狀態會變更為作用中,您可以開始傳送訊息。

注意

組態建立包括自動帳戶驗證和品牌名稱檢查。大多數組態會在幾秒鐘內啟用。如果您的品牌名稱需要驗證,則狀態為需要驗證

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

組態狀態:

待定

正在驗證組態。

ACTIVE

準備好傳送訊息。

REQUIRES_VERIFICATION

品牌名稱在啟用之前需要驗證。

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

後續步驟