You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constattributesManager=handlerInput.attributesManager;constpersistentAttributes=awaitattributesManager.getPersistentAttributes();constuserIdTail=handlerInput.requestEnvelope.session.user.userId.substr(-6);letspeechOutput=`I've saved now as the last access time. Your user id ends with <say-as interpret-as='spell-out'>${userIdTail}</say-as>.`;if(persistentAttributes.lastAccessTime){// not the first time accessing the skill, so share the saved infoconstlastTime=parseInt(persistentAttributes.lastAccessTime,10);constthisTime=Date.now();constdifference=(thisTime-lastTime)/1000;speechOutput=`The last time you accessed this skill was ${difference} seconds ago. ${speechOutput}`;}persistentAttributes.lastAccessTime=Date.now();attributesManager.setPersistentAttributes(persistentAttributes);awaitattributesManager.savePersistentAttributes();
Skill Disabled so delete persistent data
constSkillDisabledEventHandler={canHandle(handlerInput){constrequest=handlerInput.requestEnvelope.request;returnrequest.type==="AlexaSkillEvent.SkillDisabled";},handle(handlerInput){console.log(JSON.stringify(handlerInput.requestEnvelope));constuserId=handlerInput.requestEnvelope.context.System.user.userId;console.log(`skill was disabled for user: ${userId}`);if(handlerInput.requestEnvelope.request.body.userInformationPersistenceStatus==="NOT_PERSISTED"){handlerInput.attributesManager.deletePersistentAttributes();}},};