在写入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();
};