Amazon Lex Configuration
Natural Language Model
Your Lex app performs the following functions:
- Records what questions or phrases (called "utterances") users enter into the search query
- Interprets the question or phrase ("utterance").
- Describes the meaning of the question or phrase
A model includes:
- Intents: Tasks or actions the user wants to perform.
- Enter intents into your Lex app.
- For each intent, enter examples of what a user might say/ask regarding that intent (called "utterances"). See theSearchForKnowledgeArticlesintent example below.
- Sample Utterances: Examples of user inputs that your app is designed to interpret. Each intent requires examples of user utterances.
- It may be a sentence, like "Book a ticket to Paris for me", or a fragment of a sentence, like "Booking" or "Paris flight."
- Slots: A specific word or phrase inside an utterance that you want extracted, such as names, dates, product names, or any significant group of words.
- The primary purpose of slots is to give the client application predictable extraction of data.
SearchForKnowledgeArticles Intent Example
- In the example below, the intent "SearchForKnowledgeArticles" is shown.
- Every line contains anutterance.
- Slots in each utterance are highlighted in different colors.
- Note that slots such asIssueType,OperatingSystem, andDevicesare a kind of keyword that can be recognized by your app.
AWS Settings and App Training
How to Create a Root/IAM User Account
In the following topics, you will use on of two available AWS user accounts:
- Root user:
- Account owner.
- Unrestricted access
- IAM user:
- Standard user.
- Restricted access.
- The App Key and App Secret (topics described below) are generated for each IAM user.
To create an account, go to aws.amazon.com and follow the instructions on the page.
Set User Account Security
- To set the security access for each IAM user account, from console.aws.amazon.com, navigate to IAM > Users > <user_account> > Security Credentials.
- Click the Add user button to create a new user.
- Set the user's access as desired. Repeat with other users as appropriate and necessary.
NOTE! It is recommended that you rotate user access keys.
Get Started with Amazon Lex
- To sign in and get started with the AWS Lex application, go to aws.amazon.com.
- Click the Machine Learning icon and select Amazon Lex.
- You are prompted to login.
- Enter your credentials.
- Create a new (Custom) Bot. Under Bots, click Create > Custom bot.
- Fill in the Bot fields including "Bot name."
- Click the Create button.
Configure Your AWS Lex Bot with Intents
Use the steps below to configure your AWS Lex bot.
-
See AWS Lex documentation for more information.
The "Support" drop-down menu in the top right also provides links to additional materials and training.
- To configure your bot with an intent, click the "+" icon next to Intents on the left side menu.
- In the example below, "FindDrugs" is the example intent.
- Next, configure your intent with utterances.
- Complete the remaining fields as desired.
- Click Save Intent.
- Enter as many intents as you desire.
How to Build and Publish a Lex App
After you create and setup a Lex bot application, you next build and publish it.
- Select your bot.
- Select the Editor tab.
- Use the buttons in the upper right corner of the screen to build and then publish your Lex app.
How to Get Your Bot Name and Bot Alias
For the Bot Name and Bot Alias fields:
- Go to http://console.aws.amazon.com and under Services search for Amazon Lex.
- Select an existing bot from the list or create a new one.
- Click Settings > Aliases.
- The Bot Name and Bot Alias are shown in the screenshot below:
How to Train Your Lex App
- Select the Editor tab from the top menu.
- In the left side menu create a new Intent.
- Under Sample utterances enter 5 or so examples of possible phrases, or "utterances", a user might use. Use the table below.
- In the same page, go under Slots and enter a word or phrase inside the utterance that you want extracted.
- Go back to Sample utterances and double-click the words you want extracted as Slots, then select the matching Slot.
Travel App Intents | Utterance Examples | Slots | Data |
---|---|---|---|
BookFlight |
"Buy 3 tickets to New York" "Fly me to Rio on the 24th" "I need a plane ticket next Sunday to Rio de Janeiro" |
AMAZON.NUMBER AMAZON.US_CITY |
3 New York |
CheckWeather |
"What's the weather like in Boston?" "Show me the forecast for this weekend" |
AMAZON.US_CITY | Boston |
How to Create the App Key and App Secret
For get an App Key and App Secret you must have a user account with the AamzonLexFullAccess permission.
This cannot be created by the IAM user.
- Go to https://console.aws.amazon.com.
- Select Services from the top menu then search for the IAM service.
- Then, go to Users form the left panel and select an existing user or create a new one.
- Give the user the following permissions: AmazonLexFullAccess.
- Under the Security Credentials tab, click Create Access Key.
- A dialogue appears with the App Key and the App Secret:
SmartHub LEX Settings
LEX settings are made on the "NLQ Service Configuration" page.
- Access the page by selecting NLQ Service Settings from the SmartHub Administration site at: http(s)://<hostname>:<port>/_admin.
-
The administrator needs to complete the following fields from NLQ Service Configuration page:
- Endpoint:
- The NLQ Service Endpoint.
- Authoring Endpoint
- Region
- App Key:
- The purpose of the key is authoring, publishing, managing collaborators, versioning.
- To retrieve your app secretsee "How to Create the App Key and App Secret" below.
- App Secret:
- To retrieve your app secret see "How to Create the App Key and App Secret" below.
- To retrieve your app secret see "How to Create the App Key and App Secret" below.
- Bot Name
- : How to Get Your Bot Name and Bot Alias
- : How to Get Your Bot Name and Bot Alias
- Bot Alias:
- How to Get Your Bot Name and Bot Alias
- How to Get Your Bot Name and Bot Alias
- Maximum query length:
- Maximum query size.
- Maximum query size.
- Supported Source IDs
- Minimum intent score:
- Indicates the minimum prediction accuracy for intent.
- A prediction score is between 0 and 1.
- Minimum number of words in query necessary to be NLQ:
- An integer
- An integer
- Minimum number of stop words in query necessary to be NLQ: Is an integer.
- A stop word is a commonly used word (such as “the”, “a”, “an”, “in”).
- A stop word is a commonly used word (such as “the”, “a”, “an”, “in”).
- Endpoint:
By default, only queries with at least 3 words reach LEX.
A built-in memory caches questions that are asked multiple times.
If the following settings are changed (such as lowering the value for the Minimum number of words in query necessary to be NLQ), then LEX is called more often and the quota is reached faster:
- Minimum intent score
- Minimum number of words in query necessary to be NLQ
- Minimum number of stop words in query necessary to be NLQ
You can find information on how to fill the Endpoint, Authoring Endpoint and Region fields here.
- The Endpoint field requires the following structure:
- https://runtime.lex.[your region].amazonaws.com/bot/[your bot name]/alias/[your bot alias]/user/smarthub/text
- https://runtime.lex.[your region].amazonaws.com/bot/[your bot name]/alias/[your bot alias]/user/smarthub/text
- The Authoring Endpoint field requires the following structure:
- https://models.lex.[your region].amazonaws.com