

终止支持通知：2025年9月15日， AWS 我们将停止对Amazon Lex V1的支持。2025 年 9 月 15 日之后，您将无法再访问 Amazon Lex V1 控制台或 Amazon Lex V1 资源。如果您使用的是 Amazon Lex V2，请改为参阅 [Amazon Lex V2 指南](https://docs.aws.amazon.com/lexv2/latest/dg/what-is.html)。

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

# 步骤 4：创建自动程序 (AWS CLI)
<a name="gs-cli-create-order-flowers-bot"></a>

`OrderFlowersBot` 自动程序有一个目的，即您在上一步中创建的 `OrderFlowers` 目的。要运行本练习中的命令，您需要知道将在其中运行命令的区域。有关区域列表，请参阅[模型构建配额](gl-limits.md#gl-limits-model-building)。

**注意**  
以下 AWS CLI 示例是针对 Unix、Linux 和 macOS 进行格式化的。对于 Windows，请将 `"\$LATEST"` 改为 `$LATEST`。

**创建 `OrderFlowersBot` 自动程序 (AWS CLI)**

1. 创建名为 **OrderFlowersBot.json** 的文本文件。将 JSON 代码从 [OrderFlowersBot.json](gs-cli-create-order-flowers-bot-json.md) 复制到该文本文件中。

1. 在中 AWS CLI，调用[PutBot](API_PutBot.md)操作来创建机器人。此示例的格式适用于 Unix、Linux 和 macOS。对于 Windows，请将每行末尾的反斜杠 (\$1) Unix 行继续符替换为脱字号 (^)。

   ```
   aws lex-models put-bot \
       --region region \
       --name OrderFlowersBot \
       --cli-input-json file://OrderFlowersBot.json
   ```

   服务器响应如下。当您创建或更新自动程序时，`status` 字段设置为 `BUILDING`。这表示自动程序尚未就绪，不能使用。要确定自动程序何时可供使用，请使用下一步中的 [GetBot](API_GetBot.md) 操作。

   

1. 要确定您的新自动程序是否已可用，请运行以下命令。重复此命令，直到 `status` 字段返回 `READY`。此示例的格式适用于 Unix、Linux 和 macOS。对于 Windows，请将每行末尾的反斜杠 (\$1) Unix 行继续符替换为脱字号 (^)。

   ```
   aws lex-models get-bot \
       --region region \
       --name OrderFlowersBot \
       --version-or-alias "\$LATEST"
   ```

   在响应中查找 `status` 字段：

   ```
   {
       "status": "READY", 
       
       ...
       
   }
   ```

## 下一个步骤
<a name="gs-create-next-5"></a>

[步骤 5：测试自动程序 (AWS CLI)](gs-create-test.md)

# OrderFlowersBot.json
<a name="gs-cli-create-order-flowers-bot-json"></a>

以下代码提供了构建 `OrderFlowers` Amazon Lex 机器人所需的 JSON 数据：

```
{
    "intents": [
        {
            "intentVersion": "$LATEST",
            "intentName": "OrderFlowers"
        }
    ],
    "name": "OrderFlowersBot",
    "locale": "en-US",
    "abortStatement": {
        "messages": [
            {
                "content": "Sorry, I'm not able to assist at this time",
                "contentType": "PlainText"
            }
        ]
    },
    "clarificationPrompt": {
        "maxAttempts": 2,
        "messages": [
            {
                "content": "I didn't understand you, what would you like to do?",
                "contentType": "PlainText"
            }
        ]
    },
    "voiceId": "Salli",
    "childDirected": false,
    "idleSessionTTLInSeconds": 600,
    "description": "Bot to order flowers on the behalf of a user"
}
```