首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >amazon技能工具包(ASK)

amazon技能工具包(ASK)
EN

Stack Overflow用户
提问于 2017-12-12 10:15:52
回答 2查看 949关注 0票数 1

在amazon中,this.emit(:ask)this.response(:speak)有什么区别:

代码语言:javascript
复制
let handler = {
    'PlayVideoIntent' : function() {

        // VideoApp.Play directives can be added to the response
        if (this.event.context.System.device.supportedInterfaces.VideoApp) {
            this.response.playVideo('http://path/to/my/video.mp4');
        } else {
            this.response.speak("The video cannot be played on your device. " +
                "To watch this video, try launching the skill from your echo show device.");
        }

        this.emit(':responseReady');
    }
}
EN

回答 2

Stack Overflow用户

发布于 2017-12-18 14:45:26

Alexa技能工具包文档有一个详细的解释。

来自响应与ResponseBuilder部分:

目前,在Node.js SDK中生成响应对象有两种方法。第一种方法是按照this.emit(:${action}, 'responseContent')格式使用语法。 如果要手动创建自己的响应,可以使用this.response帮助。this.response包含一系列函数,可以用来设置响应的不同属性。这允许您利用Alexa技能工具包的内置音频和视频播放器支持。一旦您设置了您的响应,您只需调用this.emit(':responseReady')将您的响应发送给Alexa。this.response中的函数也是可链接的,因此您可以在一行中使用任意数量的函数。 当您完成您的响应,只需调用this.emit(':responseReady')发送您的响应。下面是两个用几个响应对象构建响应的示例: Example1: this.response.speak(speechOutput) .listen(repromptSpeech); this.emit(':responseReady'); 示例2 this.response.speak(speechOutput) .cardRenderer(cardTitle, cardContent, cardImage) .renderTemplate(template) .hint(hintText, hintType); this.emit(':responseReady'); 由于responseBuilder在构建丰富的响应对象方面更加灵活,所以我们更喜欢使用这种方法来构建响应。

票数 2
EN

Stack Overflow用户

发布于 2017-12-12 12:39:10

欢迎来到StackOverflow。问题本身就有答案。

当您有一个ask时,本质上意味着会话仍然被维护,而Alexa正在期待用户的一些东西。另一方面,如果您要使用tell,这意味着没有可用的会话。下面的例子将会很有帮助。

告诉

代码语言:javascript
复制
User: Alexa, how are you doing.

Alexa: I'm doing good thank you. 

--Conversation ended

ask

代码语言:javascript
复制
User: Alexa set an alarm
Alexa: sure, at what time? <-- This is where we use ask, as the conversation is incomplete
User: at 5:30 AM
Alexa: Alarm set <-- This is where we use tell, as the task is done and there is no use of user's input anymore.

希望这能帮到你。

编码愉快!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47770088

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档