From 5e0b6e9c69d4655f09bae0befaa547ccb09bcd73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=8D=E5=93=B2?= Date: Fri, 9 Feb 2018 00:25:54 +0800 Subject: [PATCH 1/2] fix:replace local variable with this fix #32 --- lambda/custom/index.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/lambda/custom/index.js b/lambda/custom/index.js index 1413c58..bb3dae3 100644 --- a/lambda/custom/index.js +++ b/lambda/custom/index.js @@ -6,9 +6,6 @@ const states = { SEARCHMODE: '_SEARCHMODE', DESCRIPTION: '_DESKMODE', }; -// local variable holding reference to the Alexa SDK object -let alexa; - //OPTIONAL: replace with "amzn1.ask.skill.[your-unique-value-here]"; let APP_ID = undefined; @@ -97,7 +94,7 @@ const newSessionHandlers = { const startSearchHandlers = Alexa.CreateStateHandler(states.SEARCHMODE, { 'AMAZON.YesIntent': function () { output = welcomeMessage; - alexa.response.speak(output).listen(welcomeMessage); + this.response.speak(output).listen(welcomeMessage); this.emit(':responseReady'); }, @@ -180,22 +177,22 @@ const startSearchHandlers = Alexa.CreateStateHandler(states.SEARCHMODE, { } output += eventNumberMoreInfoText; - alexa.response.cardRenderer(cardTitle, cardContent); - alexa.response.speak(output).listen(haveEventsreprompt); + this.response.cardRenderer(cardTitle, cardContent); + this.response.speak(output).listen(haveEventsreprompt); } else { output = NoDataMessage; - alexa.emit(output).listen(output); + this.response.speak(output).listen(output); } } else { output = NoDataMessage; - alexa.emit(output).listen(output); + this.response.speak(output).listen(output); } } else { output = NoDataMessage; - alexa.emit(output).listen(output); + this.response.speak(output).listen(output); } - }); + }.bind(this)); } else{ this.response.speak("I'm sorry. What day did you want me to look for events?").listen("I'm sorry. What day did you want me to look for events?"); @@ -292,7 +289,7 @@ const descriptionHandlers = Alexa.CreateStateHandler(states.DESCRIPTION, { // register handlers exports.handler = function (event, context, callback) { - alexa = Alexa.handler(event, context); + const alexa = Alexa.handler(event, context); alexa.appId = APP_ID; alexa.registerHandlers(newSessionHandlers, startSearchHandlers, descriptionHandlers); alexa.execute(); From 2d691b3591dc50f94ad6bb78e5b1a2da23a92e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=8D=E5=93=B2?= Date: Fri, 9 Feb 2018 00:28:00 +0800 Subject: [PATCH 2/2] fix:emit 'responseReady' asynchronously close #45 --- lambda/custom/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lambda/custom/index.js b/lambda/custom/index.js index bb3dae3..d5106ef 100644 --- a/lambda/custom/index.js +++ b/lambda/custom/index.js @@ -192,13 +192,13 @@ const startSearchHandlers = Alexa.CreateStateHandler(states.SEARCHMODE, { output = NoDataMessage; this.response.speak(output).listen(output); } + this.emit(':responseReady'); }.bind(this)); } else{ this.response.speak("I'm sorry. What day did you want me to look for events?").listen("I'm sorry. What day did you want me to look for events?"); + this.emit(':responseReady'); } - - this.emit(':responseReady'); }, 'AMAZON.HelpIntent': function () {