Getting an Alexa Slot value out of an intent
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" } ] } ]}
This is an example of an intent with your structure:
"intent": { "name": "MovieIntent", "slots": { "string": { "name": "Movie", "value": "Titanic" } }}
So, this means that the Intent you are using is named: Movie Intent (the one you set in your Interaction Model). And you will get the value this way:
var movieSlot = intent.slots.Movie.value;
As of Jul, 2019: You can access it in your intent handler as follows
if (handlerInput.requestEnvelope.request.intent.slots.SLOTNAME === undefined) { text = 'Hello! SLOTNAME not identified';} else { text = 'Hello!, SLOTNAME identified: ' + handlerInput.requestEnvelope.request.intent.slots.SLOTNAME.value;}
Replace SLOTNAME
with your slot name.It is also very important that undefined
is just as it is as an object, and not undefined