Learn
DynamoDB
Saving Session Attributes to the Database

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)

Instructions

1.

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

2.

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

Folder Icon

Take this course for free

Already have an account?