var http = require('http'); // if going through a proxy that uses SSL change to "require('https');" // Your external IP. Alexa can only access publically-accessible IPs. No LAN access unfortunately. // In my case I had to move receiver to DMZ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// var local_ip = 'deskcontrol.k-world.me.uk'; var local_port = '80'; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * App ID for the skill */ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// var APP_ID = "amzn1.ask.skill.8f9502ec-5452-4c18-a8e5-6f2aed86d676"; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * The AlexaSkill prototype and helper functions */ var AlexaSkill = require('./AlexaSkill'); var DTVControl = function () { AlexaSkill.call(this, APP_ID); }; // Extend AlexaSkill DTVControl.prototype = Object.create(AlexaSkill.prototype); DTVControl.prototype.constructor = DTVControl; //Ignore Certificate errors if using HTTPS communication process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; DTVControl.prototype.intentHandlers = { desk: function (intent, session, response) { //No matter what she wants to tell you her opinion. function satisfyAlexa() { response.tell("Desk Updated"); }; // Obtain User Intent switch(intent.slots.Control.value) { // List of triggers and URL to goto case "red": path = '/red.php'; break; case "blue": path = '/blue.php'; break; case "green": path = '/green.php'; break; case "off": path = '/off.php'; break; default: response.tell("Sorry, I didnt understand that desk request."); break; } var options = { host: local_ip, port: local_port, // default port for webserver path: '' + path, // Modify if path is prefixed method: 'POST' //, //(remove first comment slashes if using the "auth" option below) // auth: 'username:password' // this is used if going through authenticated proxy (this is BASIC AUTH) }; var req = http.request(options, satisfyAlexa); req.end(); } } exports.handler = function (event, context) { var dtvControl = new DTVControl(); dtvControl.execute(event, context); };