from server
This commit is contained in:
@@ -33,7 +33,27 @@ alexaApp.express({
|
||||
|
||||
// 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
|
||||
debug: true,
|
||||
|
||||
preRequest: (request, response)=>{
|
||||
console.log('Pre req');
|
||||
/*
|
||||
const alexaRequest = new alexa.request(request);
|
||||
if (alexaRequest.type() === "IntentRequest") {
|
||||
db.collection('skill_list').findOne({_id: ObjectID(skillDbID)}, (err,skill)=>{
|
||||
if (skill) {
|
||||
console.log(alexaRequest.data.request.intent);
|
||||
let intentId = findElementByAttr(skill.intents, 'intentName', alexaRequest.data.request.intent.name);
|
||||
const response = new alexa.response(alexaRequest.getSession());
|
||||
if (intentId !== -1){
|
||||
return response.say(skill.intents[intentId].answer);
|
||||
}else{
|
||||
return response.say('Sorry, I could not find desired intent');
|
||||
}
|
||||
}
|
||||
});
|
||||
}*/
|
||||
}
|
||||
});
|
||||
|
||||
// now POST calls to /test in express will be handled by the app.request() function
|
||||
@@ -42,17 +62,19 @@ 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){
|
||||
response.say("I could not find desired skill")
|
||||
return response.say("I could not find desired skill")
|
||||
}else{
|
||||
response.say(skill.invocationAnswer);
|
||||
return response.say(skill.invocationAnswer);
|
||||
}
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
var findElementByAttr = function (data, attr, val){
|
||||
for(var i = 0; i < data.length; i ++) {
|
||||
@@ -63,6 +85,7 @@ var findElementByAttr = function (data, attr, val){
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
alexaApp.request = (jsonRequest) => {
|
||||
const alexaRequest = new alexa.request(jsonRequest);
|
||||
if (alexaRequest.type() === "IntentRequest") {
|
||||
@@ -72,14 +95,30 @@ alexaApp.request = (jsonRequest) => {
|
||||
let intentId = findElementByAttr(skill.intents, 'intentName', alexaRequest.data.request.intent.name);
|
||||
const response = new alexa.response(alexaRequest.getSession());
|
||||
if (intentId !== -1){
|
||||
return response.say(skill.intents[intentId].answer);
|
||||
response.say(skill.intents[intentId].answer);
|
||||
}else{
|
||||
return response.say('Sorry, I could not find desired intent');
|
||||
response.say('Sorry, I could not find desired intent');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
alexaApp.intent("SimpleIntent", {
|
||||
"slots": [],
|
||||
"utterances": ["Tell me somethin"]
|
||||
},
|
||||
function(request, response) {
|
||||
response.say("This is sample");
|
||||
}
|
||||
);
|
||||
|
||||
/*
|
||||
alexaApp.error = function(exception, request, response){
|
||||
console.log('Error ' + exception);
|
||||
response.say('Sorry, there was error in Saburly skill'); // TODO : Rephrase this
|
||||
};*/
|
||||
|
||||
router.get ('/getSkill/:id', async (req, res, next) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user