question

morris_cinci avatar image
morris_cinci asked

Accessing custom slot type values from JS code?

I'm using JavaScript to write my skill (hosted on AWS), and I have a couple of custom slot types defined on my Interaction Model page in the Developer Console. When my intentHandler gets called I would like to be able to build a list of the strings that appear in a couple of the custom slots I defined on the Interaction Model page. Is there a way for my code to be able to "see" the list of all values in a specific slot type? The intentHandler gets called with function (intent, session, response), and I can access the value of a specific slot that the user has spoken (e.g. intent.slots.Station.value might be "WGNN"), but I need to be able to see all of the values for the Station slot type, not just the one the user spoke. If this is possible, a short JS code snippet would be very helpful. I would also like to be able to use JS code to access the list of strings in the Sample Utterances if possible. Thanks.
alexa skills kitvoice-user interface
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
This is not provided in the Alexa API. For my own skills I always include the interaction model with my run-time code. It's good practice to keep it in source control anyway. And, once it is there, I can serve it up through alternate invocations of the endpoint, which make it easy to use with EchoSim. Also, I have a dynamic reprompt function that introspects the interaction model to build example invocations to suggest to the user in the reprompt value.
10 |5000

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

morris_cinci avatar image
morris_cinci answered
Somewhere along the way I had seen a method called getSlots(), so I was hoping this functionality was built in, but thanks for clarifying this for me. Does the API support creating or updating custom slots? Right now I have several custom slots that are based on a setup configuration in my Sonos system, and the user can change those values on the Sonos side, so it would be nice if the JS code could include a "refresh configuration" feature that would re-populate the custom slots with the current valid strings from the Sonos system. It sucks that you can't tell what the slots currently hold, because that precludes any type of intelligent updating, but it would still be a big improvement if the user could update the slots without having to log into the Developer Console.
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
>Does the API support creating or updating custom slots? Nope. This is a frequent request. You can find the feature request thread and +1 it, if you like. But it really doesn't seem to make any difference. Amazon does what it want to do when it wants to do it. Be aware that defining a custom slot is not exclusive. Alexa may still chose to return a value not in your custom list in that slot. It's more of a [i]suggestion[/i]. If you have enough values on your custom list it just takes that as a general description and goes from there. So 1) You may not need to update them as much as you think. If you have enough there, Alexa will "kind of get" what you are looking for and make an attempt to match values not on the list 2) Your code is going to need to handle non-list returns. Either by erroring and asking the user to repeat, or by doing a phonetic match. (Search DoubleMetaphone in the forum for some discussion of that.)
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
> Does the API support creating or updating custom > slots? I asked David Isbitski (Chief Alexa Evangelist) about this feature yesterday. They understand that it's a problem, and he sort of implied that my request (about just updating custom slots) was aiming too low. I expect that one way or another we'll see a change to the way the intent schema is managed in the not too distant future, although I have a feeling it might be solved in a way that isn't the one we've been advocating on the forums.
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
> They understand that it's a > problem, and he sort of implied that my request > (about just updating custom slots) was aiming too > low. That seems somewhat problematic. Right now the only real quality control provided by certification is on the interaction model. Everything else can be changed outside of certification. So if they are going to open up allowing changes to the interaction model more ambitious than updating custom slot values, then there is even less of a point to certification. Let's say they let up you update custom slot values, utterances, and built-in Amazon intents. Not unreasonable on paper. But you could come up with a skill that had a bunch of zero-slot intents, a bunch of one-slot intents, a bunch of one-custom-slot intents, several two-slot intents, a couple of two-slot-custom intents, and a few more permutations. Get it certified, and then change it later to virtually any type of skill you want. Given their passion for control, that doesn't really seem to be where they want to go. So I'd kind of take his answer with a rather large grain of salt.
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
Yeah, it was weird trying to marry my experiences (which you describe) with what Dave was saying. I'd wager that there may be a disconnect between what people like he and the community-facing side of the team want, versus the approach that the certification team has taken. This would be a great topic for next week's office hours.
10 |5000

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