Create a Lex Chat Bot For TravelBuddy

Now we have TravelBuddy up and running, it is time to add a chat bot to the site to allow users to find flights using a natural interaction with a bot. In this section, we will create a simple bot with an intent to find flights to a destination. We will enhance this as we move ahead.

  1. On the AWS Console in the browser, click Services and type lex and then press enter.
  2. Click Get Started

Lex

  1. Click Custom bot
  2. For Bot name type TravelBuddyChatBot
  3. In IAM Permissions section, select Create a role with basic Amazon Lex permissions.

Lex

  1. For COPPA* select No
  2. For Session timeout type 5 and select minutes
  3. Click Next

Lex

  1. For Language select English (US)
  2. For Output Voice select Joanna. For Confidence score threshold leave the default value
  3. Click Done to create your new Lex bot

Lex

  1. Give the new intent the name TravelBuddyCheckFlightsIntent
  2. Click Save Intent

Lex

  1. For Sample utterances type I would like to fly to {destinationCity}
  2. Click Add utterances

Lex

In this utterance, we have embedded a slot parameter called destinationCity. We now need to declare this slot name in the Slots section.

  1. In the Slots section, click Add slot.
  2. For Name type destinationCity.
  3. For Slot type select AMAZON.City.
  4. For Prompt type What city would you like to fly to?. Then click Add.

Lex

We now need to define a Confirmation which will be used to confirm with the user that they want to proceed with the fulfillment of the bot, once all the slots are filled.

  1. Expand the Confirmation field and click to the Active.
  2. In Confirm prompt section, enter Are you sure you want to find flights to {destinationCity}?
  3. In Cancel, enter No problem, you can try again later
  4. Click Save intent

Lex

Test the bot in the browser

  1. At the top of the page, click Build

Lex

  1. Your bot will now be built and in a few moments, it will be ready to test.
  2. Click Test to test, enter I would like to fly into the Type a message field.
  3. The bot will respond What city would you like to fly to? , type Sydney
  4. The bot will respond Are you sure you want to find flights to Sydney?, type Yes
  5. The bot will respond by returning the details of the intent and the slot values:

Lex

  1. HTry a few other variations, for example I want to go to Sydney. If you try I want to make a flight booking you will notice that the bot doesn’t understand.

Lex

  1. The request is too different from the single utterance you have defined. You can fix that by adding additional sample utterances. Add a few additional variations to your bot in the Sample utterances section, such as:
    • I want to make a flight booking
    • I want to make a booking
    • I want to go to {destinationCity}
    • What flights are available to {destinationCity}
    • Is there a flight to {destinationCity}

… and any others you think should be added

Notice: Do not add punctuation to the sample utterances.

  1. Re-build your bot by clicking Build and once built, try testing the bot with the variations you have added as sample utterances.

Lex