diff --git a/backend/models/alexa.js b/backend/models/alexa.js index 4074784..0ff79d8 100644 --- a/backend/models/alexa.js +++ b/backend/models/alexa.js @@ -34,14 +34,42 @@ module.exports = { handlers = {}; destinationEmail = activeSkill.contactEmail; + //Defaul Amazon handlers (some of them) + + handlers.NewSession = function () { + this.attributes['WantToHearQuestions'] = false; + }; + + handlers['AMAZON.YesIntent'] = function () { + if (this.attributes['WantToHearQuestions']) { + let listOfPossibleQuestions = ''; + activeSkill.intents.map (intent => { + if (intent.questions.length > 0) { + listOfPossibleQuestions += + intent.intentExplanation + + intent.questions[0] + + ''; + } + }); + this.response + .speak (listOfPossibleQuestions) + .listen(listOfPossibleQuestions); + this.emit(':responseReady'); + } + }; + //Handler for launch request handlers = { LaunchRequest: function () { this.response .speak (activeSkill.invocationAnswer) + .speak ( + 'Would you like to hear questions that you can ask me ?' + ) .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!! - //TODO : Maybe to ask user does he want to hear possible intents - //For this functionality, we need explanation text for each intent (Question) + + this.attributes['WantToHearQuestions'] = true; + this.emit (':responseReady'); }, };