How i can save session data from one session for another session after a while?

amazon-alexa

#1

Let’s suppose that I have an “intent” in which I save a data that I ask for, but I need to keep that data valid for one hour (no more or less) to use it the next times that the skill is activated during that range of time and once that time has elapsed I no longer use it or need to renew that data.

Jovo and alexa allow me to do something like this?

i tried using this.$session.$data because i don’t wanna use this.ask, because in that case i don’t need a instant response from the user, but if i use this.tell i finish the session and i can’t use the this.$session.data


#2

There’s no built-in feature in the framework for that but you can easily implement it yourself.

You can use this.$user.$data to store data that is available after the session has ended.

// pseudo code

IntentA() {
     if (!this.$user.$data.tempStorage.expiresAt || now > this.$user.$data.tempStorage.expiresAt) {
         // renew data
         this.$user.$data.tempStorage.data = {foo:'bar'};
         this.$user.$data.tempStorage.expiresAt = now + 1h;
     }
     // use temporary data here
}

#3

Perfect, i’ll try that.
Thanks :smiley: