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

thetaiko picture thetaiko · Dec 1, 2015 · Viewed 19.7k times · Source

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"
                }
            ]
        }
    ]
}

Answer

Justin at Amazon picture Justin at Amazon · Dec 4, 2015

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