AWS Lambda在完成请求之前提供“流程退出”

时间:2017-02-01 20:52:21

标签: javascript amazon-web-services aws-lambda alexa alexa-skill

我有以下代码,我正在上传到lambda,它一直给我错误:“errorMessage”:“RequestId:bdfa695d-e8b8-11e6-952a-21bb5e95cff6在完成请求之前退出流程”,即使我已经从一个完美的技能修改了这个代码。 代码只是告诉用户问候(带卡),并在用户说出问题时向他们提问。这是我的代码: `

var APP_ID=undefined;

var Alexa = require('./AlexaSkill');

var Sample = function () {
    AlexaSkill.call(this, APP_ID);
};

var handlers = {
    'LaunchRequest': function () {

        this.emit(':ask', welcomeMessage, GetReprompt());
},
'Unhandled': function () {
    this.emit(':ask', welcomeMessage, GetReprompt());
},

'AMAZON.HelpIntent': function () {
    this.emit(':ask', HelpMessage, HelpMessage);
},

'AMAZON.StopIntent': function () {
    this.shouldEndSession = true;
    this.emit(':tell', stopSkillMessage, stopSkillMessage);
},

'AMAZON.CancelIntent': function () {
    this.shouldEndSession = true;
    this.emit(':tell', stopSkillMessage, stopSkillMessage);
},

'SaySomethingIntent': function () {

    var speechOutput= "Hello";
    var repromptOutput= "Say hello";
    var cardTitle="Hello. This is the card title.";
    var overviewMessage="This is a card.";
    this.askWithCard(speechOutput, repromptOutput, howToPlayCardTitle, overviewMessage);
},

'AskIntent': function () {

    var question="Hi there, what's your name?";
    this.askWithCard(question);
}
}

exports.handler = function (event, context) {

    var sample = new Sample();
    sample.execute(event, context);
};

` 任何类型的帮助,甚至是使用aws的任何提示都将非常感激。感谢。

1 个答案:

答案 0 :(得分:4)

您的Lambda函数应回调AWS以通知Lambda已完成所有工作。

在当前版本的Lambda Nodejs运行时中,您可以将第3个参数调用到处理程序callback

http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html

在Nodejs运行时的早期版本中,或者如果您的处理程序没有使用callback参数,您应该在退出之前调用context.succeed()context.fail()

http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-using-old-runtime.html