Now that we have created a table in DynamoDB, all session attributes will automatically be written to the database when you call this.emit(‘:responseReady’); from within the intent handlers or when your session ends.

Saving attributes explicitly

Though, a user’s attributes are automatically saved when they end a session; sometimes, you may need to explicitly save them. For example, if a user ends the session by saying ‘quit’ or if the skill times out, you have to write code that saves the attributes.

You do that by adding the following line to the SessionEndedRequest handler.

this.emit(':saveState', true)



After the AMAZON.CancelIntent function, add a 'SessionEndedRequest' function.


Inside the function, write console.log('session ended!'); and this.emit(':saveState', true);

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?