experiment with Yes and No intents

This commit is contained in:
GotPPay
2018-01-23 00:20:50 +01:00
parent d58d4b89e3
commit b1a853c363
2 changed files with 28 additions and 10 deletions

View File

@@ -64,12 +64,25 @@ var generateInteractionModel = function (skill) {
let result = {}; let result = {};
let allIntents = []; let allIntents = [];
//Special Amazon intent
allIntents.push (
{
name: 'AMAZON.YesIntent',
samples: [],
},
{
name: 'AMAZON.NoIntent',
samples: [],
}
);
skill.intents.map (intent => { skill.intents.map (intent => {
allIntents.push ({name: intent.intentName, samples: intent.questions}); allIntents.push ({name: intent.intentName, samples: intent.questions});
}); });
//Special intent for sending message (Dialog) //Special intent for sending message (Dialog)
allIntents.push ({ allIntents.push ({
name: 'SendMessageIntent', name: 'SendMessageIntent',
samples: [ samples: [
@@ -95,9 +108,7 @@ var generateInteractionModel = function (skill) {
}, },
], ],
}); });
let customSlotTypes = [ let customSlotTypes = [
{ {
name: 'EmailSlot', name: 'EmailSlot',
@@ -152,7 +163,7 @@ var generateInteractionModel = function (skill) {
], ],
}, },
]; ];
let dialogPrompts = [ let dialogPrompts = [
{ {
id: 'Elicit.Intent-SendMessageIntent.IntentSlot-Name', id: 'Elicit.Intent-SendMessageIntent.IntentSlot-Name',
@@ -190,7 +201,7 @@ var generateInteractionModel = function (skill) {
], ],
}, },
]; ];
let dialogIntents = [ let dialogIntents = [
{ {
name: 'SendMessageIntent', name: 'SendMessageIntent',
@@ -244,7 +255,7 @@ var generateInteractionModel = function (skill) {
}; };
var uploadSkill = function (skill) { var uploadSkill = function (skill) {
let generatedInteractionModel = generateInteractionModel(skill); let generatedInteractionModel = generateInteractionModel (skill);
return fetch ( return fetch (
`https://api.amazonalexa.com/v0/skills/${skill.skillID}/interactionModel/locales/en-US`, `https://api.amazonalexa.com/v0/skills/${skill.skillID}/interactionModel/locales/en-US`,
{ {

View File

@@ -47,24 +47,31 @@ module.exports = {
//Defaul Amazon handlers (some of them) //Defaul Amazon handlers (some of them)
handlers.NewSession = function () { handlers.NewSession = function () {
this.attributes['WantToHearQuestions'] = false; this.attributes['WaitingQuestions'] = false;
}; };
handlers['AMAZON.YesIntent'] = function () { handlers['AMAZON.YesIntent'] = function () {
console.log("yes intent"); console.log("yes intent");
if (this.attributes['WantToHearQuestions']) { if (this.attributes['WaitingQuestions']) {
this.response this.response
.speak (listOfPossibleQuestions) .speak (listOfPossibleQuestions)
.listen(listOfPossibleQuestions); .listen(constants.voiceResponseStrings.GENERIC_CONTINUE);
this.emit(':responseReady'); this.emit(':responseReady');
} }
}; };
handlers['AMAZON.NoIntent'] = function () {
console.log("No intent");
if (this.attributes['WaitingQuestions']) {
this.attributes['WaitingQuestions'] = false;
}
};
//Handler for launch request //Handler for launch request
handlers = { handlers = {
LaunchRequest: function () { LaunchRequest: function () {
this.response this.response
.speak (activeSkill.invocationAnswer) .speak (activeSkill.invocationAnswer + '<break time="1s"/> Would you like to hear possible questions ?')
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!! .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
this.attributes['WantToHearQuestions'] = true; this.attributes['WantToHearQuestions'] = true;