Aws lambda 除启动请求外,没有来自任何其他意图请求的响应
我是Alexa技能创造新手。我在大学里试着为我的学期计划创造一种技能,现在我正努力完成它。我终于获得了Lambda和交互模型,现在正在测试该工具的技能。我发现了两个问题。Aws lambda 除启动请求外,没有来自任何其他意图请求的响应,aws-lambda,alexa,alexa-skills-kit,alexa-skill,Aws Lambda,Alexa,Alexa Skills Kit,Alexa Skill,我是Alexa技能创造新手。我在大学里试着为我的学期计划创造一种技能,现在我正努力完成它。我终于获得了Lambda和交互模型,现在正在测试该工具的技能。我发现了两个问题。 1) 调用名称正在将未处理的响应发回给我, 2) 发射意图之外的任何意图都不会返回任何响应。Lambda代码如下所示: "use strict"; var Alexa = require("alexa-sdk"); var handlers = { "Invocation": function LaunchIntent
1) 调用名称正在将未处理的响应发回给我,
2) 发射意图之外的任何意图都不会返回任何响应。Lambda代码如下所示:
"use strict";
var Alexa = require("alexa-sdk");
var handlers = {
"Invocation": function LaunchIntent() {
this.response.speak("Hello, Welcome to Family Table. where would you like to make a reservation today?");
this.emit(':ask', ':responseReady');
context.succeed(handlers());
},
"LaunchIntent": function LaunchIntent() {
this.response.speak("Hello, Welcome to Family Table. where would you like to make a reservation today?");
this.emit(':responseReady');
context.succeed(handlers());
},
"FoodIntent": function FoodIntent() {
this.response.speak("What kind of food would you like today?");
this.emit(':responseReady');
context.succeed(handlers());
},
"cityintent": function cityintent() {
this.response.speak("Where would you like to eat?");
this.emit(':responseReady');
context.succeed(handlers());
},
"restaurantintent": function restaurantintent() {
this.response.speak("Would you like to eat at {RestaurantName}?");
this.emit(':responseReady');
context.succeed(handlers());
},
"cofirmintent": function cofirmintent() {
this.response.speak("You want to eat at {RestaurantName} correct?");
this.emit(':responseReady');
context.succeed(handlers());
},
"Amazon.FallbackIntent": function AmazonFallbackIntent() {
this.response.speak("Sorry I can't do that right now.");
this.emit(':responseReady');
context.succeed(handlers());
},
"Amazon.CancelIntent": function AmazonCancelIntent() {
this.response.speak("Cancelling");
this.emit(':responseReady');
context.succeed(handlers());
},
"Amazon.HelpIntent": function AmazonHelpIntent() {
this.response.speak("I don't know how to help you with that.");
this.emit(':responseReady');
context.succeed(handlers());
},
"Amazon.StopIntent": function AmazonStopIntent() {
this.response.speak("Alright, please come back soon.");
this.emit(':responseReady');
context.succeed(handlers());
},
"Amazon.YesIntent": function AmazonYesIntent() {
this.response.speak("Thank you for using Family Table. Your reservation has been made. Enjoy your meal.");
this.emit(':responseReady');
context.succeed(handlers());
},
'Unhandled': function () {
this.emit(':ask', 'I don\'t get it!', 'I don\'t get it!');
context.succeed(handlers());
},
};
exports.handler = function (event, context, callback) {
var alexa = Alexa.handler(event, context);
alexa.registerHandlers(handlers);
alexa.execute();
};
我错过了什么?谢谢你的帮助 你有几件事需要纠正
它是
LaunchRequest
而不是LaunchIntent
。当您调用某个技能时,将调用该处理程序李>
您不需要
context.success(handlers())代码>,您可以将其从所有意图处理程序中删除李>
应结束会话:
如果未设置此参数或将其设置为true
,Alexa将结束当前会话,您的技能将被关闭。除非再次调用,否则后续的用户语音将不会到达后端代码
好的是,您不必手动设置此参数,SDK将按如下方式处理此参数:
:询问:将通过保持会话活动状态来“询问”用户并等待响应。如果设置了重新提示,如果用户没有交互,则会在8秒后触发。
询问:将自动在响应中包含“shouldEndSession”:“false”
例:
:tell只需说出响应并结束会话。当您不希望用户做出任何响应时,请使用此选项。例如:将其用于AMAZON.StopIntent
speak()和listen():如果没有listen()
,speak()
将被视为:tell,它只告诉响应并在响应中设置“shouldEndSession”:“true”
,这将结束会话。但是如果存在一个listen()
,SDK将设置“shouldEndSession”:“false”
,作为响应,并保持会话活动
进行如下更改:
"LaunchRequest": function () {
this.response
.speak("Hello, Welcome to Family Table. where would you like to make a reservation today?")
.listen("where would you like to make a reservation today?");
this.emit(':responseReady');
}
或使用:询问
"FoodIntent": function () {
const speech = "What kind of food would you like today?";
const reprompt = "What kind of food would you like today?";
this.emit(':ask',speech,reprompt);
}
谢谢你的帮助。这些意图似乎大部分是有效的,但未处理的事件却出现了很多。有什么原因吗?谢谢。当没有特定意图请求的意图处理程序时,会出现Unhandled。请检查JSON生成的请求。
"FoodIntent": function () {
const speech = "What kind of food would you like today?";
const reprompt = "What kind of food would you like today?";
this.emit(':ask',speech,reprompt);
}