generate interaction model

This commit is contained in:
GotPPay
2017-12-03 00:15:11 +01:00
parent d5120a1ba2
commit 74ee9de93f
3 changed files with 53 additions and 6 deletions

View File

@@ -1,7 +1,52 @@
var ObjectID = require ('mongodb').ObjectID;
var generateInteractionModel = function (skill) {
try{
let result = {};
let allIntents = [];
let defaultIntents = [{
name: "AMAZON.CancelIntent",
samples: []
},
{
name: "AMAZON.HelpIntent",
samples: []
},
{
name: "AMAZON.StopIntent",
samples: []
}];
defaultIntents.map(intent=>{
allIntents.push(intent);
});
export const sendUpdateToAmazon = (id)=>{
//id - skill ID in database
skill.intents.map(intent=>{
allIntents.push({name: intent.intentName, samples: intent.questions, slots: []});
});
}
result.languageModel = {
invocationName: skill.invocationName,
intents: allIntents
};
return JSON.stringify(result);
}catch(e){
console.log("error generate : " + e);
}
}
module.exports = {
sendUpdateToAmazon: function (id, db){
db.collection ('skill_list').find({_id: ObjectID(id)}).toArray((err,result)=>{
if (err){
console.log("Error finding skill");
}else{
//generateInteractionModel
//POST to amazon
let generatedInteractionModel = generateInteractionModel(result[0]);
}
});
}
};