list all questions on Launch

This commit is contained in:
GotPPay
2018-01-22 23:35:25 +01:00
parent af19108e9c
commit 2c6953fe97

View File

@@ -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] +
'<break time="1s"/>';
}
});
this.response
.speak (listOfPossibleQuestions)
.listen(listOfPossibleQuestions);
this.emit(':responseReady');
}
};
//Handler for launch request
handlers = {
LaunchRequest: function () {
this.response
.speak (activeSkill.invocationAnswer)
.speak (
'<break time="1s"/>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');
},
};