Search code examples
javascriptsession-variablesalexa-skills-kit

Need a beginner lesson for Sessions Attribute in Alexa skill development


Can someone please guide me to a very basic beginners tutorial for Sessions attribute in Alexa skill development. I want to understand how to be able to save data across handles and sessions.

I know very basic Javascript as of now.


Solution

  • The basic tutorial Cake Time covers setting/reading session data (across handlers) and setting persistent variables (across sessions) with a persistence adapter.

    Edit

    Part 2 of the SDK guided walk-through is a bit old, but fairly beginner-friendly, still accurate (or so it seems from a quick look), and covers sessions and session attributes in more detail than Cake Time.

    Handlers handle a single exchange. Sessions cover a set of exchanges in what might be seen as a single visit. So sessions store data across handlers. Persistence stores it across sessions.

    If I come to your sit-up skill and say I did 23 sit-ups today. You might read my previous total from a persistence attribute and save the new value to a persistence attribute, because each day's use of your skill would be a session.

    On the other hand if you ask my name on launch, then do various business, then say "Bye Greg" when I leave, you'd use a session attribute to remember my name between the first interaction and that goodbye interaction.