I'm learning node with Alexa skills and was wondering how you go about actually creating a new session attribute.
I've tried looking up on here and youtube walkthroughs on how to do so... and I understand how to get and modify them but I'm stuck as to actually initializing them. Any help would be appreciated. (new to node by the way sorry if this seems easy.)
here is how I made the code for getting and setting the attributes, just want to go about making them though:
const attributes = handlerInput.attributesManager.getSessionAttributes();
const response = handlerInput.responseBuilder;
attributes.state = states.QUIZ;
attributes.counter = 0;
attributes.quizScore = 0;
In general, you can check if your session is a new session using Alexa.isNewSession. If the session is new, you can go about initializing the attributes
if(Alexa.isNewSession(handlerInput.requestEnvelope)){
const sessionAtts = {};
// set your attributes here
handlerInput.attributesManager.setSessionAttributes(sessionAtts);
}