Files
old-tellall/backend/controllers/saburlyEntryPoint.js
2018-01-18 19:50:13 +01:00

40 lines
1.1 KiB
JavaScript

var express = require ('express'), router = express.Router ();
const config = require('../config/config');
var bodyParser = require ('body-parser');
var Alexa = require('alexa-sdk');
router.get('/', async (req, res) => {
console.log("GET request on /saburly");
// Build the context manually, because Amazon Lambda is missing
var context = {
succeed: function (result) {
console.log(result);
res.json(result);
},
fail:function (error) {
console.log(error);
}
};
const handlers = {
'LaunchRequest': function () {
console.log("Launch request");
this.emit(':tell', 'Welcome to Saburly');
this.emit('HelloWorldIntent');
},
'HelloWorldIntent': function () {
console.log("Hello world intent");
this.emit(':tell', 'Hello World!');
}
};
// Delegate the request to the Alexa SDK and the declared intent-handlers
var alexa = Alexa.handler(req.body, context);
alexa.appId = config.SKILL_ID;
alexa.registerHandlers(handlers);
alexa.execute();
});
module.exports = router;