步骤 3:创建目的 (AWS CLI) - Amazon Lex V1

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

 

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

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

步骤 3:创建目的 (AWS CLI)

OrderFlowersBot 自动程序创建一个目的并提供三个槽 (参数)。这些槽允许自动程序完成以下目的:

  • FlowerType 是一个自定义槽类型,用于指定可以订购哪些类型的鲜花。

  • AMAZON.DATEAMAZON.TIME 是内置槽类型,用于获取从用户那里送花的日期和时间。

要运行本练习中的命令,您需要知道将在其中运行命令的区域。有关区域列表,请参阅 模型构建配额

创建 OrderFlowers目的 (AWS CLI)
  1. 创建名为 OrderFlowers.json 的文本文件。将 JSON 代码从 OrderFlowers.json 复制到该文本文件中。

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

    aws lex-models put-intent \ --region region \ --name OrderFlowers \ --cli-input-json file://OrderFlowers.json

    服务器响应如下:

    {
        "confirmationPrompt": {
            "maxAttempts": 2, 
            "messages": [
                {
                    "content": "Okay, your {FlowerType} will be ready for pickup by {PickupTime} on {PickupDate}.  Does this sound okay?", 
                    "contentType": "PlainText"
                }
            ]
        }, 
        "name": "OrderFlowers", 
        "checksum": "checksum", 
        "version": "$LATEST", 
        "rejectionStatement": {
            "messages": [
                {
                    "content": "Okay, I will not place your order.", 
                    "contentType": "PlainText"
                }
            ]
        }, 
        "createdDate": timestamp, 
        "lastUpdatedDate": timestamp, 
        "sampleUtterances": [
            "I would like to pick up flowers", 
            "I would like to order some flowers"
        ], 
        "slots": [
            {
                "slotType": "AMAZON.TIME", 
                "name": "PickupTime", 
                "slotConstraint": "Required", 
                "valueElicitationPrompt": {
                    "maxAttempts": 2, 
                    "messages": [
                        {
                            "content": "Pick up the {FlowerType} at what time on {PickupDate}?", 
                            "contentType": "PlainText"
                        }
                    ]
                }, 
                "priority": 3, 
                "description": "The time to pick up the flowers"
            }, 
            {
                "slotType": "FlowerTypes", 
                "name": "FlowerType", 
                "slotConstraint": "Required", 
                "valueElicitationPrompt": {
                    "maxAttempts": 2, 
                    "messages": [
                        {
                            "content": "What type of flowers would you like to order?", 
                            "contentType": "PlainText"
                        }
                    ]
                }, 
                "priority": 1, 
                "slotTypeVersion": "$LATEST", 
                "sampleUtterances": [
                    "I would like to order {FlowerType}"
                ], 
                "description": "The type of flowers to pick up"
            }, 
            {
                "slotType": "AMAZON.DATE", 
                "name": "PickupDate", 
                "slotConstraint": "Required", 
                "valueElicitationPrompt": {
                    "maxAttempts": 2, 
                    "messages": [
                        {
                            "content": "What day do you want the {FlowerType} to be picked up?", 
                            "contentType": "PlainText"
                        }
                    ]
                }, 
                "priority": 2, 
                "description": "The date to pick up the flowers"
            }
        ], 
        "fulfillmentActivity": {
            "type": "ReturnIntent"
        }, 
        "description": "Intent to order a bouquet of flowers for pick up"
    }
    

下一个步骤

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