What is a session variable?
A Session Variable is a variable that is defined during a voice session. Unlike variables in the msg object, values stored in a session variable are accessible throughout an entire voice session.
A voice session is defined as one continuous interaction with Alexa. That is from the time Alexa is called until the interaction is complete. Visually, a voice session begins when the blue ring on the Echo lights up and continues until the ring is no longer illuminated.
Session variables use a special object called orbita.session
. You create your variables in this object.
The scope of the orbita.session
object is the entire voice session.
Uses of Session Variables
During a voice session, you may want to manipulate the value of a variable. It could be a counter that you initialize when you start the session. It could be a value stored in a user’s record that you need to change multiple times during the session before writing it back to the user’s record.
Manipulating Session Variables
The Orbita Function node allows you to write JavaScript code as part of your flow.
In this case, you use the Function node to manipulate a session variable.
See also
Session Variable Demo, which was included in your Orbita sandbox, demonstrates the use of session variables.