

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

# 创建用于 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 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 账户和区域中创建机器人`AppInstanceBot`。`AppInstance`
+ 机器人必须通过基于资源的策略向 `messaging.chime.amazonaws.com` 服务主体授予调用权限。
+ 机器人可以建模欢迎意图。这允许 `AppInstanceBot` 在加入频道后显示自己及其功能。
+ 机器人应具有生产版本与别名功能才能配置 `AppInstanceBot`。
+ 机器人必须使用支持的语言和区域设置。有关语言和区域设置的更多信息，请参阅《Amazon Lex V2 开发人员指南》**中的 [Amazon Lex V2 支持的语言和区域设置](https://docs.aws.amazon.com/lexv2/latest/dg/how-languages.html)。

## 授予调用权限
<a name="invocation-perms"></a>

对于要调用 Amazon Lex V2 机器人的 `AppInstanceBot`，Amazon Chime SDK 消息传递服务主体必须有权调用 Amazon Lex 机器人资源。有关 Amazon Lex V2 基于资源的策略权限的更多信息，请参阅 Amazon Lex V2 [开发者指南中的 Amazon Le *x V* 2 Resource-based 策略示例](https://docs.aws.amazon.com/lexv2/latest/dg/security_iam_resource-based-policy-examples.html)。

以下示例介绍了基于资源的策略。

------
#### [ 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}}"
        }
      }
    }
  ]
}
```

------

**注意**  
要允许用户调用 Amazon Lex V2 机器人，请使用 AppInstanceBot的 ID。`AppInstanceBot`要允许 `AppInstance` 中的所有 `AppInstanceBots` 调用 Amazon Lex V2 机器人，请使用通配符。例如：  
`arn:aws:chime:{{region}}:{{aws-account-id}}:{{app-instance}}/{{app-instance-id}}/bot/*`