Created
April 26, 2020 09:35
-
-
Save kinisoftware/99b58b1004c13e1348ee938cad56191d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as alexa from 'ask-sdk-core'; | |
| import {HandlerInput} from 'ask-sdk-core'; | |
| import {SessionAttributes} from '../model/sessionAttributes'; | |
| export const loadAttributesRequestInterceptor = { | |
| async process(handlerInput: HandlerInput) { | |
| const {attributesManager, requestEnvelope} = handlerInput; | |
| if (alexa.isNewSession(requestEnvelope)) { | |
| const persistentAttributes = await attributesManager.getPersistentAttributes(); | |
| let sessionAttributes: SessionAttributes; | |
| if (!('tvShows' in persistentAttributes)) { | |
| sessionAttributes = { | |
| firstTime: true, | |
| tvShows: [], | |
| }; | |
| } else { | |
| sessionAttributes = { | |
| firstTime: false, | |
| tvShows: persistentAttributes.tvShows, | |
| }; | |
| } | |
| console.log('Loading from persistent storage: ' + JSON.stringify(sessionAttributes)); | |
| attributesManager.setSessionAttributes(sessionAttributes); | |
| } | |
| }, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment