I'm working to build an Alexa skill and have run into a roadblock on getting my slot values out of the intent object. The intent object JSON looks like so:
"intent": {
"name": "string",
"slots": {
"string": {
"name": "string",
"value": "string"
}
}
}
My question is what will that first "string" value be to identify the slots? The documentation has this:
A map of key-value pairs that further describes what the user meant based on a predefined intent schema. The map can be empty.
The key is a string that describes the name of the slot. Type: string.
The value is an object of type slot. Type: object. See Slot Object.
Does this mean the key to get the slot is the name I set in the Interaction Model? The only reason I'm hesitant to think that is because we already have a name object in the slot, which is definitely the name of the slot -- so if the way to access a specific slot was via the name, the name parameter would be redundant (you already know the name from accessing the slot.)
Does anyone know how I go about accessing individual slot values in an Alexa skill?
I'm using NodeJS for this skill by the way.
Since I had a lot of trouble with this, a more concrete answer (now) is:
'PersonIntent': function () {
var text = 'Hello ' + this.event.request.intent.slots.FirstPerson.value;
this.emit(':tell', text);
},
With this intent schema:
{
"intents": [
{
"intent": "PersonIntent",
"slots": [
{
"name": "FirstPerson",
"type": "AMAZON.DE_FIRST_NAME"
}
]
}
]
}