

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

# 為 Amazon Chime SDK 訊息建立 Amazon Lex V2 機器人
<a name="create-lex-bot"></a>

若要使用 AppInstance 機器人做為代理程式，您必須先建立 Amazon Lex V2 機器人來管理智慧代理程式案例的對話方塊互動。若要開始建置 Amazon Lex V2 機器人，請參閱《[Amazon Lex V2 開發人員指南》中的 Amazon Lex V2 入門](https://docs.aws.amazon.com/lexv2/latest/dg/getting-started.html)。 *Amazon Lex V2 * 如需有關將 Amazon Lex V1 機器人遷移至 Amazon Lex V2 的資訊，請參閱 [Amazon Lex V1 遷移至 V2 指南](https://docs.aws.amazon.com/lexv2/latest/dg/migration.html)。

**Topics**
+ [先決條件](#lex-prereqs)
+ [授予調用許可](#invocation-perms)
+ [建立 Amazon Chime SDK 訊息的歡迎意圖](welcome-intent.md)
+ [為 Amazon Chime SDK 訊息建立 Amazon Lex V2 機器人版本](lex-versions.md)
+ [為 Amazon Chime SDK 訊息建立 Amazon Lex V2 機器人別名](lex-aliases.md)

## 先決條件
<a name="lex-prereqs"></a>

您的 Amazon Lex V2 機器人必須具備下列先決條件。
+ 您必須在支援 Amazon Lex V2 執行時間端點的 AWS 區域中建立機器人。
+ 您必須在與 和 相同的 AWS 帳戶和區域中建立機器人`AppInstance``AppInstanceBot`。
+ 機器人必須透過以資源為基礎的政策，將調用許可授予`messaging.chime.amazonaws.com`服務委託人。
+ 機器人可以建立歡迎意圖的模型。這允許 `AppInstanceBot` 在頻道中的成員資格時宣告本身及其功能。
+ 機器人應具有生產版本和別名，才能設定 `AppInstanceBot`。
+ 機器人必須使用支援的語言和地區設定。如需語言和地區設定的詳細資訊，請參閱《[Amazon Lex V2 開發人員指南》中的 Amazon Lex V2 支援的語言和地區](https://docs.aws.amazon.com/lexv2/latest/dg/how-languages.html)設定。 *Amazon Lex V2 *

## 授予調用許可
<a name="invocation-perms"></a>

若要`AppInstanceBot`讓 叫用 Amazon Lex V2 機器人，Amazon Chime SDK 訊息服務主體必須具有叫用 Amazon Lex 機器人資源的許可。如需 Amazon Lex V2 資源型政策許可的詳細資訊，請參閱《[Amazon Lex V2 開發人員指南》中的 Amazon Lex V2 的資源型政策範例](https://docs.aws.amazon.com/lexv2/latest/dg/security_iam_resource-based-policy-examples.html)。 *Amazon Lex V2 *

下列範例顯示以資源為基礎的政策。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "messaging.chime.amazonaws.com"
      },
      "Action": [
        "lex:PutSession",
        "lex:DeleteSession",
        "lex:RecognizeText"
      ],
      "Resource": "arn:aws:lex:us-east-1:111122223333:bot-alias/lex-bot-id/lex-bot-alias-id",
      "Condition": {
        "StringEquals": {
        "AWS:SourceAccount": "111122223333"
        },
        "ArnEquals": {
        "AWS:SourceArn": "arn:aws:chime:us-east-1:111122223333:app-instance/app-instance-id/bot/app-instance-bot-id"
        }
      }
    }
  ]
}
```

------

**注意**  
若要允許一個 `AppInstanceBot` 叫用 Amazon Lex V2 機器人，請使用 AppInstanceBot 的 ID。若要允許 `AppInstanceBots`中的所有 `AppInstance`叫用 Amazon Lex V2 機器人，請使用萬用字元。例如：  
`arn:aws:chime:region:aws-account-id:app-instance/app-instance-id/bot/*`