Add Persistence to Your Skill (SDK v1)

Learn how to persist values during and between Alexa skills.

Start[missing "en.views.course_landing_page.learn-alexa.course_illustration" translation]
Chevron Left Icon
Session Attributes
Lesson 1 of 2
Chevron Right Icon
  1. 1

    In this lesson, we're going to build a Codecademy Flashcards skill and look at how you can program Alexa to remember details about your conversation within a session — the time between when y...

  2. 2

    Before we build the Lambda function logic for our flashcards skill, we want to build the interaction model. To do so, we’ll navigate to developer.amazon.com and use the Alexa Skill Builder. If ...

  3. 3

    Let’s take a look at how we access session attributes from a Lambda function. Session attributes are stored in the response that your skill receives from Alexa as a JSON. We can create and edit a...

  4. 4

    Like variables, session attributes hold values that we can change after we've created them. For example, if any of our session attributes are numbers, we can set their initial values and use numbe...

  5. 5

    One good use of session attributes is to capture and store user input through slots so you can use that information at a later time. This information is sent to your Lambda function as part of the ...

  6. 6

    Often, you want to combine session attribute values with another string to generate a custom speech output. Let's consider our movie genre skill. If we wanted Alexa to respond with the current ge...

  7. 7

    In the last exercise, we used interpolation to create a speech output. Though, accessing session attributes and slot values can get messy. In this exercise we'll see how variables can help us clean...

  8. 8

    Now that we’ve added all of the functionality of session attributes, let’s create our Lambda function. We’ve detailed the steps below, but if you need a refresher, check out this video on creatin...

  9. 9

    Now that we’ve completed our skill, let’s test it out. We’ve included our version of the service simulator to let you see how the requests and responses should appear. Try out the following utter...

  10. 10

    Congratulations! You now know how to persist data throughout an Alexa session. Let’s review what you learned: - We define session attributes using [...] pair syntax. - You can modify session att...

  1. 1

    Once you have session attributes that persist throughout a session, it’s helpful to save them to a database. The information that is saved within a session can be accessed in subsequent sessions....

  2. 2

    In this lesson, we’re going to use a DynamoDB database so our Alexa Skill will remember things from one session to the next. A database holds and organizes information so that it can be easily ac...

  3. 3

    In this lesson, we are going to create a flashcards skill that saves your progress, including the language you’re working on, the current card, and how many you have gotten correct. We’re going to ...

  4. 4

    Before you can save something to DynamoDB, you need to create a table. A database table is a space for storing a user's information. The Alexa NodeJS SDK makes it simple to create a database tab...

  5. 5

    Now that we have created a table in DynamoDB, all session attributes will automatically be written to the database when you call [...] from within the intent handlers or when your session end...

  6. 6

    When we save session attributes to our database table, we should always store them in a well-structured and descriptive format. Currently, our session attributes aren’t specific, and while we could...

  7. 7

    Now that we have saved the session state, let's use it to deliver a different response to a first time user versus a returning user. For returning users, the session attributes are retrieved from...

  8. 8

    Before we connect our finished Lambda function to our Interaction Model, we need to give the Lambda function specific permissions to read/write to our DynamoDB table. We can add and change permis...

  9. 9

    Now that we’ve created a script that supports session attributes, let’s create our Lambda function. The IAM work we added comes into play when you navigate to the Lambda function configuration pa...

  10. 10

    Now that we’ve completed our skill, let’s test it out. We’ve included our version of the service simulator to let you see how requests and responses should appear. Try out the following utterance...

  11. 11

    Now that we understand how to save and retrieve information in the DynamoDB database, let's take a look at how DynamoDB stores these session attributes. #### View DynamoDB Tables 1. Navigate to t...

  12. 12

    In this lesson, you learned how to use DynamoDB to give your skill "long-term memory" — so it can remember session attributes across sessions. To integrate a DynamoDB table into your Lambda ...

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo

Add Persistence to Your Skill (SDK v1)

Start[missing "en.views.course_landing_page.learn-alexa.course_illustration" translation]