步骤 4:创建自动程序 (AWS CLI) - Amazon Lex V1

如果您使用的是 Amazon Lex V2,请改为参阅 Amazon Lex V2 指南

 

如果您使用的是 Amazon Lex V1,我们建议您将机器人升级到 Amazon Lex V2。我们不再向 V1 添加新功能,强烈建议使用 V2 以获得全新的机器人。

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

步骤 4:创建自动程序 (AWS CLI)

OrderFlowersBot 自动程序有一个目的,即您在上一步中创建的 OrderFlowers 目的。要运行本练习中的命令,您需要知道将在其中运行命令的区域。有关区域列表,请参阅 模型构建配额

注意

以下 AWS CLI 示例针对 Linux、Unix 和 macOS 编排了格式。对于 Windows,请将 "\$LATEST" 改为 $LATEST

创建 OrderFlowersBot 自动程序 (AWS CLI)
  1. 创建名为 OrderFlowersBot.json 的文本文件。将 JSON 代码从 OrderFlowersBot.json 复制到该文本文件中。

  2. 在 AWS CLI 中,调用 PutBot 操作以创建自动程序。此示例的格式适用于 Unix、Linux 和 macOS。对于 Windows,请将每行末尾的反斜杠 (\) Unix 行继续符替换为脱字号 (^)。

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

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

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

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

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

    在响应中查找 status 字段:

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

下一个步骤

步骤 5:测试自动程序 (AWS CLI)