There once used to be a slot type called Amazon.LITERAL
, that was allowed to be used in specific regions. However, it has now been either deprecated (or removed).
There is however another solution to this problem using custom slots.
Let's say we are creating a Food Ordering System on Alexa. A skill for something like Zomato or Yelp for Alexa. Let us give the skill the invocation name robert.
So first we make a list of the type of statements which are going to be made. You can skip this step if your skill isn't this specific. However, this just helps you define the type of statements your skill might expect to encounter.
- Alexa order robert to send me a chicken steak with mashed potatoes.
- Alexa ask robert to recommend me some good Indian restaurants near me.
- Alexa please tell robert to rate Restaurant XYZ's recent delivery with a single star.
After we have made a list of statements we store them in a csv file.
We go ahead and click on the Add button beside Slot Types.
Give your Custom Slot Type a name.
Now once you are done with this, come up with the list of constructs in which your skill can be invoked. Some of them have been given below.
- Alexa ask robert to ...
- Alexa make robert ...
- Alexa order robert to ...
- Alexa tell robert to ...
The three dots (...) represent the actual part of the order/statement. This is the text which you are interested in extracting. An example would be; for the statement,
Alexa ask Robert to send me a bucket of chicken nuggets.
you would be interested in extracting only the portion in bold.
Now Amazon classifies statements based on intent. They have five default, predefined intents for Welcome, Cancelling, Help and other basic functionalities. We go ahead and create a custom intent for dealing with the mainstream statements that will be used to primarily interact with our skill.
Under the new Custom Intent Window, at the bottom of the page is the space to add slots which will be used in your intent. We add our previously created custom slot and name it literal. (You can name it anything)
The custom slot, literal in our case, is the text we want to be extracted out of the user's statements.
Now we go ahead and replace the three dots (...) in the list of constructs with {literal}
and add it to the list of sample utterances.
For the statement
Alexa order robert to send me a chicken steak with mashed potatoes.
The JSON would contain a section like this for the custom intent and highlighting the custom slot text.
"request": {
"type": "IntentRequest",
"requestId": "",
"timestamp": "2019-01-01T19:37:17Z",
"locale": "en-IN",
"intent": {
"name": "InteractionIntent",
"confirmationStatus": "NONE",
"slots": {
"literal": {
"name": "literal",
"value": "to send me a chicken steak with mashed potatoes.",
"resolutions": {
"resolutionsPerAuthority": [
{
"authority": "",
"status": {
"code": ""
}
}
]
},
"confirmationStatus": "NONE",
"source": "USER"
}
}
}
}
Under the slots subsection under the custom intent we have our literal slot whose value gives us the text of the user's speech.
"slots": {
"literal": {
"name": "literal",
"value": "to send me a chicken steak with mashed potatoes."