From c731f7597ce64637aef4ddbc039e98fc7704ff82 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Thu, 18 Jan 2018 01:15:14 +0100 Subject: [PATCH] dialog test --- backend/components/alexa.js | 41 +++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/backend/components/alexa.js b/backend/components/alexa.js index 2fc124d..8ca9e6b 100644 --- a/backend/components/alexa.js +++ b/backend/components/alexa.js @@ -19,16 +19,16 @@ module.exports = { init: function (express) { alexaApp.express ({ expressApp: express, - + // 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 // things to test behavior. enabled by default. checkCert: false, - + // sets up a GET route when set to true. This is handy for testing in // development, but not recommended for production. disabled by default debug: true, - }); + }); }, updateIntentsJSON: function () { @@ -42,7 +42,7 @@ module.exports = { slots: [], utterances: intent.questions, }, - function (request, response) { + (request, response) => { return response.say (intent.answer).shouldEndSession (false); } ); @@ -52,6 +52,38 @@ module.exports = { return response.say (skill.invocationAnswer).shouldEndSession (false); }); + alexaApp.intent ( + 'EmailIntent', + { + dialog: { + type: 'delegate', + }, + slots: [ + { + name: 'Name', + type: 'AMAZON.US_FIRST_NAME', + samples: [], + }, + { + name: 'Color', + type: 'AMAZON.Color', + samples:[] + }, + ], + utterances: [ + 'I would like to send a message', + 'I want to send a message', + 'Send message', + ], + }, + (request, response) => { + console.log ('Completed : ' + request.getDialog.isCompleted ()); + console.log('Name : ' + request.slot('Name')); + console.log('Color : ' + request.slot('Color')); + } + ); + + /* alexaApp.intent ( 'EmailIntentLaunch', { @@ -193,6 +225,7 @@ module.exports = { } } ); + */ }) .catch (err => { console.log (err);