almost there
This commit is contained in:
@@ -16,7 +16,7 @@ var ObjectID = require ('mongodb').ObjectID;
|
|||||||
const router = express.Router ();
|
const router = express.Router ();
|
||||||
|
|
||||||
var skillID = 'amzn1.ask.skill.7115bfc9-313e-4728-830b-ebd19ce96cb3';
|
var skillID = 'amzn1.ask.skill.7115bfc9-313e-4728-830b-ebd19ce96cb3';
|
||||||
var skillDbID = '5a232fb86ce046c749739455'; //_id in database
|
var skillDbID = '5a5016e775becaef2015da10'; //_id in database
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
|
|
||||||
@@ -66,18 +66,19 @@ var findElementByAttr = function (data, attr, val){
|
|||||||
alexaApp.request = (jsonRequest) => {
|
alexaApp.request = (jsonRequest) => {
|
||||||
const alexaRequest = new alexa.request(jsonRequest);
|
const alexaRequest = new alexa.request(jsonRequest);
|
||||||
if (alexaRequest.type() === "IntentRequest") {
|
if (alexaRequest.type() === "IntentRequest") {
|
||||||
const skill = db.collection('skill_list').findOne({
|
db.collection('skill_list').findOne({_id: ObjectID(skillDbID)}, (err,skill)=>{
|
||||||
_id: skillDbID
|
if (skill) {
|
||||||
});
|
let intentId = findElementByAttr(skill.intents, 'intentName', alexaRequest.data.request.intent.name);
|
||||||
if (skill) {
|
console.log(alexaRequest.data.request.intent.name);
|
||||||
let intentId = findElementByAttr(skill.intents, 'intentName', alexaRequest.data.request.intent.name);
|
console.log(intentId);
|
||||||
const response = new alexa.response(alexaRequest.getSession());
|
const response = new alexa.response(alexaRequest.getSession());
|
||||||
if (intentId !== -1){
|
if (intentId !== -1){
|
||||||
return response.say(skill.intents[intentId].answer);
|
response.say(skill.intents[intentId].answer);
|
||||||
}else{
|
}else{
|
||||||
return response.say('Sorry, I could not find desired intent');
|
response.say('Sorry, I could not find desired intent');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user