diff --git a/backend/helpers/amazon.js b/backend/helpers/amazon.js index 9cc046f..f280ed4 100644 --- a/backend/helpers/amazon.js +++ b/backend/helpers/amazon.js @@ -64,12 +64,25 @@ var generateInteractionModel = function (skill) { let result = {}; let allIntents = []; + //Special Amazon intent + + allIntents.push ( + { + name: 'AMAZON.YesIntent', + samples: [], + }, + { + name: 'AMAZON.NoIntent', + samples: [], + } + ); + skill.intents.map (intent => { allIntents.push ({name: intent.intentName, samples: intent.questions}); }); //Special intent for sending message (Dialog) - + allIntents.push ({ name: 'SendMessageIntent', samples: [ @@ -95,9 +108,7 @@ var generateInteractionModel = function (skill) { }, ], }); - - let customSlotTypes = [ { name: 'EmailSlot', @@ -152,7 +163,7 @@ var generateInteractionModel = function (skill) { ], }, ]; - + let dialogPrompts = [ { id: 'Elicit.Intent-SendMessageIntent.IntentSlot-Name', @@ -190,7 +201,7 @@ var generateInteractionModel = function (skill) { ], }, ]; - + let dialogIntents = [ { name: 'SendMessageIntent', @@ -244,7 +255,7 @@ var generateInteractionModel = function (skill) { }; var uploadSkill = function (skill) { - let generatedInteractionModel = generateInteractionModel(skill); + let generatedInteractionModel = generateInteractionModel (skill); return fetch ( `https://api.amazonalexa.com/v0/skills/${skill.skillID}/interactionModel/locales/en-US`, { diff --git a/backend/models/alexa.js b/backend/models/alexa.js index 271b528..9723c1f 100644 --- a/backend/models/alexa.js +++ b/backend/models/alexa.js @@ -47,24 +47,31 @@ module.exports = { //Defaul Amazon handlers (some of them) handlers.NewSession = function () { - this.attributes['WantToHearQuestions'] = false; + this.attributes['WaitingQuestions'] = false; }; handlers['AMAZON.YesIntent'] = function () { console.log("yes intent"); - if (this.attributes['WantToHearQuestions']) { + if (this.attributes['WaitingQuestions']) { this.response .speak (listOfPossibleQuestions) - .listen(listOfPossibleQuestions); + .listen(constants.voiceResponseStrings.GENERIC_CONTINUE); this.emit(':responseReady'); } }; + handlers['AMAZON.NoIntent'] = function () { + console.log("No intent"); + if (this.attributes['WaitingQuestions']) { + this.attributes['WaitingQuestions'] = false; + } + }; + //Handler for launch request handlers = { LaunchRequest: function () { this.response - .speak (activeSkill.invocationAnswer) + .speak (activeSkill.invocationAnswer + ' Would you like to hear possible questions ?') .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!! this.attributes['WantToHearQuestions'] = true;