How to keep an alexa skill open?

心不动则不痛 提交于 2019-12-23 07:40:47

问题


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.


回答1:


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.




回答2:


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




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/38191837/how-to-keep-an-alexa-skill-open

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!