From 554a16794dc1a3a57ac23dc494835667821e793c Mon Sep 17 00:00:00 2001 From: GotPPay Date: Thu, 18 Jan 2018 07:38:09 +0100 Subject: [PATCH] dialog test --- backend/components/alexa.js | 17 ++++--- backend/helpers/amazon.js | 94 +++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 7 deletions(-) diff --git a/backend/components/alexa.js b/backend/components/alexa.js index 8ca9e6b..3445d71 100644 --- a/backend/components/alexa.js +++ b/backend/components/alexa.js @@ -52,22 +52,25 @@ module.exports = { return response.say (skill.invocationAnswer).shouldEndSession (false); }); + + + alexaApp.intent ( 'EmailIntent', { dialog: { - type: 'delegate', + 'type': 'delegate', }, slots: [ { - name: 'Name', - type: 'AMAZON.US_FIRST_NAME', - samples: [], + 'name': 'Name', + 'type': 'AMAZON.US_FIRST_NAME', + 'samples': ['My name is {Name}', 'I am {Name}', '{Name}'], }, { - name: 'Color', - type: 'AMAZON.Color', - samples:[] + 'name': 'Color', + 'type': 'AMAZON.Color', + 'samples':['My favorite color is {Color}', '{Color}'] }, ], utterances: [ diff --git a/backend/helpers/amazon.js b/backend/helpers/amazon.js index 1fd9410..a380b3e 100644 --- a/backend/helpers/amazon.js +++ b/backend/helpers/amazon.js @@ -56,6 +56,9 @@ var refreshTokens = function () { var generateInteractionModel = function (skill) { let result = {}; let allIntents = []; + let allPrompts = []; + let dialogIntents = []; + let defaultIntents = [ { name: 'AMAZON.CancelIntent', @@ -81,7 +84,91 @@ var generateInteractionModel = function (skill) { 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": "Color", + "type": "AMAZON.Color", + "samples": [ + "{Color}", + "My favorite color is {Color}" + ] + } + ] + }); + + 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": "Tell me your favorite color" + }, + { + "type": "PlainText", + "value": "What is your favorite color" + } + ] + } + ); + + 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": "Color", + "type": "AMAZON.Color", + "elicitationRequired": true, + "confirmationRequired": false, + "prompts": { + "elicitation": "Elicit.Intent-EmailIntent.IntentSlot-Color" + } + } + ] + } + ); + + + + //Special Email Intents : + /* allIntents.push ({ name: 'EmailIntentLaunch', slots: [], @@ -123,6 +210,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}', ], }); + */ + + result.interactionModel = {}; @@ -131,6 +221,10 @@ var generateInteractionModel = function (skill) { intents: allIntents, }; + result.interactionModel.prompts = allPrompts; + result.interactionModel.dialog = {}; + result.interactionModel.dialog.intents = dialogIntents; + return JSON.stringify (result); };