Alexa回调错误,保持默认为未处理(Lambda)

时间:2018-10-08 09:45:05

标签: node.js amazon-web-services aws-lambda alexa unhandled

在写入Firebase之后,我的代码始终始终默认为未处理的函数。我不确定为什么,应该调用OneShotSecond函数,以便Alexa向用户提供响应。

const handlers = {
    'LaunchRequest': function () {
        this.emit(':ask', 'welcome to dog pictures');
    },
    'ShowAllDogPicturesIntent': function() {
        this.emit(':ask', 'you asked for all pictures');
    },
    'AMAZON.HelpIntent': function () {
        this.emit(':tell', 'you can ask for any dog picture');
    },
    'AMAZON.CancelIntent': function () {
        this.emit(':tell', 'bye bye, have a nice day');
    },
    'AMAZON.StopIntent': function () {
        this.emit(':tell', 'have a nice day');
    },
    'Unhandled': function () {
        this.emit(':ask', 'There was a problem here');
    },
    'oneShotSecond': function () {
        this.emit(':ask', 'We are done buddy');
    },
};

exports.handler = function (event, context, callback) {
    var request = event.request;

    if(request.type ==="IntentRequest"){

        if(request.intent.name === "ShowDogPictureIntent"){

// Get a key for a new Post.
 Firebase.database().ref('/').set({
    username: "james",
    email: "james@mail.com"
}).then((data)=>{
    Firebase.app().delete().then(oneShotSecond(this))
}).catch((err) => {
    console.log(err);
})

        }
    }


    const alexa = Alexa.handler(event, context, callback);
    alexa.APP_ID = APP_ID;
    alexa.registerHandlers(handlers);
    alexa.execute();
};

0 个答案:

没有答案