Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Test the Bot Using Text Input (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.

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.

Test the Bot Using Text Input (AWS CLI)

To verify that the bot works correctly with text input, use the PostText operation. 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 Runtime Service Quotas.

Note

The following AWS CLI example is formatted for Unix, Linux, and macOS. For Windows, change "\$LATEST" to $LATEST and replace the backslash (\) continuation character at the end of each line with a caret (^).

To use text to test the bot (AWS CLI)
  1. In the AWS CLI, start a conversation with the OrderFlowersBot 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-runtime post-text \ --region region \ --bot-name OrderFlowersBot \ --bot-alias "\$LATEST" \ --user-id UserOne \ --input-text "i would like to order flowers"

    Amazon Lex recognizes the user's intent and starts a conversation by returning the following response:

    {
        "slotToElicit": "FlowerType", 
        "slots": {
            "PickupDate": null, 
            "PickupTime": null, 
            "FlowerType": null
        }, 
        "dialogState": "ElicitSlot", 
        "message": "What type of flowers would you like to order?", 
        "intentName": "OrderFlowers"
    }
  2. Run the following commands to finish the conversation with the bot.

    aws lex-runtime post-text \ --region region \ --bot-name OrderFlowersBot \ --bot-alias "\$LATEST" \ --user-id UserOne \ --input-text "roses"
    aws lex-runtime post-text \ --region region \ --bot-name OrderFlowersBot \ --bot-alias "\$LATEST" \ --user-id UserOne \ --input-text "tuesday"
    aws lex-runtime post-text \ --region region \ --bot-name OrderFlowersBot --bot-alias "\$LATEST" \ --user-id UserOne \ --input-text "10:00 a.m."
    aws lex-runtime post-text \ --region region \ --bot-name OrderFlowersBot \ --bot-alias "\$LATEST" \ --user-id UserOne \ --input-text "yes"

    After you confirm the order, Amazon Lex sends a fulfillment response to complete the conversation:

    {
        "slots": {
            "PickupDate": "2017-05-16", 
            "PickupTime": "10:00", 
            "FlowerType": "roses"
        }, 
        "dialogState": "ReadyForFulfillment", 
        "intentName": "OrderFlowers"
    }

Next Step

Test the Bot Using Speech Input (AWS CLI)

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.