3 Commits

Author SHA1 Message Date
GotPPay
2ccc0c6ca2 dialog test 2018-01-18 19:08:51 +01:00
GotPPay
554a16794d dialog test 2018-01-18 07:38:09 +01:00
GotPPay
c731f7597c dialog test 2018-01-18 01:15:14 +01:00
2 changed files with 214 additions and 4 deletions

View File

@@ -19,16 +19,16 @@ module.exports = {
init: function (express) { init: function (express) {
alexaApp.express ({ alexaApp.express ({
expressApp: express, expressApp: express,
// verifies requests come from amazon alexa. Must be enabled for production. // verifies requests come from amazon alexa. Must be enabled for production.
// You can disable this if you're running a dev environment and want to POST // You can disable this if you're running a dev environment and want to POST
// things to test behavior. enabled by default. // things to test behavior. enabled by default.
checkCert: false, checkCert: false,
// sets up a GET route when set to true. This is handy for testing in // sets up a GET route when set to true. This is handy for testing in
// development, but not recommended for production. disabled by default // development, but not recommended for production. disabled by default
debug: true, debug: true,
}); });
}, },
updateIntentsJSON: function () { updateIntentsJSON: function () {
@@ -42,7 +42,7 @@ module.exports = {
slots: [], slots: [],
utterances: intent.questions, utterances: intent.questions,
}, },
function (request, response) { (request, response) => {
return response.say (intent.answer).shouldEndSession (false); return response.say (intent.answer).shouldEndSession (false);
} }
); );
@@ -52,6 +52,56 @@ module.exports = {
return response.say (skill.invocationAnswer).shouldEndSession (false); return response.say (skill.invocationAnswer).shouldEndSession (false);
}); });
alexaApp.intent (
'EmailIntent',
{
dialog: {
'type': 'delegate',
},
slots: [
{
name:'Name',
type:'AMAZON.US_FIRST_NAME',
samples:[
'My name is {-|Name}',
'I am {-|Name}',
'{-|Name}'
]
},
{
"name": "Email",
"type": "emailSlot",
"samples": [
"{blablablabla@blablabla.blabla.blabla|Email}",
"My email is {blablablabla@blablabla.blabla.blabla|Email}"
]
},
{
"name": "Message",
"type": "emailMessage",
"samples": [
"{Quick brown fox jumps over lazy dog. Quick brown fox jumps over lazy dog. Quick brown fox jumps over lazy dog.|Message}",
"My message is {Quick brown fox jumps over lazy dog. Quick brown fox jumps over lazy dog. Quick brown fox jumps over lazy dog.|Message}"
]
}
],
utterances: [
'I would like to send a message',
'I want to send a message',
'Send message',
],
},
(request, response) => {
console.log('Name : ' + request.slot('Name'));
console.log('Color : ' + request.slot('Color'));
}
);
/*
alexaApp.intent ( alexaApp.intent (
'EmailIntentLaunch', 'EmailIntentLaunch',
{ {
@@ -193,6 +243,7 @@ module.exports = {
} }
} }
); );
*/
}) })
.catch (err => { .catch (err => {
console.log (err); console.log (err);

View File

@@ -56,6 +56,10 @@ var refreshTokens = function () {
var generateInteractionModel = function (skill) { var generateInteractionModel = function (skill) {
let result = {}; let result = {};
let allIntents = []; let allIntents = [];
let allPrompts = [];
let dialogIntents = [];
let allTypes = [];
let defaultIntents = [ let defaultIntents = [
{ {
name: 'AMAZON.CancelIntent', name: 'AMAZON.CancelIntent',
@@ -81,7 +85,154 @@ var generateInteractionModel = function (skill) {
allIntents.push ({name: intent.intentName, samples: intent.questions}); allIntents.push ({name: intent.intentName, samples: intent.questions});
}); });
allIntents.push({
name:'EmailIntent',
samples:['I would like to send a message', 'I want to send a message', 'Send a message'],
slots:[
{
name:'Name',
type:'AMAZON.US_FIRST_NAME',
samples:[
'My name is {Name}',
'I am {Name}',
'{Name}'
]
},
{
"name": "Email",
"type": "emailSlot",
"samples": [
"{Email}",
"My email is {Email}"
]
},
{
"name": "Message",
"type": "emailMessage",
"samples": [
"{Message}",
"My message is {Message}"
]
}
]
});
allPrompts.push(
{
"id": "Elicit.Intent-EmailIntent.IntentSlot-Name",
"variations": [
{
"type": "PlainText",
"value": "What is your name ?"
}
]
}
);
allPrompts.push(
{
"id": "Elicit.Intent-EmailIntent.IntentSlot-Color",
"variations": [
{
"type": "PlainText",
"value": "What is your email"
},
{
"type": "PlainText",
"value": "Tell me your email"
}
]
}
);
allPrompts.push(
{
"id": "Elicit.Intent-EmailIntent.IntentSlot-Message",
"variations": [
{
"type": "PlainText",
"value": "What is your message ?"
},
{
"type": "PlainText",
"value": "What is the message ?"
}
]
}
);
dialogIntents.push(
{
"name": "EmailIntent",
"confirmationRequired": false,
"prompts": {},
"slots": [
{
"name": "Name",
"type": "AMAZON.US_FIRST_NAME",
"elicitationRequired": true,
"confirmationRequired": false,
"prompts": {
"elicitation": "Elicit.Intent-EmailIntent.IntentSlot-Name"
}
},
{
"name": "Email",
"type": "emailSlot",
"elicitationRequired": true,
"confirmationRequired": false,
"prompts": {
"elicitation": "Elicit.Intent-EmailIntent.IntentSlot-Email"
}
},
{
"name": "Message",
"type": "emailMessage",
"elicitationRequired": true,
"confirmationRequired": false,
"prompts": {
"elicitation": "Elicit.Intent-EmailIntent.IntentSlot-Message"
}
}
]
}
);
allTypes.push(
{
"name": "emailMessage",
"values": [
{
"id": null,
"name": {
"value": "Quick brown fox jumps over lazy dog. Quick brown fox jumps over lazy dog. Quick brown fox jumps over lazy dog.",
"synonyms": []
}
}
]
}
);
allTypes.push(
{
"name": "emailSlot",
"values": [
{
"id": null,
"name": {
"value": "blablablabla@blablabla.blabla.blabla",
"synonyms": []
}
}
]
}
);
//Special Email Intents : //Special Email Intents :
/*
allIntents.push ({ allIntents.push ({
name: 'EmailIntentLaunch', name: 'EmailIntentLaunch',
slots: [], slots: [],
@@ -123,6 +274,9 @@ var generateInteractionModel = function (skill) {
'My message is {The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.|Message}', 'My message is {The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.|Message}',
], ],
}); });
*/
result.interactionModel = {}; result.interactionModel = {};
@@ -131,6 +285,11 @@ var generateInteractionModel = function (skill) {
intents: allIntents, intents: allIntents,
}; };
result.interactionModel.types = allTypes;
result.interactionModel.prompts = allPrompts;
result.interactionModel.dialog = {};
result.interactionModel.dialog.intents = dialogIntents;
return JSON.stringify (result); return JSON.stringify (result);
}; };