When does SessionEndedRequest get invoked on the Alexa Skills Kit?
SessionEndedRequest is important to get right, especially when you want to save the current session to DynamoDB (in essence, persist the state across different sessions). However, like the LaunchRequest, you won’t define this in your intent schema. So when does it get invoked?
There are a few different ways:
- The user says “quit” or “exit” or something like that
- If Alexa is waiting for a response and the user doesn’t respond
- If Alexa is waiting for a response and the user says something that doesn’t correspond to one of your intents
- There’s an error
In all of these cases, the session will end and the
SessionEndedRequest for the current state (if you are leveraging states) will be invoked. This is the time to save the current session to DynamoDB if your skill can be used across multiple sessions:
One thing to note: if you force the session to end by setting
true by using any of the methods off of
SessionEndedRequest will not be invoked.