Quick guides
Showcase AWS Lex Chatbot:
Useful information:
Creating the sample chatbot on AWS Console
Open Amazon Lex in the AWS Console
On the top-right corner of the console, confirm which region you are using. This needs to match the one you specify in the component.
Then, click the Create button (the blue one, top left corner) to create a new bot.
Upon clicking the button, the AWS console will prompt you with several sample bots or allow you to create a new one from scratch. For the purpose of this tutorial, we’ll use the BookTrip sample and we’ll call it MyBookingAssistant.
Before proceeding, we’ll need to specify the Language of our bot – English (US) for this tutorial. This is the language our bot will use to communicate and expects the user to use as well (either written or spoken).
There are a few more options that we need to account for:
But what is the confidence score? (rewrite this, it’s copy pasta)
Every time your clients types a message, the bot analyses its accuracy and pairs it with the most matching available interaction. The accuracy is shown as a number: the higher the number, the better the match. This result is called matching score. Usually, If there are three available interactions, the bot will choose the one with the highest result.
Confidence Score is a threshold that determines what the lowest matching score acceptable to trigger an interaction is. If the matching score falls below the confidence score, the bot will trigger fallback interaction, an interaction that asks the user to repeat the query.
By setting the confidence score correctly, you can provide effortless and smooth chatting experience, right for your business.
Finally, click on the create button (bottom right corner) to create the bot. Et voilà, we have our bot created!
Since our bot is based on a sample bot provided by AWS, we already have some configurations in place in terms of functionality to jumpstart our integration.
Starting with the top left corner, we have:
Let us now investigate the center part of the screen. This is where we define our intent, the information we need to gather and how our bot interacts with the user.
On the top part we have our intent name (BookHotel) and right next to it we have Latest, which is the intent version we are viewing. Just like the bot itself, our intents (and slots) also have versions. Below it there are the sample utterances. These utterances are the written (or spoken) sentences that will trigger this intent. In the example above, the user could use any of the three to start this intent.
You see the first utterance, with the {Nights} and the {Location}? These are placeholders for the slots. Slots are nothing else than just a variable that we need to gather from the user so we can correctly fulfill the intent.
Note: we are skipping “lambda initialization and validation” and “context” for now since they are not relevant for the scenario at hand. We’ll address this later.
Speaking of slots, our intent has four slots defined: Location, CheckInDate, Nights and RoomType. The Nights and the Location slots can be filled in two ways: by using the utterance – Book a 2 night stay in New York – or by answering the question when prompted. Each slot has a data type, that can be either a built-in type (Date, Number, City) or it can be a custom type, defined in the slot types.
Let us take a deeper look into the slot table:
The settings option allows you to specify additional options for the slot – as seen in the picture – but for the purpose of this tutorial, we don’t need to change anything.
Now to the last three sections of the page – Confirmation Prompt, Fulfillment and Response.
The confirmation prompt is a summary of the current state of the intent (and the respective slot values) before considering the intent fulfilled. The user needs to specify if it is correct or not. In the case the user says no, the “Cancel” message will be shown and the intent discarded.
The fulfillment is the definition of what is executed when the intent is, well, fulfilled. We have two options: invoke a Lambda function or returning the parameters to the client. Since we want to process the response in the OutSystems platform, we’ll return the parameters to the client.
Finally, the Response. The response is what happens after the intent is fulfilled. You have several options here:
Example:
Intent is fulfilled. Bot says: “Thank you for your reservation! Is there anything else I can help you with?”
User says: “No.”
Bot closes the interaction: “Thank you and have a nice day!”
Custom Slot Types
As you have seen previously, we have the ability to configure custom slot types to be used in conjunction with our slots. In this example, our RoomType slot is a custom type and is comprised of the following values – and we have an empty one, too!
So, the first thing here is the slot type name (RoomTypeValues). Right next to it is the version we are viewing – as we said previously, everything has versions! Then we have the slot resolution (more on that later) and, finally, the values. Once you add the slot to the intent, the name will be unchangeable.
The slot resolution has two options: expand values and restrict to slot values and synonyms. There is a slight difference, although the functionality is similar.
When you restrict to slot values and synonyms, you specify the value along with some synonyms that the user can type that will lead to the value. When you select the expand values option, you will just specify the value and, if the user doesn’t type a match, AWS will infer the value from the typed value using synonyms.
The final “step” in configuring our bot behavior is specifying what happens when there’s an error. The error is considered when the bot can’t parse (understand) the input from the user and has two steps:
You also have the option to specify the number of retries for clarification before closing up the interaction.
Okay, our bot is now configured! We’re ready to roll! On the top right corner you’ll have two options: build and publish.
If you build, you can test your bot on the right side of the screen. When you’re testing, you’re able to communicate with your bot and see the current state of the dialog (and which intent is being handled). Also, during interaction, you can see how the slots are being populated based on inputs.
Pro tip: When an interaction from the user occurs, a JSON response will be sent back to the integrator (your OutSystems app). That JSON response can be seen by clicking the “Detail” radio button in the Inspect Response section and will allow you to see what’s going on and what changes when the interaction occurs.
Now that we have tested our bot, it’s time to publish it. In order to publish it, just click on the blue “Publish” button and specify an alias that will represent this version:
Creating a User on IAM
Go to the AWS console and search for IAM (or Identity and Access Management). It should show the IAM service.
Click on the Add user button (the blue one) and specify the following:
Then, on the next screen (step 2), you are prompted for the permissions. Select “Attach existing policies directly” and search for Lex. You should have a result very similar – if not identical to – AmazonLexRunBotsOnly. Select this policy and keep clicking “Next” until the process finishes. You will be then shown the Access Key Id and the Secret Access Key that you need to use in the site properties.
Go to Service Center and find the AWSChatbotConnector module. Then go to the site properties of this module and define the following: