Ask user for input from LaunchIntent

那年仲夏 提交于 2019-12-02 10:25:32

Yes, it is possible.

When the skill user open your skill, you can give a welcome message followed by a question.
Ex:

[user]  : open note skill  
[Alexa] : Welcome to note skill. What note would you like?  
----------<Alexa will wait for users input>--------  
[user]  : ABC note.  
[Alexa] : <response>

In order for Alexa to wait for users input after it says the welcome message, you need to keep the session alive. The session is kept alive based on shouldEndSession parameter in the response. For any request, if not provided, shouldEndSession defaults to true. In your case, the response to LaunchRequest should have this shouldEndSession parameter set to false. Only by which the session remains open and users can continue interaction.

Ex:

'LaunchRequest': function() {
   const speech = "Welcome to note skill. What note would you like?";
   const reprompt = "What note would you like?";
   this.emit(':ask', speech, reprompt);
}

Read this answer to know more about how you can keep the session alive using ask-nodejs-sdk.

Using Dialog Model
Another way to achieve this is to use Dialog directives. Dialog directives helps you to fill and validate slot values easily. You can use the directives to ask the user for the information you need to fulfill their request.

More information on Dialog directives here

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