From 994670ce54d0c24a7df9c46cc8f0c4d3cc948434 Mon Sep 17 00:00:00 2001 From: Bilal Date: Mon, 8 Jan 2018 12:44:38 +0000 Subject: [PATCH] from server ; working with amazon test service, not working with real device --- backend/express.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/backend/express.js b/backend/express.js index b12111d..d878244 100644 --- a/backend/express.js +++ b/backend/express.js @@ -61,21 +61,27 @@ alexaApp.express({ // from here on you can setup any other express routes or middlewares as nor app.set("view engine", "ejs"); - +/* alexaApp.launch(function(request, response) { console.log("Alexa launch"); - console.log(request); - /* - const skill = db.collection('skill_list').findOne({_id: ObjectID(skillDbID)}, (err,result)=>{ + db.collection('skill_list').findOne({_id: ObjectID(skillDbID)}, (err,skill)=>{ + if (skill){ + console.log('pass'); + return new Promise ((resolve,reject)=>{ + }else{ + console.log('error'); + } + /* if (err){ return response.say("I could not find desired skill") + console.log('error ' + err); }else{ - return response.say(skill.invocationAnswer); + //return response.say(result.invocationAnswer); + return response.say('Welcome'); + console.log('Poslano'); } }); - */ - return response.say('Welcome to Saburly'); -}); +});*/ var findElementByAttr = function (data, attr, val){ for(var i = 0; i < data.length; i ++) { @@ -110,7 +116,10 @@ var updateIntentsJSON = function(){ db.collection('skill_list').findOne({_id: ObjectID(skillDbID)}, (err, skill)=>{ if (skill){ skill.intents.map(intent => { - alexaApp.intent(intent.intentName,{'slots':[], 'utterances':intent.questions}, function(request,response){ response.say(intent.answer);}); + alexaApp.intent(intent.intentName,{'slots':[], 'utterances':intent.questions}, function(request,response){ return response.say(intent.answer);}); + }); + alexaApp.launch((request,response)=>{ + return response.say(skill.invocationAnswer); }); } });