Im writing a skill for Alexa in JS and I have a problem with creating user objects so more then 1 user could use my code at the same time. I tried doing it in this way at the beginning of my code:
class MyUser {
constructor() {
this.name= "";
this.number = 0;
this.question= "";
}
}
var myUser = new MyUser();
but it makes no sense :( How can I create a user depending on session? Every Alexa user gets session userId and I get this variable everytime user starts my skill:
event.session.user.userId
How can I dynamically use this feature? So if every user starts my script Im sure there is a new user object created and 2 or more people can use my skill parallel
Does it make sense something like this?
class MyUser {
constructor() {
this.name= "";
this.number = 0;
this.question= "";
}
}
event.session.user.userId = new MyUser();
So Im able to get into value name? Like this? console.log("event.session.user.userId.name ");
I would like to create a session user object in that place:
var newSessionHandlers = {
"NewSession": function () {
console.log(this.event.session.user.userId);
this.emit("Welcome");
}