From 39b8e7608e17de015447deb037c1e5a521af14a6 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Tue, 23 Jan 2018 13:24:56 +0100 Subject: [PATCH 01/11] Test built-in intents --- backend/models/alexa.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/backend/models/alexa.js b/backend/models/alexa.js index 8a31a0d..49539ff 100644 --- a/backend/models/alexa.js +++ b/backend/models/alexa.js @@ -34,7 +34,7 @@ module.exports = { destinationEmail = activeSkill.contactEmail; let listOfPossibleQuestions = ''; - activeSkill.intents.forEach(intent => { + activeSkill.intents.forEach (intent => { if (intent.questions.length > 0 && intent.intentExplanation) { listOfPossibleQuestions += intent.intentExplanation + @@ -45,8 +45,6 @@ module.exports = { } }); - console.log(listOfPossibleQuestions); - //Handler for launch requestconsole.log() handlers = { LaunchRequest: function () { @@ -161,6 +159,26 @@ module.exports = { } }; + //Built-In intents + + handlers['AMAZON.CancelIntent'] = function () { + console.log ('Cancel'); + this.reponse.speak ('Thank you for using Saburly'); + this.emit (':responseReady'); + }; + + handlers['AMAZON.HelpIntent'] = function () { + console.log ('Help'); + }; + + handlers['AMAZON.NoIntent'] = function () { + console.log ('No'); + }; + + handlers['AMAZON.YesIntent'] = function () { + console.log ('Yes'); + }; + //Default handlers for unknown questions and session close handlers.Unhandled = function () { From 7a5ddc6b529bf34c35f96d5fa67581b2b367ec27 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Tue, 23 Jan 2018 13:33:53 +0100 Subject: [PATCH 02/11] Experiment with user-defined help intent --- backend/models/alexa.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/backend/models/alexa.js b/backend/models/alexa.js index 49539ff..d4703a9 100644 --- a/backend/models/alexa.js +++ b/backend/models/alexa.js @@ -171,13 +171,9 @@ module.exports = { console.log ('Help'); }; - handlers['AMAZON.NoIntent'] = function () { - console.log ('No'); - }; - - handlers['AMAZON.YesIntent'] = function () { - console.log ('Yes'); - }; + handlers.HelpIntent = function (){ + console.log('Help'); + } //Default handlers for unknown questions and session close From 3700d9bb58b1a3b6aaad12088eb782e5e90b3959 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Tue, 23 Jan 2018 13:46:02 +0100 Subject: [PATCH 03/11] Simulate built-in intents --- backend/helpers/amazon.js | 13 +++++++++++++ backend/models/alexa.js | 13 +++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/backend/helpers/amazon.js b/backend/helpers/amazon.js index fcc781e..107b0a6 100644 --- a/backend/helpers/amazon.js +++ b/backend/helpers/amazon.js @@ -68,6 +68,19 @@ var generateInteractionModel = function (skill) { allIntents.push ({name: intent.intentName, samples: intent.questions}); }); + //Special intents (Amazon built-in don't work, probably something related to existance of dialog intent + allIntents.push ({ + name: 'HelpIntent', + samples: ['Help', 'Can you help me', 'I need help'], + slots: [], + }); + + allIntents.push ({ + name: 'CancelIntent', + samples: ['Cancel', 'Stop', 'Please stop'], + slots: [], + }); + //Special intent for sending message (Dialog) allIntents.push ({ diff --git a/backend/models/alexa.js b/backend/models/alexa.js index d4703a9..d51b051 100644 --- a/backend/models/alexa.js +++ b/backend/models/alexa.js @@ -44,6 +44,7 @@ module.exports = { 'ms"/>'; } }); + listOfPossibleQuestions += 'If you dont know what to do, just say help or stop'; //Handler for launch requestconsole.log() handlers = { @@ -161,20 +162,20 @@ module.exports = { //Built-In intents - handlers['AMAZON.CancelIntent'] = function () { + handlers.CancelIntent = function () { console.log ('Cancel'); this.reponse.speak ('Thank you for using Saburly'); this.emit (':responseReady'); }; - handlers['AMAZON.HelpIntent'] = function () { + handlers.HelpIntent = function () { console.log ('Help'); + this.response + .speak (listOfPossibleQuestions) + .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!! + this.emit (':responseReady'); }; - handlers.HelpIntent = function (){ - console.log('Help'); - } - //Default handlers for unknown questions and session close handlers.Unhandled = function () { From c0a177d39b0d2eef662209ec00fd39591bdf4059 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Tue, 23 Jan 2018 14:40:01 +0100 Subject: [PATCH 04/11] experiment with yes no help cancel --- backend/helpers/amazon.js | 17 ++++++++++++++++ backend/models/alexa.js | 41 ++++++++++++++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/backend/helpers/amazon.js b/backend/helpers/amazon.js index 107b0a6..365be24 100644 --- a/backend/helpers/amazon.js +++ b/backend/helpers/amazon.js @@ -81,6 +81,23 @@ var generateInteractionModel = function (skill) { slots: [], }); + allIntents.push ({ + name: 'YesIntent', + samples: [ + 'Yes', + 'Yes please', + 'I would like that', + 'Yes I would like that', + ], + slots: [], + }); + + allIntents.push ({ + name: 'NoIntent', + samples: ['No', 'No thank you'], + slots: [], + }); + //Special intent for sending message (Dialog) allIntents.push ({ diff --git a/backend/models/alexa.js b/backend/models/alexa.js index d51b051..f227abf 100644 --- a/backend/models/alexa.js +++ b/backend/models/alexa.js @@ -55,9 +55,10 @@ module.exports = { '' + - listOfPossibleQuestions + 'Would you like to hear list of questions that you can ask me' ) .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!! + this.attributes['LaunchRequestYesNo'] = true; this.emit (':responseReady'); }, }; @@ -65,6 +66,9 @@ module.exports = { //Handlers for user defined questions activeSkill.intents.map (intent => { handlers[intent.intentName] = function () { + if (this.attributes['LaunchRequestYesNo']){ + this.attributes['LaunchRequestYesNo'] = false; + } this.response .speak (intent.answer) .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!! @@ -74,6 +78,10 @@ module.exports = { //Handler for sending message handlers.SendMessageIntent = function () { + if (this.attributes['LaunchRequestYesNo']){ + this.attributes['LaunchRequestYesNo'] = false; + } + let intent = this.event.request.intent; console.log ('Dialog state : ' + this.event.request.dialogState); @@ -163,20 +171,37 @@ module.exports = { //Built-In intents handlers.CancelIntent = function () { - console.log ('Cancel'); - this.reponse.speak ('Thank you for using Saburly'); + if (this.attributes['LaunchRequestYesNo']){ + this.attributes['LaunchRequestYesNo'] = false; + } + this.response.speak ('Thank you for using Saburly'); this.emit (':responseReady'); }; handlers.HelpIntent = function () { - console.log ('Help'); + if (this.attributes['LaunchRequestYesNo']){ + this.attributes['LaunchRequestYesNo'] = false; + } this.response .speak (listOfPossibleQuestions) .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!! this.emit (':responseReady'); }; - //Default handlers for unknown questions and session close + handlers.YesIntent = function(){ + if (this.attributes['LaunchRequestYesNo']){ + this.attributes['LaunchRequestYesNo'] = false; + this.emit('HelpIntent'); + } + } + + handlers.NoIntent = function (){ + if (this.attributes['LaunchRequestYesNo']){ + this.attributes['LaunchRequestYesNo'] = false; + } + } + + //Default handler for unknown question handlers.Unhandled = function () { this.response @@ -184,6 +209,12 @@ module.exports = { .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); }; + //Session handlers + + handlers.NewSession = function(){ + this.attributes['LaunchRequestYesNo'] = false; + } + handlers.SessionEndedRequest = function () { //We don't care for now }; From adc1f1c099c58d68ec3facd60003443c1e4c02eb Mon Sep 17 00:00:00 2001 From: GotPPay Date: Wed, 24 Jan 2018 13:02:46 +0100 Subject: [PATCH 05/11] improve default built-in intents --- backend/config/constants.js | 3 ++- backend/models/alexa.js | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/config/constants.js b/backend/config/constants.js index 7c3a7df..25a738e 100644 --- a/backend/config/constants.js +++ b/backend/config/constants.js @@ -28,7 +28,8 @@ constants.SKILL_ID_LENGTH = 24; constants.voiceResponseStrings = { QUESTION_NOT_FOUND : 'Sorry, I didnt understand', - GENERIC_CONTINUE : 'Would you like to continue' + GENERIC_CONTINUE : 'Would you like to continue', + DIDNT_ASK_ANYTHING : 'There was no question to answer to', } //Timing is given in [ms] diff --git a/backend/models/alexa.js b/backend/models/alexa.js index f227abf..68c7aac 100644 --- a/backend/models/alexa.js +++ b/backend/models/alexa.js @@ -81,7 +81,7 @@ module.exports = { if (this.attributes['LaunchRequestYesNo']){ this.attributes['LaunchRequestYesNo'] = false; } - + let intent = this.event.request.intent; console.log ('Dialog state : ' + this.event.request.dialogState); @@ -192,12 +192,19 @@ module.exports = { if (this.attributes['LaunchRequestYesNo']){ this.attributes['LaunchRequestYesNo'] = false; this.emit('HelpIntent'); + }else{ + this.response.speak(constants.voiceResponseStrings.DIDNT_ASK_ANYTHING).listen(constants.voiceResponseStrings.GENERIC_CONTINUE); + this.emit(':responseReady'); } } handlers.NoIntent = function (){ if (this.attributes['LaunchRequestYesNo']){ this.attributes['LaunchRequestYesNo'] = false; + this.response.listen(constants.voiceResponseStrings.GENERIC_CONTINUE); + }else{ + this.response.speak(constants.voiceResponseStrings.DIDNT_ASK_ANYTHING).listen(constants.voiceResponseStrings.GENERIC_CONTINUE); + this.emit(':responseReady'); } } @@ -211,10 +218,6 @@ module.exports = { //Session handlers - handlers.NewSession = function(){ - this.attributes['LaunchRequestYesNo'] = false; - } - handlers.SessionEndedRequest = function () { //We don't care for now }; From f714fdf70aac5294894a240b57eb4493bfa9e96a Mon Sep 17 00:00:00 2001 From: GotPPay Date: Wed, 24 Jan 2018 13:07:08 +0100 Subject: [PATCH 06/11] improve No intent --- backend/models/alexa.js | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/models/alexa.js b/backend/models/alexa.js index 68c7aac..f53543e 100644 --- a/backend/models/alexa.js +++ b/backend/models/alexa.js @@ -202,6 +202,7 @@ module.exports = { if (this.attributes['LaunchRequestYesNo']){ this.attributes['LaunchRequestYesNo'] = false; this.response.listen(constants.voiceResponseStrings.GENERIC_CONTINUE); + this.emit(':responseReady'); }else{ this.response.speak(constants.voiceResponseStrings.DIDNT_ASK_ANYTHING).listen(constants.voiceResponseStrings.GENERIC_CONTINUE); this.emit(':responseReady'); From 4f6c714fa319198c05e53ce1f47a082966bb5417 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Wed, 24 Jan 2018 13:11:35 +0100 Subject: [PATCH 07/11] Rephrase continuation question --- backend/config/constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/config/constants.js b/backend/config/constants.js index 25a738e..093f427 100644 --- a/backend/config/constants.js +++ b/backend/config/constants.js @@ -28,7 +28,7 @@ constants.SKILL_ID_LENGTH = 24; constants.voiceResponseStrings = { QUESTION_NOT_FOUND : 'Sorry, I didnt understand', - GENERIC_CONTINUE : 'Would you like to continue', + GENERIC_CONTINUE : 'Say something to continue', DIDNT_ASK_ANYTHING : 'There was no question to answer to', } From 145fff3b51a6ea57d41fe5d57407137fed592d94 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Wed, 24 Jan 2018 13:14:47 +0100 Subject: [PATCH 08/11] fix alexa bug with no speak action --- backend/models/alexa.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/models/alexa.js b/backend/models/alexa.js index f53543e..e791b18 100644 --- a/backend/models/alexa.js +++ b/backend/models/alexa.js @@ -201,7 +201,7 @@ module.exports = { handlers.NoIntent = function (){ if (this.attributes['LaunchRequestYesNo']){ this.attributes['LaunchRequestYesNo'] = false; - this.response.listen(constants.voiceResponseStrings.GENERIC_CONTINUE); + this.response.speak('').listen(constants.voiceResponseStrings.GENERIC_CONTINUE); this.emit(':responseReady'); }else{ this.response.speak(constants.voiceResponseStrings.DIDNT_ASK_ANYTHING).listen(constants.voiceResponseStrings.GENERIC_CONTINUE); From 5d2a15bc934ff96dc7609b5aa3415177b4a21590 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Thu, 25 Jan 2018 15:19:30 +0100 Subject: [PATCH 09/11] apply comment from PR --- backend/helpers/amazon.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/backend/helpers/amazon.js b/backend/helpers/amazon.js index 365be24..fdb8476 100644 --- a/backend/helpers/amazon.js +++ b/backend/helpers/amazon.js @@ -63,25 +63,27 @@ var refreshTokens = function () { var generateInteractionModel = function (skill) { let result = {}; let allIntents = []; + let builtInIntents = []; skill.intents.map (intent => { allIntents.push ({name: intent.intentName, samples: intent.questions}); }); - //Special intents (Amazon built-in don't work, probably something related to existance of dialog intent - allIntents.push ({ + //Built-In like intents (Amazon built-in don't work, probably something related to existance of dialog intent + + builtInIntents.push ({ name: 'HelpIntent', samples: ['Help', 'Can you help me', 'I need help'], slots: [], }); - allIntents.push ({ + builtInIntents.push ({ name: 'CancelIntent', samples: ['Cancel', 'Stop', 'Please stop'], slots: [], }); - allIntents.push ({ + builtInIntents.push ({ name: 'YesIntent', samples: [ 'Yes', @@ -92,12 +94,14 @@ var generateInteractionModel = function (skill) { slots: [], }); - allIntents.push ({ + builtInIntents.push ({ name: 'NoIntent', samples: ['No', 'No thank you'], slots: [], }); + allIntents.push(builtInIntents); + //Special intent for sending message (Dialog) allIntents.push ({ From b0737efb4ea94d1320394c9986814fd27fe7e52f Mon Sep 17 00:00:00 2001 From: GotPPay Date: Thu, 25 Jan 2018 15:39:48 +0100 Subject: [PATCH 10/11] add missing spread operator --- backend/helpers/amazon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/helpers/amazon.js b/backend/helpers/amazon.js index fdb8476..a48cbea 100644 --- a/backend/helpers/amazon.js +++ b/backend/helpers/amazon.js @@ -100,7 +100,7 @@ var generateInteractionModel = function (skill) { slots: [], }); - allIntents.push(builtInIntents); + allIntents.push(...builtInIntents); //Special intent for sending message (Dialog) From 9b58f7745b99308b66ed82dd4596c09c6380a29e Mon Sep 17 00:00:00 2001 From: GotPPay Date: Thu, 25 Jan 2018 15:56:45 +0100 Subject: [PATCH 11/11] improve code --- backend/helpers/amazon.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/backend/helpers/amazon.js b/backend/helpers/amazon.js index a48cbea..3644a76 100644 --- a/backend/helpers/amazon.js +++ b/backend/helpers/amazon.js @@ -63,7 +63,6 @@ var refreshTokens = function () { var generateInteractionModel = function (skill) { let result = {}; let allIntents = []; - let builtInIntents = []; skill.intents.map (intent => { allIntents.push ({name: intent.intentName, samples: intent.questions}); @@ -71,19 +70,17 @@ var generateInteractionModel = function (skill) { //Built-In like intents (Amazon built-in don't work, probably something related to existance of dialog intent - builtInIntents.push ({ + allIntents.push ({ name: 'HelpIntent', samples: ['Help', 'Can you help me', 'I need help'], slots: [], - }); - - builtInIntents.push ({ + }, + { name: 'CancelIntent', samples: ['Cancel', 'Stop', 'Please stop'], slots: [], - }); - - builtInIntents.push ({ + }, + { name: 'YesIntent', samples: [ 'Yes', @@ -92,16 +89,13 @@ var generateInteractionModel = function (skill) { 'Yes I would like that', ], slots: [], - }); - - builtInIntents.push ({ + }, + { name: 'NoIntent', samples: ['No', 'No thank you'], slots: [], }); - allIntents.push(...builtInIntents); - //Special intent for sending message (Dialog) allIntents.push ({