experiment with yes no help cancel

This commit is contained in:
GotPPay
2018-01-23 14:40:01 +01:00
parent 3700d9bb58
commit c0a177d39b
2 changed files with 53 additions and 5 deletions

View File

@@ -81,6 +81,23 @@ var generateInteractionModel = function (skill) {
slots: [], 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) //Special intent for sending message (Dialog)
allIntents.push ({ allIntents.push ({

View File

@@ -55,9 +55,10 @@ module.exports = {
'<break time="' + '<break time="' +
constants.voiceResponseTimings.PAUSE_AFTER_WELCOME_MESSAGE + constants.voiceResponseTimings.PAUSE_AFTER_WELCOME_MESSAGE +
'ms"/>' + 'ms"/>' +
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 !!! .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
this.attributes['LaunchRequestYesNo'] = true;
this.emit (':responseReady'); this.emit (':responseReady');
}, },
}; };
@@ -65,6 +66,9 @@ module.exports = {
//Handlers for user defined questions //Handlers for user defined questions
activeSkill.intents.map (intent => { activeSkill.intents.map (intent => {
handlers[intent.intentName] = function () { handlers[intent.intentName] = function () {
if (this.attributes['LaunchRequestYesNo']){
this.attributes['LaunchRequestYesNo'] = false;
}
this.response this.response
.speak (intent.answer) .speak (intent.answer)
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!! .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
@@ -74,6 +78,10 @@ module.exports = {
//Handler for sending message //Handler for sending message
handlers.SendMessageIntent = function () { handlers.SendMessageIntent = function () {
if (this.attributes['LaunchRequestYesNo']){
this.attributes['LaunchRequestYesNo'] = false;
}
let intent = this.event.request.intent; let intent = this.event.request.intent;
console.log ('Dialog state : ' + this.event.request.dialogState); console.log ('Dialog state : ' + this.event.request.dialogState);
@@ -163,20 +171,37 @@ module.exports = {
//Built-In intents //Built-In intents
handlers.CancelIntent = function () { handlers.CancelIntent = function () {
console.log ('Cancel'); if (this.attributes['LaunchRequestYesNo']){
this.reponse.speak ('Thank you for using Saburly'); this.attributes['LaunchRequestYesNo'] = false;
}
this.response.speak ('Thank you for using Saburly');
this.emit (':responseReady'); this.emit (':responseReady');
}; };
handlers.HelpIntent = function () { handlers.HelpIntent = function () {
console.log ('Help'); if (this.attributes['LaunchRequestYesNo']){
this.attributes['LaunchRequestYesNo'] = false;
}
this.response this.response
.speak (listOfPossibleQuestions) .speak (listOfPossibleQuestions)
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!! .listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
this.emit (':responseReady'); 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 () { handlers.Unhandled = function () {
this.response this.response
@@ -184,6 +209,12 @@ module.exports = {
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE); .listen (constants.voiceResponseStrings.GENERIC_CONTINUE);
}; };
//Session handlers
handlers.NewSession = function(){
this.attributes['LaunchRequestYesNo'] = false;
}
handlers.SessionEndedRequest = function () { handlers.SessionEndedRequest = function () {
//We don't care for now //We don't care for now
}; };