complete switch to new alexa package

This commit is contained in:
GotPPay
2018-01-18 21:33:44 +01:00
parent 2f59e12aa7
commit 68287d49ff
7 changed files with 62 additions and 253 deletions

View File

@@ -1,40 +1,9 @@
var express = require ('express'), router = express.Router ();
const config = require('../config/config');
var bodyParser = require ('body-parser');
var Alexa = require('alexa-sdk');
var alexa = require ('../models/alexa');
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();
router.post ('/', bodyParser.json (), async (req, res) => {
alexa.run (req, res);
});
module.exports = router;
module.exports = router;