Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I define a custom slot type that isn't a list?

I'm playing around with the Alexa Skills Kit (for the Amazon Echo) and want to create a skill that would send the intent to an AWS Lambda function which would just email something back to me.

Sample Utterances would be something like this:

MemoIntent take a memo {myMemo} MemoIntent to take a memo {myMemo} MemoIntent send a memo {myMemo} 

This would allow me to say something like "Alexa, ask my secretary to take a memo, remind me to go to the store on my way home today" and would then get an email from my Lambda function saying, "remind me to go to the store on my way home today."

The myMemo slot is freeform - at this point just a sentence or two will do, but I'm not finding a lot of help in the documentation for how to write the schema for something like this. My best guess at the moment fails with a:

Error: There was a problem with your request: Unknown slot name '{myMemo}'. Occurred in sample 'MemoIntent take a memo {myMemo}' on line 1.

I'm using the AMAZON.LITERAL slot type, which the documentation discourages, but it also doesn't offer any suggestions on how else to go about this. And besides, like I mentioned, it fails.

Here is the schema that fails:

{     "intents": [         {             "intent": "MemoIntent",             "slots": [                 {                     "name": "myMemo",                     "type": "AMAZON.LITERAL"                 }             ]         }     ] } 
like image 301
thetaiko Avatar asked Dec 01 '15 22:12

thetaiko


People also ask

How do I make a custom Alexa slot?

To add a new custom slot typeFrom the left-hand navigation, click Add next to Slot Types. Select the Create custom slot type option. Enter a name for the slot type and click Create custom slot type. Enter each value and click the plus or press Enter.

What are slot types?

A slot type defines how the bot processes the information available in the identified slot. Make sure that you map each slot to a slot type. Slot types help the bot define the information that the bot looks for when trying to find a slot in the utterance. A slot type must include at least one value.

What are Lex slots?

A slot type is a list of values that Amazon Lex uses to train the machine learning model to recognize values for a slot. For example, you can define a slot type called " Genres. " Each value in the slot type is the name of a genre, "comedy," "adventure," "documentary," etc.

What is slot validation?

Slot validation lets you create validation rules for your slot values. Alexa can then check the user's response against these rules and prompt the user if the user provides an unacceptable value. Note: Alexa uses your slot validation rules and prompts when you delegate the dialog to Alexa. Understand slot validation.


2 Answers

Literals are different than other slot types in that you must provide training in the sample utterance, as mentioned in the official documentation: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interaction-model-reference

Sample Utterances Syntax

Sample utterances map the phrases the user can speak to the intents you have defined. They are written as lines in a plain text file, using the following format:

IntentName  this is a sample utterance with no slots IntentName  this is a sample utterance containing a {SlotName} IntentName  this is a sample utterance containing a {SlotName} and {AnotherSlotName} 

Note that the above format applies to all slot types except AMAZON.LITERAL. For AMAZON.LITERAL, you also need to specify a sample slot value:

IntentName  this is a sample utterance containing a {slot value|SlotName} using LITERAL 

Alternatively, using Custom Slots will allow you to provide the slot after defining numerous sample custom slot values. In this scenario, you would create a new custom slot called myMemo with a type of the custom slot name, such as MY_MEMO. Your custom slot value would be populated with potential values (these are not the only values it will receive), such as:

walk the dog eat more bacon go to the store on the way home 
like image 135
Justin at Amazon Avatar answered Sep 22 '22 22:09

Justin at Amazon


We are currently developing an AI (for Alexa) which should be able to answer a wide variety of questions. It is very important that users are able to phrase complex questions which shall be analyzed in the backend. If Alexa drops them early on because of limited utterances and slot types, we can't provide such a service.

At the moment we are experimenting with the following approach. (Keep in mind that our experiment is based on German. Other languages might behave differently.)

1. Custom Slot Types per Word Class

We defined custom slot types for the following word classes:

  • interrogation (what, who, when)
  • item (cybersecurity, darknet, malware)
  • verb (is, has, can)
  • adjective (popular, inexpensive, insecure)
  • pronoun (the, he, she)

2. Sample Utterances for Sentence Structure

Then we have defined possible structures for sentences with sample utterances:

QuestionIntent {Interrogation} QuestionIntent {Item} QuestionIntent {Verb} QuestionIntent {Adjective} QuestionIntent {Interrogation} {Verb} {Item} QuestionIntent {Interrogation} {Verb} {Item} {Adjective} QuestionIntent {Interrogation} {Verb} {Pronoun} {Item} QuestionIntent {Interrogation} {Verb} {Pronoun} {Pronoun} {Item} QuestionIntent {Interrogation} {Verb} {Pronoun} {Item} {Preposition} {Item} QuestionIntent {Interrogation} {Verb} {Adjective} {Item} QuestionIntent {Interrogation} {Verb} {Pronoun} {Adjective} {Item} QuestionIntent {Interrogation} {Item} {Verb} QuestionIntent {Interrogation} {Item} {Verb} {Adjective} QuestionIntent {Interrogation} {Item} {Verb} {Pronoun} {Adjective} QuestionIntent {Item} {Verb} {Interrogation} QuestionIntent {Verb} {Item} {Verb} QuestionIntent {Verb} {Adjective} {Item} {Verb} 

3. NLP Analysis in Backend

Then we do an NLP analysis of the submitted words in the backend. The received data looks like this:

"intent": {       "name": "QuestionIntent",       "slots": {         "Item": {           "name": "Item",           "value": "darknet"         },         "Preposition": {           "name": "Preposition"         },         "Adjective": {           "name": "Adjective"         },         "Verb": {           "name": "Verb",           "value": "is"         },         "Interrogation": {           "name": "Interrogation",           "value": "what"         },         "Pronoun": {           "name": "Pronoun",           "value": "the"         }       }     } 

Some words might be lost, some others might be misheard. In this case, we remember topics from earlier exchanges and "fill" the missing words with these. For example: What is {it}?What is {Darknet}?

We were experimenting with a broad list of lists for slot types. But this increases the risk of mishearing something (a good example in English is write and right, luckily they are not assigned to the same word class). So we switched to a very narrow approach. The lists only contain words which can be handled by the AI and are stored in the knowledge base. For example, the list of items does not contain the words pony or unicorn. We expect this to come up with better results (less confusing answers).

Complex sentences not defined with a utterances structure are highly confusing to work with. For example, if a sentence contains more than 2 verbs (which might be necessary to build tense). But so far our approach leads to results with a good level of accuracy as long as the user behaves with some level of politeness.

But in the end: Unfortunately, at the moment, it is not possible to dictate something like a memo with an infinite amount of different words and sentence structures.

like image 42
Marc Ruef Avatar answered Sep 19 '22 22:09

Marc Ruef