For slots of high consequence — money, dates, values with multiple meanings, hard-to-hear words — we need to confirm the user-provided value. Making a mistake with these types of values could be costly or just annoying to users.
How does the Lambda function know when to confirm a slot? It must check the confirmation status of the desired slot(s). The function can then direct the conversation based on that information.
Here’s an example slot confirmation:
ALEXA: What genre would you like? USER: Horror! ALEXA: Horror movies are rated R. Do you still want that genre? USER: Yes.
At every turn of the conversation, the confirmation status for each slot is included in the JSON request sent to your skill. It can be accessed with:
this.event.request.intent.slots.YOUR_SLOT_NAME.confirmationStatus
When Alexa confirms a slot value, as in the example above, we expect the user to give a yes or no answer.
- If the user responds affirmatively,
confirmationStatus
for that slot will be'CONFIRMED'
- If the user responds negatively, it will be
'DENIED'
- If the user hasn’t confirmed or denied the slot yet, it will be
'NONE'
Instructions
We’ve provided one of the JSON requests from this part of a conversation:
ALEXA: I heard action. Is that correct? USER: Yup.
You can view the request on the right and you can access it with JavaScript in main.js.
Because this
is a reserved word in JavaScript, we’ve setup main.js so you can omit this, and start with event
.
Use console.log
to print the confirmationStatus for genre
.
We can use this property in conditionals as well. Write an if
-else
statement that checks the value of confirmationStatus
:
- If the status is NOT
'CONFIRMED'
, print'Slot not confirmed yet!'
- Else print
'Slot confirmed!'