0
votes

I try to build an Alexa Skill that has an utterance with various slots. I implemented, that if a slot value is not given Alexa asks for that specific value. Everything works fine.

Now the problem is, that one of the Slots should be a Name. A User might also say 'I' instead of his name. In that case the value should again be undefined and alexa should ask for the Name. But I have no Idea how to set the value undefined in the Lambda funktion. I mean i can say: name = undefined or name = NONE but Alexa doesn't ask for it.

I guess that ASK saves the value somewhere and I can't touch that Value.

I've searched for Solutions but everything I found was about why slots are still undefined or things like that.

Thanks in advance

2
are you using Dialog Model?johndoe
Yes I am using it.tamara d

2 Answers

2
votes

Always validate slots in your backend, and whenever your name-slot is not giving you expected values, use Dialog.ElicitSlot directive to make Alexa ask for that particular slot.

Ex: If you are using ask-nodejs-sdk, then

return handlerInput.responseBuilder
   .addElicitSlotDirective(slotToElicit)
   .speak("Please provide a valid name")
   .reprompt("Please provide a valid name")
   .getResponse();

More on Dialog directives here

1
votes

If you are using dialogs then you can easily validate a slot value like i have checked that the date is in past, if it is in future alexa asks the user to tell the date again (i'm using node sdk v2)

if (dialogState !== 'COMPLETED') {
                var dateTakenSlot=handlerInput.requestEnvelope.request.intent.slots.dateTaken.value;
                if (dateTakenSlot !== null || dateTakenSlot !== undefined) {
                  var dateTaken = new Date(dateTakenSlot);
                  if (dateTaken > new Date()) {
                    resolve(handlerInput.responseBuilder
                      .speak('You can not log any future slots, On what date did you took the medicine')
                      .addElicitSlotDirective(handlerInput.requestEnvelope.request.intent.slots.dateTaken.name)
                      .getResponse());
                  }

then check your slots after dialogState is COMPLETED like

else if (dialogStatus === 'COMPLETED') {
              console.log('slots after confirmation: ', handlerInput.requestEnvelope.request.intent.slots);
            }