from server ; intents working - launch request not working

This commit is contained in:
Bilal
2018-01-08 12:06:25 +00:00
parent 8a59d452f5
commit 51ff7f255c

View File

@@ -62,10 +62,10 @@ alexaApp.express({
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)=>{
if (err){
return response.say("I could not find desired skill")
@@ -73,8 +73,9 @@ alexaApp.launch(function(request, response) {
return response.say(skill.invocationAnswer);
}
});
*/
return response.say('Welcome to Saburly');
});
*/
var findElementByAttr = function (data, attr, val){
for(var i = 0; i < data.length; i ++) {
@@ -105,6 +106,18 @@ alexaApp.request = (jsonRequest) => {
};
*/
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("SimpleIntent", {
"slots": [],
"utterances": ["Tell me somethin"]
@@ -113,6 +126,7 @@ alexaApp.intent("SimpleIntent", {
response.say("This is sample");
}
);
*/
/*
alexaApp.error = function(exception, request, response){
@@ -170,6 +184,7 @@ router.post ('/updateSkill/:id', async (req, res, next) => {
if (JSON.parse(result).nModified===1){
//database update ok
res.json({result:0, message:'ok'});
updateIntentsJSON();
}else{
res.json({result:-1, message:'ok'});
}
@@ -211,6 +226,7 @@ MongoClient.connect (config.dbURL).then (database => {
app.listen (config.PORT, () =>{
console.log ('Express server running on port ' + config.PORT);
updateIntentsJSON();
databaseHelper.loadTokens();
});
}).catch(e=>{