Step 4: Create a Bot (AWS CLI) - Amazon Lex V1

If you are using Amazon Lex V2, refer to the Amazon Lex V2 guide instead.

 

If you are using Amazon Lex V1, we recommend upgrading your bots to Amazon Lex V2. We are no longer adding new features to V1 and strongly recommend using V2 for all new bots.

Step 4: Create a Bot (AWS CLI)

The OrderFlowersBot bot has one intent, the OrderFlowers intent that you created in the previous step. To run the commands in this exercise, you need to know the region where the commands will be run. For a list of regions, see Model Building Quotas .

Note

The following AWS CLI example is formatted for Unix, Linux, and macOS. For Windows, change "\$LATEST" to $LATEST.

To create the OrderFlowersBot bot (AWS CLI)
  1. Create a text file named OrderFlowersBot.json. Copy the JSON code from OrderFlowersBot.json into the text file.

  2. In the AWS CLI, call the PutBot operation to create the bot. The example is formatted for Unix, Linux, and macOS. For Windows, replace the backslash (\) Unix continuation character at the end of each line with a caret (^).

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

    The response from the server follows. When you create or update bot, the status field is set to BUILDING. This indicates that the bot isn't ready to use. To determine when the bot is ready for use, use the GetBot operation in the next step .

    {
        "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. To determine if your new bot is ready for use, run the following command. Repeat this command until the status field returns READY. The example is formatted for Unix, Linux, and macOS. For Windows, replace the backslash (\) Unix continuation character at the end of each line with a caret (^).

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

    Look for the status field in the response:

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

Next Step

Step 5: Test a Bot (AWS CLI)