Find intent object by name and send answer as response

This commit is contained in:
MirnaM
2017-12-01 14:37:51 +01:00
parent 4f36fc7738
commit 819dbefde7
6 changed files with 12 additions and 230 deletions

View File

@@ -79,21 +79,22 @@ alexaApp.express({
// now POST calls to /test in express will be handled by the app.request() function
// from here on you can setup any other express routes or middlewares as normal
app.set("view engine", "ejs");
alexaApp.launch(function(request, response) {
response.say("You launched Saburly app!");
});
alexaApp.intent("GetProcessIntent", {
"utterances": [
"tell me about projects", "say something about your project", "what are your projects"
]
},
function(request, response) {
response.say("We collaborate closely with our clients at each step of the developmentprocess. From designing the UX to developing the front-end andarchitecting the back-end.");
alexaApp.request = (jsonRequest) => {
const alexaRequest = new alexa.request(jsonRequest);
if (alexaRequest.type() === "IntentRequest") {
const intent = db.collection('intent_list').findOne({
name: alexaRequest.data.request.intent.name
});
if (intent) {
const response = new alexa.response(alexaRequest.getSession());
return response.say(intent.answer);
}
}
);
};
app.use (function (req, res, next) {
res.header ('Access-Control-Allow-Origin', '*');