Hi How to keep session always open in alexa app.I developed custom skill for my client .After last response skill session ends.I don't want this. I want to keep session open always.so when user says the opening flows intent it should start from there.
-
1This is a very vaguely worded question. Could you elaborate some more? – Nelewout Sep 19 '16 at 09:40
-
hi am developing one custom skill in which alexa will ask question to many customers and customers will response the answer , echo takes the input and gives a output to customer based on his answer. So i want to keep session alive always I am developing application using java and hosting through aws lambda – Kamlesh Sep 19 '16 at 11:32
2 Answers
You cannot do this. Alexa's model is call and response. The user talks to Alexa, and then Alexa talks back. You can leave the session open, but if the user doesn't respond in about 8 seconds, the session is closed. (You can stretch it another 8 seconds if you use a reprompt.)
This is part of their security model. They don't want people creating skills that, basically, monitor everything going on in a room. When Alexa is listening, everything it says is streamed to the internet. Should someone break their protocol, this could be used for spying. (Or running up bandwith on the user's or Amazon's servers.)
Now, if your question is really one of continuity, that's different. Alexa provides as part of its service Session variables. Those only have a lifetime of the session. So, again, it is part of the design not to persist those past sessions.
In general, though, I do not recommend you use them. Alexa drops sessions all the time. It is far better for you to persist you own variables. Then you have control over their lifetime. Use the passed in UserID as they key, and stash them either in memory (for non-Lambda skills) and/or a DynamoDB (for Lambda skills, or longer term persistence).

- 2,118
- 17
- 15
You can achieve the desired user experience but you need to build it differently because you must assume the session might end at any time with session data being discarded.
Whenever the session is updated, persist it to a database, such as DynamoDB.
Identify each session by the userId which is sent with every request and does not change between sessions.
When a new session is created, check the database for any sessions saved against the userId. If found, populate the new session from the database. Otherwise, create a fresh session.

- 5,122
- 2
- 34
- 47