询问用户来自 LaunchIntent 的输入 [英] Ask user for input from LaunchIntent

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

问题描述

我正在 Node JS 8 中编写一项技能.我有一个设置了插槽的意图,如果我说它可以正常工作

<块引用>

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

我想设计我的技能,以便用户可以直接说

<块引用>

打开{技能名称}

并且在打开它时会要求他们输入然后将被处理并传递给意图.我看到很多人说你不能这样做.但是我今天使用了 2 项技能来做到这一点.我只是在寻找正确的语法来做到这一点.

我有:

'LaunchRequest': function() {this.response.speak("你想要什么笔记?");this.emit(':responseReady');}

这看起来应该可行,但我对 JS 和 Alexa 还是很陌生.

解决方案

是的,这是可能的.

当技能使用者打开你的技能时,你可以先给一个欢迎信息,然后是一个问题.
例如:

[user] : 打开笔记技能[Alexa]:欢迎关注技巧.你想要什么笔记?----------<Alexa 将等待用户输入>--------[用户] : ABC 笔记.[Alexa]:<响应>

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

例如:

'LaunchRequest': function() {const Speech = "欢迎笔记技巧,你想要什么笔记?";const reprompt = "你想要什么笔记?";this.emit(':ask', 演讲, reprompt);}

阅读这个答案以了解更多有关如何使用 ask-nodejs-sdk 保持会话活动的信息.>

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

有关 Dialog 指令的更多信息此处

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}

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.

I have:

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

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

解决方案

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

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

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