15 Commits

Author SHA1 Message Date
GotPPay
9b58f7745b improve code 2018-01-25 15:56:45 +01:00
GotPPay
b0737efb4e add missing spread operator 2018-01-25 15:39:48 +01:00
GotPPay
5d2a15bc93 apply comment from PR 2018-01-25 15:19:30 +01:00
GotPPay
145fff3b51 fix alexa bug with no speak action 2018-01-24 13:14:47 +01:00
GotPPay
4f6c714fa3 Rephrase continuation question 2018-01-24 13:11:35 +01:00
GotPPay
f714fdf70a improve No intent 2018-01-24 13:07:08 +01:00
GotPPay
adc1f1c099 improve default built-in intents 2018-01-24 13:02:46 +01:00
GotPPay
c0a177d39b experiment with yes no help cancel 2018-01-23 14:40:01 +01:00
GotPPay
3700d9bb58 Simulate built-in intents 2018-01-23 13:46:02 +01:00
GotPPay
7a5ddc6b52 Experiment with user-defined help intent 2018-01-23 13:33:53 +01:00
GotPPay
39b8e7608e Test built-in intents 2018-01-23 13:24:56 +01:00
MirnaM
a8ffe0a5c0 Merge pull request #11 from GotPPay/send-message-feature
Send message feature
2018-01-23 12:19:57 +01:00
MirnaM
def591224e Merge pull request #12 from GotPPay/question-explanation
Question explanation
2018-01-23 12:19:14 +01:00
GotPPay
d8b2f5f0b4 fix typo 2018-01-23 12:18:20 +01:00
MirnaM
f6bf3a05b2 Merge pull request #10 from GotPPay/switch-to-alexa-sdk
Switch to alexa sdk
2018-01-19 11:24:23 +01:00
4 changed files with 87 additions and 8 deletions

View File

@@ -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 : 'Say something to continue',
DIDNT_ASK_ANYTHING : 'There was no question to answer to',
}
//Timing is given in [ms]

View File

@@ -68,6 +68,34 @@ var generateInteractionModel = function (skill) {
allIntents.push ({name: intent.intentName, samples: intent.questions});
});
//Built-In like 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: [],
},
{
name: 'CancelIntent',
samples: ['Cancel', 'Stop', 'Please stop'],
slots: [],
},
{
name: 'YesIntent',
samples: [
'Yes',
'Yes please',
'I would like that',
'Yes I would like that',
],
slots: [],
},
{
name: 'NoIntent',
samples: ['No', 'No thank you'],
slots: [],
});
//Special intent for sending message (Dialog)
allIntents.push ({

View File

@@ -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 =

View File

@@ -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 +
@@ -44,8 +44,7 @@ module.exports = {
'ms"/>';
}
});
console.log(listOfPossibleQuestions);
listOfPossibleQuestions += 'If you dont know what to do, just say help or stop';
//Handler for launch requestconsole.log()
handlers = {
@@ -56,9 +55,10 @@ module.exports = {
'<break time="' +
constants.voiceResponseTimings.PAUSE_AFTER_WELCOME_MESSAGE +
'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 !!!
this.attributes['LaunchRequestYesNo'] = true;
this.emit (':responseReady');
},
};
@@ -66,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 !!!
@@ -75,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);
@@ -138,7 +145,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,
@@ -161,7 +168,48 @@ module.exports = {
}
};
//Default handlers for unknown questions and session close
//Built-In intents
handlers.CancelIntent = function () {
if (this.attributes['LaunchRequestYesNo']){
this.attributes['LaunchRequestYesNo'] = false;
}
this.response.speak ('Thank you for using Saburly');
this.emit (':responseReady');
};
handlers.HelpIntent = function () {
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');
};
handlers.YesIntent = function(){
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.speak('').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');
}
}
//Default handler for unknown question
handlers.Unhandled = function () {
this.response
@@ -169,6 +217,8 @@ module.exports = {
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE);
};
//Session handlers
handlers.SessionEndedRequest = function () {
//We don't care for now
};