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.
- On the AWS Console in the browser, click Services and type lex and then press enter.
- Click Get Started

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

- For COPPA* select No
- For Session timeout type
5
and select minutes
- Click Next

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

- Give the new intent the name TravelBuddyCheckFlightsIntent
- Click Save Intent

- For Sample utterances type
I would like to fly to {destinationCity}
- Click Add utterances

In this utterance, we have embedded a slot parameter called destinationCity. We now need to declare this slot name in the Slots section.
- In the Slots section, click Add slot.
- For Name type
destinationCity
.
- For Slot type select AMAZON.City.
- For Prompt type What city would you like to fly to?. Then click Add.

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.
- Expand the Confirmation field and click to the Active.
- In Confirm prompt section, enter
Are you sure you want to find flights to {destinationCity}?
- In Cancel, enter
No problem, you can try again later
- Click Save intent

Test the bot in the browser
- At the top of the page, click Build

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

- 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.

- 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.
- Re-build your bot by clicking Build and once built, try testing the bot with the variations you have added as sample utterances.
