

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

# 通知入門
<a name="notify-getting-started"></a>

本教學課程會逐步引導您建立通知組態並傳送您的第一個 OTP 訊息。您可以在大約 5 分鐘內完成本教學課程。

## 先決條件
<a name="notify-getting-started-prereqs"></a>
+  AWS 帳戶。
+  AWS 最終使用者傳訊簡訊操作的 IAM 許可。如需詳細資訊，請參閱[AWS 最終使用者傳訊簡訊的身分和存取管理](security-iam.md)。

下列 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 用於資源層級動作 （例如 `SendNotifyTextMessage`、`SendNotifyVoiceMessage`、`DescribeNotifyConfigurations`、`CreateNotifyConfiguration``UpdateNotifyConfiguration`、 和 `DeleteNotifyConfiguration`)。不支援資源層級許可 （例如 `DescribeNotifyTemplates`、`ListNotifyCountries`、`DeleteNotifyMessageSpendLimitOverride`、 `SetNotifyMessageSpendLimitOverride`和 `PutMessageFeedback`) 的動作需要 `"Resource": "*"`。

## 步驟 1：建立通知組態
<a name="notify-getting-started-create"></a>

------
#### [ Console ]

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

1. 在導覽窗格的**通知**下，選擇**通知組態**。

1. 選擇**建立通知組態**。

1. 在**顯示名稱**中，輸入您的品牌名稱 （例如，`AcmeCorp`)。

1. 對於**使用案例**，會自動選取**程式碼驗證**。

1. 針對**頻道**，選取 **SMS**、**VOICE** 或兩者。

1. （選用） 展開**進階設定**以選取國家/地區、預設範本、相關聯的集區，或啟用刪除保護。

1. 選擇**建立通知組態**。

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

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

------
#### [ 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：瀏覽可用的範本
<a name="notify-getting-started-templates"></a>

傳送之前，請檢查哪些範本適用於您的層和頻道：

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

## 步驟 3：傳送測試訊息
<a name="notify-getting-started-send"></a>

------
#### [ Console ]

1. 在通知組態清單中，選擇您的組態。

1. 選擇**測試**標籤。

1. 從範本資料表中選取範本。

1. 針對**目的地電話號碼**，輸入 E.164 格式的電話號碼 （例如 `+12065550100`)。

1. 填寫範本變數 （例如，`123456`為**程式碼**變數輸入 )。

1. 選擇**傳送**。

------
#### [ 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：檢查可用的國家/地區
<a name="notify-getting-started-countries"></a>

使用 `ListNotifyCountries` 查看適用於您的方案和頻道的國家/地區：

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

## 後續步驟
<a name="notify-getting-started-next"></a>
+ [管理通知組態](notify-configurations.md) – 了解所有組態選項。
+ [使用通知範本](notify-templates.md) – 瀏覽並了解可用的範本。
+ [通知層](notify-tiers.md) – 了解 層以及如何升級至進階。
+ [通知支出限制](notify-spend-limits.md) – 管理您的通知花費限制。