Restrict to slot values is a feature in Amazon Lex that allows you to limit the possible values a user can provide for a specific slot. By enabling this setting, you can control the range of acceptable input and ensure that the bot only processes valid responses. This is particularly useful for custom slot types where you want to provide a predefined set of options to the user.
What are slots in Amazon Lex?
Key takeaways:
They capture specific information users provide during a conversation, helping the bot fulfill requests and complete tasks.
Built-in slots handle common data like dates, cities, and numbers. Custom slots allow defining specific values relevant to your application (e.g., burger sizes in a restaurant bot).
By defining slots, you control the information the bot collects, enabling it to understand user intent and provide relevant results.
Slots in Amazon Lex are placeholders for data the bot expects to receive from the user during a conversation. They represent specific information the bot needs to collect to fulfil the user’s request or complete a task. Slots define the expected data types, such as dates, numbers, or custom entities, and help the bot understand and extract relevant information from the user’s utterances. By defining slots, we can guide the conversation flow and ensure the bot collects the necessary information to provide accurate responses or take appropriate actions.
Example
Let’s consider a scenario with a weather bot that provides users with weather forecasts for different cities. Here’s an example of an utterance and its corresponding slots:
Utterance: “What’s the weather like in New York tomorrow?"
In this utterance:
“What’s the weather like?” represents the user’s intent to inquire about the weather.
“New York” is a slot representing the city for which the user wants the weather forecast.
“Tomorrow” is another slot representing the date the user wants the weather forecast.
So, in this example, “New York” and “Tomorrow” are the slots that the weather bot needs to extract information from to fulfill the user’s request. The bot will analyze the utterance to understand the user’s intent and extract values for these slots (city and date) to provide the relevant weather forecast for New York tomorrow.
Types of slots
There are two types of slots in Amazon Lex:
Built-in slot
Custom slot
Built-in slot
This is a predefined slot type supported by Amazon Lex. Built-in slots guide us on organizing and managing data within the slot. We can create our own slots using intents. Unlike custom slots, built-in slots do not have different versions.
Example
Here are some examples of built-in slots:
Built-in slot | Description |
AMAZON.DATE | Recognizes dates mentioned in various formats (e.g., "today," "tomorrow," "January 1st, 2023") |
AMAZON.TIME | Identifies times mentioned in different formats (e.g., "3 PM," "in the evening," "at noon") |
AMAZON.NUMBER | Recognizes numerical values (e.g., "5," "twenty," "3.14") |
AMAZON.City | Recognizes city names (e.g., "New York," "London," "Paris") |
AMAZON.Country | Identifies country names (e.g., "United States," "Canada," "France") |
AMAZON.Color | Recognizes colors (e.g., "red," "blue," "green") |
AMAZON.EmailAddress | Identifies email addresses (e.g., "john.doe@example.com") |
AMAZON.PhoneNumber | Recognizes phone numbers (e.g., "+1234567890," "555-555-5555" |
Custom slot
A custom slot type in AWS Lex is a user-defined type of slot that allows you to specify a list of possible values that the slot can take. Unlike built-in slot types, which are predefined by AWS and cover common categories like dates, cities, and numbers, custom slot types let you define your own set of values for a slot. This is useful when we have specific domain-specific entities or concepts that we want our bot to recognize and extract from user input. We can create custom slot types and populate them with values relevant to our application’s context.
Example
For example, if we are creating an order-taking bot for a burger restaurant, the custom slot type “BurgerSize” is created to capture the size preference of the burger chosen by the user. In AWS Lex, when we define a custom slot type like {burgerSize}, we would need to specify the possible values for that slot type. For example, the values for {burgerSize} could be “Small,” “Medium,” and “Large.”
When the bot initiates the conversation and prompts the user with, “Welcome to Burger King! What size burger would you like to order today?” and the user responds with “Medium,” the bot will recognize that the user’s response corresponds to the {burgerSize} slot type. It will then extract the value “Medium” and proceed to process the order accordingly, understanding that the user wants a burger of medium size.
In this way, the custom slot type allows the bot to gather specific information from the user about their order, ensuring a seamless and personalized ordering experience.
Quiz
To test your understanding, you can solve the following quiz:
Quiz yourself on slots in Amazon Lex
What are slots in Amazon Lex?
Placeholders for user data
Predefined responses
Bot’s intents
User utterances
Conclusion
By defining both built-in and custom slots in Amazon Lex, we enable the bot to extract structured information from unstructured user input, which allows the bot to fulfill requests accurately and provide personalized responses.
Frequently asked questions
Haven’t found what you were looking for? Contact Us
What is restrict to slot values?
What is the purpose of Amazon Lex?
What is the tolerance of a slot?
Free Resources