I'm new to Alexa skills so I may be taking the wrong approach here for dialog management, but I am trying to determine the user's response in the following manner using conditionals within YesIntent and NoIntent handlers. I am hosting and testing all within the Alexa Developer Console. Here is a basic happy path scenario where they already said yes, they are interested in the event and I am now asking if they want to be texted the info:
const YesIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& (Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.YesIntent');
},
async handle(handlerInput) {
const sessionAttributes = handlerInput.attributesManager.getSessionAttributes();
const { askedUserIfTheyWantText, textUser } = sessionAttributes;
let speakOutput;
if (askedUserIfTheyWantText === undefined) { // I have yet to ask
speakOutput = 'Alright, want me to text you the info?';
sessionAttributes.askedUserIfTheyWantText = true;
handlerInput.attributesManager.setSessionAttributes(sessionAttributes);
} else if (askedUserIfTheyWantText) { // I already asked and they said yes
// assume I already have number, so I will now text them
const successfullyTextedUser = await textUserInfo();
if (successfullyTextedUser) speakOutput = 'Texted you the info!';
else speakOutput = 'There was a problem texting you the info.';
}
return handlerInput.responseBuilder
.speak(speakOutput)
.getResponse();
}
}
The problem is that askedUserIfTheyWantText never updates to true (remains undefined) so Alexa keeps asking "Alright, want me to text you the info?". What am I doing wrong?? As I said, I'm testing (via text) in the Alexa Developer Console.