+
In introduction, Alexa will help users to ask her the right questions about your business. For Example, she will say : "To ask us about our services, say : What do you do ? ". What do you do ? is defined in question field. Alexa will use first variation of question in intro.
+
+
Date: Fri, 19 Jan 2018 22:54:50 +0100
Subject: [PATCH 12/31] fix reverting skill on failed update
---
backend/config/constants.js | 2 +-
backend/controllers/skill.js | 86 +++++++++++++++++++++++++-----------
2 files changed, 61 insertions(+), 27 deletions(-)
diff --git a/backend/config/constants.js b/backend/config/constants.js
index c131195..b60f24b 100644
--- a/backend/config/constants.js
+++ b/backend/config/constants.js
@@ -17,7 +17,7 @@ constants.apiResultCodes = {
AMAZON_FAIL:2, //amazon api doesn't work
DATABASE_ERROR:3,
NO_SKILL:4,
- INCONSISTEN_STATE:5,
+ INCONSISTENT_STATE:5,
}
constants.HTTPResultCodes = {
diff --git a/backend/controllers/skill.js b/backend/controllers/skill.js
index 6cc36e7..a0c2f5f 100644
--- a/backend/controllers/skill.js
+++ b/backend/controllers/skill.js
@@ -41,6 +41,7 @@ router.put ('/:id', bodyParser.json (), async (req, res, next) => {
.then (() => {
//Ok, done, now update skill on Amazon (if needed)
if (updateOnAmazon) {
+ //We need to update skill on Amazon
amazonHelper
.updateSkill (skill)
.then (amazonResult => {
@@ -51,45 +52,78 @@ router.put ('/:id', bodyParser.json (), async (req, res, next) => {
res.json ({result: constants.apiResultCodes.OK, message: ''});
alexa.updateModel ();
} else {
- res.status(constants.HTTPResultCodes.INTERNAL_SERVER_ERROR).json ({
- result: constants.apiResultCodes.AMAZON_ERROR,
- message: amazonResult,
- });
+ //Update on amazon failed, revert changes in database and send error to user
+ databaseHelper
+ .updateSkill (id, currentSkillState)
+ .then (() => {
+ res
+ .status (
+ constants.HTTPResultCodes.INTERNAL_SERVER_ERROR
+ )
+ .json ({
+ result: constants.apiResultCodes.AMAZON_ERROR,
+ message: amazonResult,
+ });
+ })
+ .catch (() => {
+ //This should never happen, something is seriously wrong, like no database connection
+ res
+ .status (
+ constants.HTTPResultCodes.INTERNAL_SERVER_ERROR
+ )
+ .json ({
+ result: constants.apiResultCodes.INCONSISTENT_STATE,
+ message: '',
+ });
+ });
}
})
.catch (e => {
- res.status(constants.HTTPResultCodes.INTERNAL_SERVER_ERROR).json ({
- result: constants.apiResultCodes.AMAZON_FAIL,
- message: e,
- });
+ //Update on amazon failed, revert changes in database and send error to user
+ databaseHelper
+ .updateSkill (id, currentSkillState)
+ .then (() => {
+ res
+ .status (constants.HTTPResultCodes.INTERNAL_SERVER_ERROR)
+ .json ({
+ result: constants.apiResultCodes.AMAZON_FAIL,
+ message: e,
+ });
+ })
+ .catch (() => {
+ //This should never happen, something is seriously wrong, like no database connection
+ res
+ .status (constants.HTTPResultCodes.INTERNAL_SERVER_ERROR)
+ .json ({
+ result: constants.apiResultCodes.INCONSISTENT_STATE,
+ message: '',
+ });
+ });
});
- }else{
+ } else {
+ //No need to update on Amazon, tell to user it's ok
res.json ({result: constants.apiResultCodes.OK, message: ''});
alexa.updateModel ();
}
})
.catch (() => {
- //Update in database didn't go well, revert changes
- databaseHelper
- .updateSkill (id, currentSkillState)
- .then (() => {
- res.status(constants.HTTPResultCodes.INTERNAL_SERVER_ERROR).json ({
- result: constants.apiResultCodes.DATABASE_ERROR,
- message: '',
- });
- })
- .catch (() => {
- //This should never happen, something is seriously wrong, like no database connection
- res.status(constants.HTTPResultCodes.INTERNAL_SERVER_ERROR).json ({
- result: constants.apiResultCodes.INCONSISTEN_STATE,
- message: '',
- });
- });
+ //Update in database didn't go well, no need to revert since it failed to write in the first place
+ //just send error to user
+ res
+ .status (
+ constants.HTTPResultCodes.INTERNAL_SERVER_ERROR
+ )
+ .json ({
+ result: constants.apiResultCodes.DATABASE_ERROR,
+ message: '',
+ });
});
})
.catch (e => {
//I don't know why, but something went wrong, possibly ID of skill is wrong, doesn't exist in DB
- res.status(constants.HTTPResultCodes.INTERNAL_SERVER_ERROR).json ({result: constants.apiResultCodes.NO_SKILL, message: ''});
+ res
+ .status (constants.HTTPResultCodes.INTERNAL_SERVER_ERROR)
+ .json ({result: constants.apiResultCodes.NO_SKILL, message: ''});
});
});
--
2.47.3
From d8799fa40d32fb80a9d63d46dc20c0bf0338f9ea Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Fri, 19 Jan 2018 23:26:59 +0100
Subject: [PATCH 13/31] fix JSON model
---
backend/helpers/amazon.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/backend/helpers/amazon.js b/backend/helpers/amazon.js
index 6d1b553..2839f40 100644
--- a/backend/helpers/amazon.js
+++ b/backend/helpers/amazon.js
@@ -236,10 +236,12 @@ var generateInteractionModel = function (skill) {
invocationName: skill.invocationName,
types: customSlotTypes,
intents: allIntents,
- prompts: dialogPrompts,
- dialog: dialog,
};
+ result.prompts = dialogPrompts;
+ result.dialog = dialog;
+
+ console.log(JSON.stringify(result));
return JSON.stringify (result);
};
--
2.47.3
From 085a0324b3a9681e0be11e1df3a001b42ce20386 Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Mon, 22 Jan 2018 20:12:16 +0100
Subject: [PATCH 14/31] .
---
backend/helpers/amazon.js | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/backend/helpers/amazon.js b/backend/helpers/amazon.js
index 2839f40..fa414ac 100644
--- a/backend/helpers/amazon.js
+++ b/backend/helpers/amazon.js
@@ -64,12 +64,25 @@ var generateInteractionModel = function (skill) {
let result = {};
let allIntents = [];
+ allIntents.push({
+ "name": "AMAZON.CancelIntent",
+ "samples": []
+ },
+ {
+ "name": "AMAZON.HelpIntent",
+ "samples": []
+ },
+ {
+ "name": "AMAZON.StopIntent",
+ "samples": []
+ },);
+
skill.intents.map (intent => {
- allIntents.push ({name: intent.intentName, samples: intent.questions});
+ allIntents.push ({name: intent.intentName, samples: intent.questions, slots:[]});
});
//Special intent for sending message (Dialog)
-
+/*
allIntents.push ({
name: 'SendMessageIntent',
samples: [
@@ -95,7 +108,7 @@ var generateInteractionModel = function (skill) {
},
],
});
-
+*/
let customSlotTypes = [
{
name: 'EmailSlot',
@@ -230,16 +243,14 @@ var generateInteractionModel = function (skill) {
intents: dialogIntents,
};
- result.interactionModel = {};
-
- result.interactionModel.languageModel = {
+ result.languageModel = {
invocationName: skill.invocationName,
- types: customSlotTypes,
+ //types: customSlotTypes,
intents: allIntents,
};
- result.prompts = dialogPrompts;
- result.dialog = dialog;
+ //result.prompts = dialogPrompts;
+ //result.dialog = dialog;
console.log(JSON.stringify(result));
return JSON.stringify (result);
--
2.47.3
From a00859c5944127e932add03841c818c03b2b0535 Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Mon, 22 Jan 2018 22:34:13 +0100
Subject: [PATCH 15/31] fix InteractionModel generator
---
backend/controllers/skill.js | 1 +
backend/helpers/amazon.js | 43 ++++++++++++++----------------------
2 files changed, 17 insertions(+), 27 deletions(-)
diff --git a/backend/controllers/skill.js b/backend/controllers/skill.js
index a0c2f5f..921e45b 100644
--- a/backend/controllers/skill.js
+++ b/backend/controllers/skill.js
@@ -79,6 +79,7 @@ router.put ('/:id', bodyParser.json (), async (req, res, next) => {
}
})
.catch (e => {
+ console.log(e);
//Update on amazon failed, revert changes in database and send error to user
databaseHelper
.updateSkill (id, currentSkillState)
diff --git a/backend/helpers/amazon.js b/backend/helpers/amazon.js
index fa414ac..486f1ab 100644
--- a/backend/helpers/amazon.js
+++ b/backend/helpers/amazon.js
@@ -64,25 +64,12 @@ var generateInteractionModel = function (skill) {
let result = {};
let allIntents = [];
- allIntents.push({
- "name": "AMAZON.CancelIntent",
- "samples": []
- },
- {
- "name": "AMAZON.HelpIntent",
- "samples": []
- },
- {
- "name": "AMAZON.StopIntent",
- "samples": []
- },);
-
skill.intents.map (intent => {
- allIntents.push ({name: intent.intentName, samples: intent.questions, slots:[]});
+ allIntents.push ({name: intent.intentName, samples: intent.questions});
});
//Special intent for sending message (Dialog)
-/*
+
allIntents.push ({
name: 'SendMessageIntent',
samples: [
@@ -108,7 +95,9 @@ var generateInteractionModel = function (skill) {
},
],
});
-*/
+
+
+
let customSlotTypes = [
{
name: 'EmailSlot',
@@ -163,7 +152,7 @@ var generateInteractionModel = function (skill) {
],
},
];
-
+
let dialogPrompts = [
{
id: 'Elicit.Intent-SendMessageIntent.IntentSlot-Name',
@@ -201,7 +190,7 @@ var generateInteractionModel = function (skill) {
],
},
];
-
+
let dialogIntents = [
{
name: 'SendMessageIntent',
@@ -239,24 +228,24 @@ var generateInteractionModel = function (skill) {
},
];
- let dialog = {
- intents: dialogIntents,
- };
+ result.interactionModel = {};
- result.languageModel = {
+ result.interactionModel.languageModel = {
invocationName: skill.invocationName,
- //types: customSlotTypes,
+ types: customSlotTypes,
intents: allIntents,
};
- //result.prompts = dialogPrompts;
- //result.dialog = dialog;
+ result.interactionModel.prompts = dialogPrompts;
+ result.interactionModel.dialog = {};
+ result.interactionModel.dialog.intents = dialogIntents;
- console.log(JSON.stringify(result));
return JSON.stringify (result);
};
var uploadSkill = function (skill) {
+ let generatedInteractionModel = generateInteractionModel(skill);
+ console.log(generatedInteractionModel);
return fetch (
`https://api.amazonalexa.com/v0/skills/${skill.skillID}/interactionModel/locales/en-US`,
{
@@ -264,7 +253,7 @@ var uploadSkill = function (skill) {
headers: {
Authorization: config.TOKEN,
},
- body: generateInteractionModel (skill),
+ body: generatedInteractionModel,
}
);
};
--
2.47.3
From af19108e9ced5d214b649cc615e2844054d34d73 Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Mon, 22 Jan 2018 22:34:58 +0100
Subject: [PATCH 16/31] fix InteractionModel generator
---
backend/controllers/skill.js | 1 -
backend/helpers/amazon.js | 1 -
2 files changed, 2 deletions(-)
diff --git a/backend/controllers/skill.js b/backend/controllers/skill.js
index 921e45b..a0c2f5f 100644
--- a/backend/controllers/skill.js
+++ b/backend/controllers/skill.js
@@ -79,7 +79,6 @@ router.put ('/:id', bodyParser.json (), async (req, res, next) => {
}
})
.catch (e => {
- console.log(e);
//Update on amazon failed, revert changes in database and send error to user
databaseHelper
.updateSkill (id, currentSkillState)
diff --git a/backend/helpers/amazon.js b/backend/helpers/amazon.js
index 486f1ab..9cc046f 100644
--- a/backend/helpers/amazon.js
+++ b/backend/helpers/amazon.js
@@ -245,7 +245,6 @@ var generateInteractionModel = function (skill) {
var uploadSkill = function (skill) {
let generatedInteractionModel = generateInteractionModel(skill);
- console.log(generatedInteractionModel);
return fetch (
`https://api.amazonalexa.com/v0/skills/${skill.skillID}/interactionModel/locales/en-US`,
{
--
2.47.3
From 2c6953fe97721bc16086dfea7bda55c994af836b Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Mon, 22 Jan 2018 23:35:25 +0100
Subject: [PATCH 17/31] list all questions on Launch
---
backend/models/alexa.js | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
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');
},
};
--
2.47.3
From d58d4b89e3b33342b292d9fe85e3171b97e9c55c Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Tue, 23 Jan 2018 00:08:39 +0100
Subject: [PATCH 18/31] experiment with yes intent
---
backend/models/alexa.js | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/backend/models/alexa.js b/backend/models/alexa.js
index 0ff79d8..271b528 100644
--- a/backend/models/alexa.js
+++ b/backend/models/alexa.js
@@ -12,7 +12,6 @@ module.exports = {
// Build the context manually, because Amazon Lambda is missing
var context = {
succeed: function (result) {
- console.log (result);
res.json (result);
},
fail: function (error) {
@@ -34,6 +33,17 @@ module.exports = {
handlers = {};
destinationEmail = activeSkill.contactEmail;
+ let listOfPossibleQuestions = '';
+ activeSkill.intents.map (intent => {
+ if (intent.questions.length > 0) {
+ listOfPossibleQuestions +=
+ intent.intentExplanation +
+ intent.questions[0] +
+ '';
+ }
+ });
+ console.log(listOfPossibleQuestions);
+
//Defaul Amazon handlers (some of them)
handlers.NewSession = function () {
@@ -41,16 +51,8 @@ module.exports = {
};
handlers['AMAZON.YesIntent'] = function () {
+ console.log("yes intent");
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);
@@ -63,9 +65,6 @@ module.exports = {
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 !!!
this.attributes['WantToHearQuestions'] = true;
--
2.47.3
From b1a853c3631e46ecddb80b2ea6359ad17f047e0c Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Tue, 23 Jan 2018 00:20:50 +0100
Subject: [PATCH 19/31] experiment with Yes and No intents
---
backend/helpers/amazon.js | 23 +++++++++++++++++------
backend/models/alexa.js | 15 +++++++++++----
2 files changed, 28 insertions(+), 10 deletions(-)
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;
--
2.47.3
From 2ae983d211a857d9a6c5dc7d371e696389173eef Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Tue, 23 Jan 2018 00:40:19 +0100
Subject: [PATCH 20/31] Experiment with Yes and No intent
---
backend/helpers/amazon.js | 21 +++++++++++----------
backend/models/alexa.js | 6 +++---
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/backend/helpers/amazon.js b/backend/helpers/amazon.js
index f280ed4..13bf567 100644
--- a/backend/helpers/amazon.js
+++ b/backend/helpers/amazon.js
@@ -66,16 +66,17 @@ var generateInteractionModel = function (skill) {
//Special Amazon intent
- allIntents.push (
- {
- name: 'AMAZON.YesIntent',
- samples: [],
- },
- {
- name: 'AMAZON.NoIntent',
- samples: [],
- }
- );
+ allIntents.push ({
+ name: 'YesIntent',
+ samples: ['Yes', 'Yes please', 'Sure'],
+ slots: [],
+ });
+
+ allIntents.push ({
+ name: 'NoIntent',
+ samples: ['No', 'No thank you'],
+ slots: [],
+ });
skill.intents.map (intent => {
allIntents.push ({name: intent.intentName, samples: intent.questions});
diff --git a/backend/models/alexa.js b/backend/models/alexa.js
index 9723c1f..22cbdc7 100644
--- a/backend/models/alexa.js
+++ b/backend/models/alexa.js
@@ -50,7 +50,7 @@ module.exports = {
this.attributes['WaitingQuestions'] = false;
};
- handlers['AMAZON.YesIntent'] = function () {
+ handlers['YesIntent'] = function () {
console.log("yes intent");
if (this.attributes['WaitingQuestions']) {
this.response
@@ -60,7 +60,7 @@ module.exports = {
}
};
- handlers['AMAZON.NoIntent'] = function () {
+ handlers['NoIntent'] = function () {
console.log("No intent");
if (this.attributes['WaitingQuestions']) {
this.attributes['WaitingQuestions'] = false;
@@ -71,7 +71,7 @@ module.exports = {
handlers = {
LaunchRequest: function () {
this.response
- .speak (activeSkill.invocationAnswer + ' Would you like to hear possible questions ?')
+ .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;
--
2.47.3
From b2386ea0d6520796aef77c04e9dca5456333ecde Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Tue, 23 Jan 2018 01:03:59 +0100
Subject: [PATCH 21/31] Yes and No intent dont work with dialog
---
backend/helpers/amazon.js | 14 --------------
backend/models/alexa.js | 31 ++++++-------------------------
2 files changed, 6 insertions(+), 39 deletions(-)
diff --git a/backend/helpers/amazon.js b/backend/helpers/amazon.js
index 13bf567..fcc781e 100644
--- a/backend/helpers/amazon.js
+++ b/backend/helpers/amazon.js
@@ -64,20 +64,6 @@ var generateInteractionModel = function (skill) {
let result = {};
let allIntents = [];
- //Special Amazon intent
-
- allIntents.push ({
- name: 'YesIntent',
- samples: ['Yes', 'Yes please', 'Sure'],
- slots: [],
- });
-
- allIntents.push ({
- name: 'NoIntent',
- samples: ['No', 'No thank you'],
- slots: [],
- });
-
skill.intents.map (intent => {
allIntents.push ({name: intent.intentName, samples: intent.questions});
});
diff --git a/backend/models/alexa.js b/backend/models/alexa.js
index 22cbdc7..a08f6fb 100644
--- a/backend/models/alexa.js
+++ b/backend/models/alexa.js
@@ -42,40 +42,21 @@ module.exports = {
'';
}
});
- console.log(listOfPossibleQuestions);
//Defaul Amazon handlers (some of them)
- handlers.NewSession = function () {
- this.attributes['WaitingQuestions'] = false;
- };
-
- handlers['YesIntent'] = function () {
- console.log("yes intent");
- if (this.attributes['WaitingQuestions']) {
- this.response
- .speak (listOfPossibleQuestions)
- .listen(constants.voiceResponseStrings.GENERIC_CONTINUE);
- this.emit(':responseReady');
- }
- };
-
- handlers['NoIntent'] = function () {
- console.log("No intent");
- if (this.attributes['WaitingQuestions']) {
- this.attributes['WaitingQuestions'] = false;
- }
- };
+ handlers.NewSession = function () {};
//Handler for launch request
handlers = {
LaunchRequest: function () {
this.response
- .speak (activeSkill.invocationAnswer + ' Would you like to hear possible questions ?')
+ .speak (
+ activeSkill.invocationAnswer +
+ '' +
+ listOfPossibleQuestions
+ )
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
-
- this.attributes['WantToHearQuestions'] = true;
-
this.emit (':responseReady');
},
};
--
2.47.3
From 97b6755f2f9cccdcf3bdf6b4fc0320966acd8af2 Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Tue, 23 Jan 2018 01:40:19 +0100
Subject: [PATCH 22/31] No magic numbers
---
backend/config/constants.js | 6 ++++++
backend/models/alexa.js | 4 ++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/backend/config/constants.js b/backend/config/constants.js
index b60f24b..299010e 100644
--- a/backend/config/constants.js
+++ b/backend/config/constants.js
@@ -31,6 +31,12 @@ constants.voiceResponseStrings = {
GENERIC_CONTINUE : 'Would you like to continue'
}
+//Timing is given in [ms]
+constats.voiceResponseTimings = {
+ PAUSE_BETWEEN_QUESTIONS : 650,
+ PAUSE_AFTER_WELCOME_MESSAGE : 650,
+}
+
module.exports = constants;
\ No newline at end of file
diff --git a/backend/models/alexa.js b/backend/models/alexa.js
index a08f6fb..801c5f9 100644
--- a/backend/models/alexa.js
+++ b/backend/models/alexa.js
@@ -39,7 +39,7 @@ module.exports = {
listOfPossibleQuestions +=
intent.intentExplanation +
intent.questions[0] +
- '';
+ '';
}
});
@@ -53,7 +53,7 @@ module.exports = {
this.response
.speak (
activeSkill.invocationAnswer +
- '' +
+ '' +
listOfPossibleQuestions
)
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
--
2.47.3
From c6cd49a66f6281339f05d77490f071174f725f6c Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Tue, 23 Jan 2018 01:41:34 +0100
Subject: [PATCH 23/31] fix typo
---
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 299010e..7c3a7df 100644
--- a/backend/config/constants.js
+++ b/backend/config/constants.js
@@ -32,7 +32,7 @@ constants.voiceResponseStrings = {
}
//Timing is given in [ms]
-constats.voiceResponseTimings = {
+constants.voiceResponseTimings = {
PAUSE_BETWEEN_QUESTIONS : 650,
PAUSE_AFTER_WELCOME_MESSAGE : 650,
}
--
2.47.3
From 0d858ad1c7431349bec469cb5990a169bd21c10e Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Tue, 23 Jan 2018 01:46:02 +0100
Subject: [PATCH 24/31] List only questions with explanation
---
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 801c5f9..3301a8e 100644
--- a/backend/models/alexa.js
+++ b/backend/models/alexa.js
@@ -35,7 +35,7 @@ module.exports = {
let listOfPossibleQuestions = '';
activeSkill.intents.map (intent => {
- if (intent.questions.length > 0) {
+ if (intent.questions.length > 0 && intent.intentExplanation) {
listOfPossibleQuestions +=
intent.intentExplanation +
intent.questions[0] +
--
2.47.3
From 370edd6ef0c4f9a107241a34350e7e027944957a Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Tue, 23 Jan 2018 01:51:36 +0100
Subject: [PATCH 25/31] fix inherited explanation bug
---
web/src/App.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/web/src/App.js b/web/src/App.js
index 9f46a99..a91c5f6 100644
--- a/web/src/App.js
+++ b/web/src/App.js
@@ -255,7 +255,7 @@ class App extends Component {
allIntents: this.state.allIntents,
selectedIndex: NEW_INTENT_SELECTED_INDEX,
launchRequest: false,
- selectedIntent: {intentName: '', questions: [''], answer: ''},
+ selectedIntent: {intentName: '', questions: [''], answer: '', intentExplanation:''},
});
}
--
2.47.3
From 3202bf5f0ba2981cf22c9d8cbcb35513416b0091 Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Tue, 23 Jan 2018 01:56:07 +0100
Subject: [PATCH 26/31] Implement help intent
---
backend/models/alexa.js | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/backend/models/alexa.js b/backend/models/alexa.js
index 3301a8e..87d1b95 100644
--- a/backend/models/alexa.js
+++ b/backend/models/alexa.js
@@ -39,7 +39,9 @@ module.exports = {
listOfPossibleQuestions +=
intent.intentExplanation +
intent.questions[0] +
- '';
+ '';
}
});
@@ -47,13 +49,22 @@ module.exports = {
handlers.NewSession = function () {};
+ handlers['AMAZON.HelpIntent'] = function () {
+ console.log ('Help intent');
+ this.response
+ .speak (listOfPossibleQuestions)
+ .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
+ };
+
//Handler for launch request
handlers = {
LaunchRequest: function () {
this.response
.speak (
activeSkill.invocationAnswer +
- '' +
+ '' +
listOfPossibleQuestions
)
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
--
2.47.3
From 6b26db3d18b6ea6d376157f11db30abd61f4266b Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Tue, 23 Jan 2018 02:15:44 +0100
Subject: [PATCH 27/31] fix code
---
backend/models/alexa.js | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/backend/models/alexa.js b/backend/models/alexa.js
index 87d1b95..51ac02e 100644
--- a/backend/models/alexa.js
+++ b/backend/models/alexa.js
@@ -45,18 +45,7 @@ module.exports = {
}
});
- //Defaul Amazon handlers (some of them)
-
- handlers.NewSession = function () {};
-
- handlers['AMAZON.HelpIntent'] = function () {
- console.log ('Help intent');
- this.response
- .speak (listOfPossibleQuestions)
- .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
- };
-
- //Handler for launch request
+ //Handler for launch requestconsole.log()
handlers = {
LaunchRequest: function () {
this.response
@@ -170,6 +159,19 @@ module.exports = {
}
};
+ //Defaul Amazon handlers (some of them)
+
+ handlers.NewSession = function () {
+ console.log(this.event.request);
+ };
+
+ handlers['AMAZON.HelpIntent'] = function () {
+ console.log ('Help intent');
+ this.response
+ .speak (listOfPossibleQuestions)
+ .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
+ };
+
//Default handlers for unknown questions and session close
handlers.Unhandled = function () {
--
2.47.3
From 0a8eb2e280146f3cda62932e77ac6494437f4a6e Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Tue, 23 Jan 2018 02:18:08 +0100
Subject: [PATCH 28/31] fix code
---
backend/models/alexa.js | 4 ----
1 file changed, 4 deletions(-)
diff --git a/backend/models/alexa.js b/backend/models/alexa.js
index 51ac02e..63d9f16 100644
--- a/backend/models/alexa.js
+++ b/backend/models/alexa.js
@@ -161,10 +161,6 @@ module.exports = {
//Defaul Amazon handlers (some of them)
- handlers.NewSession = function () {
- console.log(this.event.request);
- };
-
handlers['AMAZON.HelpIntent'] = function () {
console.log ('Help intent');
this.response
--
2.47.3
From cc579133c0688076636b38b8328097611b1f4bce Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Tue, 23 Jan 2018 02:23:59 +0100
Subject: [PATCH 29/31] Amazon default intents not working with dialog
---
backend/models/alexa.js | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/backend/models/alexa.js b/backend/models/alexa.js
index 63d9f16..61b390c 100644
--- a/backend/models/alexa.js
+++ b/backend/models/alexa.js
@@ -159,15 +159,6 @@ module.exports = {
}
};
- //Defaul Amazon handlers (some of them)
-
- handlers['AMAZON.HelpIntent'] = function () {
- console.log ('Help intent');
- this.response
- .speak (listOfPossibleQuestions)
- .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
- };
-
//Default handlers for unknown questions and session close
handlers.Unhandled = function () {
--
2.47.3
From dc2c8f384e6ed1a9fb5a0a9af65aa3e27fab8536 Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Tue, 23 Jan 2018 12:15:04 +0100
Subject: [PATCH 30/31] use foreach instead of map
---
backend/models/alexa.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/backend/models/alexa.js b/backend/models/alexa.js
index 61b390c..c9a32e2 100644
--- a/backend/models/alexa.js
+++ b/backend/models/alexa.js
@@ -34,7 +34,7 @@ module.exports = {
destinationEmail = activeSkill.contactEmail;
let listOfPossibleQuestions = '';
- activeSkill.intents.map (intent => {
+ activeSkill.intents.forEach(intent => {
if (intent.questions.length > 0 && intent.intentExplanation) {
listOfPossibleQuestions +=
intent.intentExplanation +
@@ -45,6 +45,8 @@ module.exports = {
}
});
+ console.log(listOfPossibleQuestions);
+
//Handler for launch requestconsole.log()
handlers = {
LaunchRequest: function () {
--
2.47.3
From d8b2f5f0b4e3efb36a771d569b6d944e84c737c7 Mon Sep 17 00:00:00 2001
From: GotPPay
Date: Tue, 23 Jan 2018 12:18:20 +0100
Subject: [PATCH 31/31] fix typo
---
backend/helpers/email.js | 2 +-
backend/models/alexa.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/backend/helpers/email.js b/backend/helpers/email.js
index 76e109a..f13a0ce 100644
--- a/backend/helpers/email.js
+++ b/backend/helpers/email.js
@@ -26,7 +26,7 @@ module.exports = {
return validEmailRegex.test (email);
},
- sendEmal: function (name, fromEmail, message, toEmail) {
+ sendEmail: function (name, fromEmail, message, toEmail) {
return new Promise ((resolve, reject) => {
fromEmail = this.transformEmailFromAlexaResponse(fromEmail);
let messageBody =
diff --git a/backend/models/alexa.js b/backend/models/alexa.js
index 4074784..309e210 100644
--- a/backend/models/alexa.js
+++ b/backend/models/alexa.js
@@ -121,7 +121,7 @@ module.exports = {
console.log ('Email : ' + intent.slots.Email.value);
console.log ('Message : ' + intent.slots.Message.value);
emailHelper
- .sendEmal (
+ .sendEmail (
intent.slots.Name.value,
intent.slots.Email.value,
intent.slots.Message.value,
--
2.47.3