I am using Node Js to write my lambda for Alexa.
I am using session variables to keep track of the counter of questions. But the counter doesn't seem to be increasong. Below given is my code. could some one please tell me what is wrong with this piece of code?
const YesIntentHandler = { canHandle(handlerInput) { const request = handlerInput.requestEnvelope.request; return request.type === 'IntentRequest' && (request.intent.name === 'AMAZON.YesIntent'); }, handle(handlerInput) { var speechText = getNextReminderQuestion(handlerInput); return handlerInput.responseBuilder .speak(speechText) .reprompt(speechText) .getResponse(); } }; function getNextReminderQuestion(handlerInput){ const attributes = handlerInput.attributesManager.getSessionAttributes(); console.log(!attributes.reminderQCount); if(!attributes.reminderQCount){// first time there is no attribute attributes.reminderQCount = 0; } else { attributes.reminderQCount = attributes.reminderQCount+1; } const question = reminders[attributes.reminderQCount]; if(attributes.reminderQCount > reminders.length){ handlerInput.attributesManager.setSessionAttributes(attributes); return finalBye; } if (attributes.reminderQCount <= reminders.length){ handlerInput.attributesManager.setSessionAttributes(attributes); return question; } }