要求用户从LaunchIntent中输入 [英] Ask user for input from LaunchIntent

查看:129
本文介绍了要求用户从LaunchIntent中输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Node JS 8编写一项技能。我有一个设置插槽的意图,如果我说

I'm writing a skill in Node JS 8. I have an intent set up with slots and it works properly if I say


向{话语}询问{技能名称}。

Ask {skill name} to {utterance}.

我想设计自己的技能,以便用户可以说

I'd like to design my skill so that the user can just say


打开{技能名称}

Open {skill Name}

打开时,它将要求他们提供输入,然后将其处理并传递给意图。我见过很多人说你不能这样做。但是我今天已经使用了2种技能来做到这一点。我只是在寻找正确的语法来做到这一点。

and on opening it will ask them for input that will then be handled and passed to the intent. I've seen multiple people say that you can't do this. But I've used 2 skills today that did exactly this. I'm just looking for the correct syntax to do this.

我有:

'LaunchRequest': function() {
   this.response.speak("What note would you like?");
   this.emit(':responseReady');
}

这似乎应该可行,但对于JS和Alexa。

Which seems like it should work, but I'm pretty new to JS and Alexa.

推荐答案

是的,有可能。

技能用户打开您的技能时,您可以在欢迎信息后提问。

例如:

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>

为了让Alexa在说出欢迎消息后等待用户输入,您需要保留会议还活着。根据响应中的 shouldEndSession 参数使会话保持活动状态。对于任何请求(如果未提供), shouldEndSession 默认为 true 。在您的情况下,对 LaunchRequest 的响应应将此 shouldEndSession 参数设置为 false 。只有会话保持打开状态,用户才能继续交互。

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);
}

阅读此答案,以了解有关如何使用ask-nodejs-sdk使会话保持活动状态的更多信息。

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

使用对话框模型

实现此目的的另一种方法是使用Dialog指令。对话框指令可帮助您轻松填充和验证插槽值。您可以使用指令向用户询问您需要满足他们的请求的信息。

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.

有关Dialog指令此处

More information on Dialog directives here

这篇关于要求用户从LaunchIntent中输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆