question

Kwan avatar image
Kwan asked

My favorite color is chicken -- how is this possible?

In one of the Alexa Sample Skills "Session", is there a way to limit Alexa to only respond to the list of colors stored in the custom slot, and nothing else? In the "Session" example code, it accepts any recognized words as my favorite color. Is there a way to refine the recognized result contextually. Thanks.
alexa skills kitsubmission testing certification
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jjaquinta avatar image
jjaquinta answered
Yes, this is extremely counter-intuitive. However someone dredged up something in the doc that says it does this. So it's by design. Dumb design if you ask me. But until they start giving us multiple returns with confidence indexes (if ever) it's their design and they probably won't change it.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

memo@amazon avatar image
memo@amazon answered
Hi there, The Skills Kit does not currently support 'strict' matching of slot values. The default behavior is to return the most likely intent/slot values spoken by the user, and this may include input for a given slot that is not expected by your skill. We recommend you include logic in your skills to handle slot values that are outside the custom set (and to log these values in order to allow for consideration of updating the values over time with common variants).
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jjaquinta avatar image
jjaquinta answered
Oh, one thing I should have mentioned: I found some nifty phonetic matching routines that I used to specifically deal with this case: https://forums.developer.amazon.com/forums/thread.jspa?messageID=24020巔 You might find them useful too. Now why some rather antiquated open source matching algorithms can find a match within a finite context while Amazon's cutting edge phonetics can't... is not something I can answer.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kwan avatar image
Kwan answered
I am writing a Java Alexa skill which I would like to do strict matching of the slot type. Is there an easy command that I read the list of items in the custom slot (in this case the number of colors) as an array of string. This way I can do a string compare and respond with an invalid color if necessary. I haven't seen any example where I can easily read the entire customeSlotTypes. Thanks for your help.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Galactoise avatar image
Galactoise answered
Nope. Your skill itself has no access to the custom slot declaration, nor do the custom slots guarantee a match. It's a set of guidelines, not an enumeration. That said, if you are building the skill, you're also building the custom slot list, so you can just store those same values service-side and do strict matching there.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jjaquinta avatar image
jjaquinta answered
Yes, to echo Galactoise, for all my skills I include the whole interaction model in with the source code. For many of them I access this dynamically and use it for things like auto-example generation for reprompt. Especially if you are using Java, you can just open it up as a resource and read it into memory.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

April L. Hamilton avatar image
April L. Hamilton answered
It's not reasonable to expect the skill to anticipate every possible thing the user might say in an interaction, because the user could literally say [i]anything[/i]. Alexa is not sentient, she doesn't think. She's just a piece of software that can match phonemes the user says to pre-programmed lists of words in a given skill or function. Alexa doesn't know what the word "color" means and therefore can't trap user errors based on that kind of knowledge. I'm glad it's set up this way. Imagine if you had to include every possible wrong or nonsensical word/phrase the user might say while interacting with your skill. Once you get into phrases, I'm not sure compiling the list would even be [i]possible[/i], that list seems infinite. It's much easier and briefer to list the words and phrases your skill *should* respond to, and go into an error handling loop for every other possible utterance.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

octaviom avatar image
octaviom answered
Helo @Kwan. What I´ve done so far to avoid this behavior is to set an array in my index.js file including all the slot types that I want my skill to match and if the input doesn´t match any of them, I just send a message telling the user that the word he just said is wrong or in your case it´s not a color.....
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.