How can I keep an alexa skill open?
Asked Answered
P

4

12

I have created a skill so that people can keep track of some state. But instead of asking alexa everytime to open the app and interact.

alexa ask grocerylist to add 2 eggs
alexa ask grocerylist to add bread

I would want to keep the grocerylist skill open so that users can interact with it until they ask it to close

alexa open grocerylist
.... 2 mins later
add 2 eggs
.... 1 min later
add bread

Is there a way to do this without having to use alexa ask grocerylist every time.

Pettifogger answered 4/7, 2016 at 20:29 Comment(0)
K
15

This is not possible. It is a security feature so 3rd parties cannot create a skill to "listen in" on everything someone is saying. You can respond, and if you don't set the "endSession" flag, it will keep the session open. But it will only remain open for about 8 seconds. If you have set a reprompt, it will read them the reprompt at that point and stay open for another 8 seconds. So the maximum you can keep the line open for is 16 or so seconds.

Kreutzer answered 5/7, 2016 at 1:21 Comment(5)
This response starts by saying "not possible" but then you describe exactly how to do what I understand the asker wants. @adamp below gives the same answer.Cleavable
Most people asking this question on the forum and elsewhere want to keep the skill open continually; listening for anything the user might say later without invocation. The asker is not explicit here about their scenario, so I answered the question based on the answer that most people searching for this will look for.Kreutzer
Can I trigger repeated 8 seconds listening mode more than 2 times?Sonyasoo
You can only supply one reprompt on Alexa, so the most you can have is the initial 8 seconds, (the reprompt), and the second 8 seconds.Kreutzer
(Google Home actually let you supply more than one reprompt, FWIW)Kreutzer
V
5

Of course this is possible! (But may be capped at maximum of around 8 seconds per @Bill's comment)

In your response, when calling buildSpeechletResponse, set shouldEndSession to false in order to keep the session open and keep listening for more utterances without needing to launch the skill again using "alexa ask MyApp..."

Various demos will show how to do this. e.g. See sample code here: https://github.com/amzn/alexa-skills-kit-js/blob/master/samples/savvyConsumer/src/AlexaSkill.js

Varied answered 28/9, 2016 at 2:43 Comment(1)
This answer is misleading. Amazon Echo devices will timeout after about 8 seconds. You have no ability to extend the length of the timeout.Maemaeander
L
2

It is possible but only for a limited time.

Based on the sdk you are using you can set the flag (should end session = false). This is already done in an ask response. If you add a reprompt with that flag set then you can keep the session open until reprompt speech.

So totally intial 8 seconds until reprompt and 8 seconds again after reprompt. Total of 16 seconds.

You will have to remember the session and session variables go away after the session ends (when the blue light on alexa echo goes away). So if you want to maintain the state or the grocery list I would recommend having storage like a db. If you are using lambda to host an endpoint then it has a dynamo Db that you can use to store data.

Lyophilic answered 1/5, 2018 at 15:11 Comment(0)
L
1

The only correct answer is that it is NOT possible. OP clearly defines the duration of time in which they would like to keep the session open as minutes. This is actually impossible. Saying that it is possible but only for a limited amount of time, which is a fraction of the time OP was attempting to do, is not really helpful.

It is not possible, for security reasons that have already been mentioned.

Lichfield answered 8/5, 2019 at 15:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.