Example #1
0
  getNext({ service, lat, lng, limit: 3 }).then(times => {
    const next = times[0];
    const alexa = new Alexa.app('nextbus');
    alexa.launch((req, res) => {
      res.say(`The next bus is due in ${next.due} minutes`);
    });

    alexa.intent('NextBusIntent', {}, (req, res) => {
      res.say(`The next bus is due in ${next.due} minutes`);
    });

    return alexa.request(req.body).then(answer => res.json(answer));
  }).catch(e => {
Example #2
0
var alexa = require('alexa-app');
module.change_code = 1;
var config = require('./config');
var _ = require('lodash');
var WindowShadeHelper = require ('./window_shade_helper');

var app = new alexa.app('windowshades');
var shadeHelper = new WindowShadeHelper();
var prompt = '';
var reprompt = '';
var sceneName = '';
var shadeName = '';
var shadePosition = 0;
 
app.launch(function(req, res) {
  prompt = 'Welcome to window shade control.';
  res.say(prompt).reprompt('You can say open bedroom shades or set bottom living room shade to 25%.').shouldEndSession(false);
});

var exitFunction = function(req, res) {
  prompt = 'Bye.';
  res.say(prompt);
};
app.intent('AMAZON.StopIntent', exitFunction);
app.intent('AMAZON.CancelIntent', exitFunction);

app.intent('sceneintent', {
  'slots': {
    'SCENE': 'SCENENAME'
  },
  'utterances': ['{|for} {|scene|recall|go} {|to} {-|SCENE}']
},
'use strict';
module.change_code = 1;
var _ = require('lodash');
var Alexa = require('alexa-app');
var skill = new Alexa.app('airportinfo');
var FAADataHelper = require('./faa_data_helper');
var TwitterHelper = require('./twitter_helper');

skill.launch(function(request, response) {
  var prompt = 'For delay information, tell me an Airport code.';
  response.say(prompt).reprompt(prompt).shouldEndSession(false);
});

skill.intent('tweetAirportStatusIntent', {
  'slots': {
    'AIRPORTCODE': 'FAACODES'
  },
  'utterances': ['tweet {|delay|status} {|info} {|for} {-|AIRPORTCODE}']
},
  function(request, response) {
    console.log('session details', request.sessionDetails);
    console.log('accessToken: ', request.sessionDetails.accessToken);
    var accessToken = request.sessionDetails.accessToken;
    if (accessToken === null) {
      //no token, show link account card
      response.linkAccount().shouldEndSession(true).say('Your twitter account is not linked');
      return true;
    } else {
      //i've got a token! make the tweet
      var twitterHelper = new TwitterHelper(request.sessionDetails.accessToken);
      var faaHelper = new FAADataHelper();
Example #4
0
    co = require('co'),
    Promise = require('node-promise'),

    harmony_clients = {},
    hub_ip = dotenv.HUB_IP,
    app_id = dotenv.SKILL_APP_ID,
    interval = 5 * 60 * 1000,

    app = new alexa.app('remote'),
    resetInterval = setInterval(cacheHarmonyUtils, interval),
    harmony;

cacheHarmonyUtils();

app.launch(function(req, res) {
  console.log("Launching the application");
});

app.intent('IncreaseVolume', co.wrap(function* (req, res) {
  let hutils = yield getHarmonyHub();
  let curActivity = yield hutils.readCurrentActivity();

  let amt = parseInt(req.slot('AMOUNT'), 10);
  if (isNaN(amt)) {
    amt = 1;
  }

  hutils.executeCommand(false, curActivity, 'Volume,Volume Up', amt).then(function () {
    console.log('Volume increased');
  });
}));
Example #5
0
'use strict';
var request = require('request');
var alexa = require('alexa-app');
var directTVApp = new alexa.app('directTV');

// process set temperature request
directTVApp.intent('setChannel', function(req, res) {
  request.get(process.env.DVR_URL + '/tv/tune?major=' + parseInt(req.slot('Channel')));
  res.card("Direct TV Skill","TV set to channel " + parseInt(req.slot('Channel')));
  res.say("I have set the TV to channel " + parseInt(req.slot('Channel')) + " as requested");
});

directTVApp.launch(function(req, res) {
  console.log('REQUEST', JSON.stringify(req));
  res.say("You can say, set to channel 44, or any number that is a valid channel");
});


module.exports = function(cb) {
  global.tv = directTVApp;
  cb();
};
Example #6
0
  }
  response.session(CAKE_BAKER_SESSION_KEY, cakeBakerHelper);
  response.send();
};

skillService.intent('advanceStepIntent', {
    'utterances': ['{next|advance|continue}']
  },
  function(request, response) {
    var cakeBakerHelper = getCakeBakerHelperFromRequest(request);
    cakeBakerHelper.currentStep++;
    cakeBakerIntentFunction(cakeBakerHelper, request, response);
  }
);

skillService.launch(function(request, response) {
  var prompt = 'Welcome to Cakebaker! To start baking, say bake a cake';
  response.say(prompt).shouldEndSession(false);
});

skillService.intent('cakeBakeIntent', {
    'utterances': ['{new|start|create|begin|build} {|a|the} cake']
  },
  function(request, response) {
    var cakeBakerHelper = new CakeBakerHelper({});
    cakeBakerIntentFunction(cakeBakerHelper, request, response);
  }
);

module.exports = skillService;
Example #7
0
  nfl: {
    version: 'nfl/v2',
    key: '72f9e106e27742ac862340b43f38f7de' // <-- Pass in your nfl key here
  }
};

var _ = require('lodash');
var Alexa = require('alexa-app');
var app = new Alexa.app('nfl players'); // Define an alexa-app [use the same name as invocation name]
var fantasyData = require('fantasydata-api')(options);
var playerId = require('./player_ids');

// Gets called whenever there is a launch request
app.launch(function(req, res) {
  var prompt = 'Welcome to NFL skill.',
  reprompt = 'Are you still there? You can ask me details of a player like, his age, height, his current team and so forth.';
  res.say(prompt).reprompt(reprompt).shouldEndSession(false);
});

// Player Basic Introduction Intent
app.intent('playerBasicIntro', {
  'slots': {
    'Player': 'LIST_OF_PLAYERS'
  }
}, 
function(req, res){
  // get the slot
  var infoSlot = req.slot('Player').toLowerCase();
  var information = playerId[infoSlot],
  reprompt = 'Tell me a player name';
  var prompt = '';
Example #8
0
var alexa = require('alexa-app');
var app = new alexa.app('guessinggame');

// Allow this module to be reloaded by hotswap when changed
module.change_code = 1;

app.launch(function(req, res) {
   var number = Math.floor(Math.random() * 99) + 1; //redo being.... coercion...asdladfsjk
   var prompt = 'Guess a number between 1 and 100!';
   res.session('number', number);
   res.session('guesses', 0);
   res.say(prompt).reprompt(prompt).shouldEndSession(false);
});

app.intent('guess', {
        'slots': {'GUESSNUM': 'NUMBER'}
        ,'utterances': ['{GUESSNUM}']
    },
    function(req, res) {
        var guesses = (+req.session('guesses')) + 1;
        var guess = req.slot('GUESSNUM');
        var number = +req.session('number');
        if (!guess) {
            res.say('Sorry, I didn\'t hear a number. The number was' + number);
        }
        else if (guess == number) {
            res.say('Congratulations, you guessed the number in ' + guesses + (guesses == 1 ? ' try ' : ' tries'));
        }
        else {
            if (guess > number) {
				res.say('Guess lower');
Example #9
0
var alexa = require('alexa-app');
var app = new alexa.app();

/**
 * LaunchRequest.
 */
app.launch(function(request,response) {
	response.say('Cool, who has come over?');
	// response.card("Hey there fancy pants!","This is an example card");
	// var number = request.slot('numbers');
	// response.say('You asked for the number '+number);
	response.shouldEndSession(false);
	response.send();
});


/**
 * IntentRequest.
 */
app.intent('GuestIntent',
  {
    'slots':{'Guest':'LIST_OF_GUESTS'},
    'utterances':[
		'{Guest} {Guest} and {Guest}',
		'{Guest}',
		'{Guest} and {Guest}',
		'{Guest} and his family',
		'{Guest} and her family',
		'{Guest} and his boyfriend',
		'{Guest} and her boyfriend',
		'{Guest} and his girlfriend',
Example #10
0
		console.log(args);
	}
	function trollboxEvent (args,kwargs) {
		console.log(args);
	}
	//session.subscribe('BTC_XMR', marketEvent);
	session.subscribe('ticker', tickerEvent);
	//session.subscribe('trollbox', trollboxEvent);
}
connection.onclose = function () {
  console.log("Websocket connection closed");
}                      
//connection.open(); // todo: purpose of open connection? Stream of data useful?

app.launch(function(req, res) {
	res.say("CryptoTrader ready for orders!").shouldEndSession(false);
});

app.intent('ticker', {
	'slots': {'updateAll': 'LITERAL'},
	'utterances': ['update all tickers']
	},
	function(req, res) {

		var currency = '';
		request
			.get
			('https://poloniex.com/public?command=returnTicker')
			.on('data', function(data) {
				currency += data;
			})
Example #11
0
    response.session('number', number); // Remember it
}

skill.launch(function(request, response) {
    response
        .say(
            "<speak> <audio src=\"https://s3.amazonaws.com/xapp-files/Alexa_Skills/Brand_Haiku/Brand_Haiku-Home_Page.mp3\" /> " +
            "You can say <break time='0.25s'/> Play Haiku <break time=\"0.5s\"/>  What Is A Brand Haiku <break time=\"0.25s\"/> " +
            "Or <break time=\"0.25s\"/> About The Author.  Which would you like?  </speak>"
        )
        .reprompt(
            "<speak>  You can say Play Haiku <break time='0.25s'/> What is A Brand Haiku <break time='0.25s'/> " +
            "About The Author.   Or <break time='0.25s'/>if you're done, You can say Stop!   What would you like to do?  </speak>"
        )
        .shouldEndSession(false);

    response
        .card({
            type: "Standard",
            title: "Fifty-Seven Brand Haikus",
            text: "Fifty-Seven Brand Haikus by Joseph Benson",
            image: {
                smallImageUrl: "https://s3.amazonaws.com/xapp-files/Alexa_Skills/Brand_Haiku/haikus57.png",
                largeImageUrl: "https://s3.amazonaws.com/xapp-files/Alexa_Skills/Brand_Haiku/haikus57.png"
            }
        });
});

skill.intent('PlayHaiku',
    {
        "slots":{"haiku":"NUMBER"},
Example #12
0
var AlexaApp = require('alexa-app');
var alexa = new AlexaApp.app('twitchy');
var twitch = require('./twitch.js');
var _ = require('lodash');
var Promise = require('bluebird');

var respondWithProcessingError = response => {
  // Catch-all response when API error occurs.
  response.say('There was an error processing your request.').shouldEndSession(false).send();
};

alexa.launch((request, response) => {
  response.say("You launched Twitchy!");
});

// Run before any Alexa request.
alexa.pre = (request, response, type) => {
  if (!request.sessionDetails.accessToken) {
    response.clear().say("You first need to authorize this skill to use your Twitch account.").send();
  }
};

var getAuthUser = token => {
  var promise = Promise.promisify(twitch.getAuthenticatedUser.bind(twitch));
  return promise(token);
};

var reprompt = 'Can you repeat that?';

alexa.intent("getTopGames", {
    "slots": {
Example #13
0
}

// Reloaded by hotswap when code has changed (by alexa-app-server)
module.change_code = 1;

var appName = config.applicationName;

/******************* ASK MAIN ROUTINES **************/
// Define an alexa-app
var app = new alexa.app(appName);
app.launch(function(request,response) {
    // Store the Launch Intent in session, which later keeps the session going for multiple requests/commands
    response.session ('launched', 'true');
    
    response.say(config.greeting);
    if (config.chime) {
        response.say(config.chime);
    }
    
    response.shouldEndSession(false, "How can I help?");
});

app.sessionEnded(function(request,response) {
    response.say('Bye');
});

app.messages.NO_INTENT_FOUND = "I am uncertain what you mean.  Kindly rephrase...";

// Pre-execution security checks - ensure each requests applicationId / userId / password match configured values
app.pre = function(request,response,type) {
    // Extract values from various levels of the nested request object
Example #14
0
var alexa = require('alexa-app');
var Levenshtein = require('levenshtein');
var omdb = require('omdb');
var SampleMovies = require('SampleMovies');
var WordsToNumber = require ('WordsToNumber');
 
console.log ("creating alexa app...");

var app = new alexa.app();
app.launch(function(request,response) {
    response.session ('open_session', 'true');
	response.say("Welcome to ruuvu.  You can ask for the I M D B and metacritic rating for a movie, or you can ask for the plot summary for a movie.  For examples, say help.  To leave ruuvu, say exit.");
	response.shouldEndSession (false, "What would you like to know?  For examples, say help.  To leave ruuvu, say exit.");
});

app.dictionary = {
    "movie_names": SampleMovies.titles
};

console.log ("defining RatingIntent...");

app.intent('RatingsIntent', 
    {
        "slots": {"TITLE":"LITERAL"},
        "utterances": [
            "{for|what is|what's} the rating {for|of} {the movie |}{movie_names|TITLE}",
            "{for|what are|what're} {the |}ratings {for|of} {the movie |}{movie_names|TITLE}"
        ]
    },
    function (request, response) {
        console.log ("[RatingsIntent]");
Example #15
0
var alexa = require('alexa-app');
var app = new alexa.app();
var Request = require('request');
/**
 * LaunchRequest.
 */
app.launch(function (request, response) {
    response.say('Omnius is Online');
    response.shouldEndSession(false);
});


app.intent('endIntent',
    function (request, response) {
        response.say('stopping, by your command');
        response.shouldEndSession(true);
        response.send();
        return false;
    });

/**
 * IntentRequest.
 */
app.intent('directionIntent',
    {
        'slots': {'dir': 'LIST_OF_DIRECTIONS'},
        'utterances': ['go {dir}']
    },
    function (request, response) {
        var direction = request.slot('dir');
        switch (direction) {
Example #16
0
var alexa = require("alexa-app");
var find = require("find-my-iphone");

var app = new alexa.app();
app.launch(function(request, response) {
  find("*****@*****.**", "mypassword", "iPhone", function() {
    response.say("OK").send();
  });
  // because this is an async handler
  return false;
});

// connect to lambda
exports.handler = app.lambda();
Example #17
0
var alexa = require('alexa-app');
var app = new alexa.app('ticketmaster');
var config = require('./config');

var FindEventsIntent = require('./intentHandlers/findEvents');


app.pre = function(request,response,type) {
	if (request.sessionDetails.application.applicationId != config.app.id) {
		response.fail("Invalid applicationId");
	}
};

app.launch(function(request,response) {
  response.say("Welcome");
  response.card("Welcome", "Please tell me what you are looking for by saying, find events nearby or find events this weekend");
});

// FindEventsIntent
app.intent('FindEventsIntent', function(request,response) {
	FindEventsIntent.init(request,response);
	
  return false;
});

// Connect to AWS Lambda
exports.handler = app.lambda();
Example #18
0
    if (_.isUndefined(request.session(RIDE_SESSION_KEY))){
      data = request.session(RIDE_SESSION_KEY);
    }
    return new RideHelper(data);
  });
};

skillService.launch(function(request, response) {
  console.log("Fired 'launch'.");
  getRideHelper(request).then(function(helper){
    if (!helper.zipcode){
      var prompt = "Welcome to Ride. I can tell you if you should ride your bike today. To start, please tell me your zipcode.";
      response.say(prompt).shouldEndSession(false);
      response.send();
    } else {
      helper.getWeather().then(function(data) {
        var responseObject = helper.generateResponse(data);
        response.say(responseObject.speech).send();
        response.shouldEndSession(true);
        response.send();
      });
    }
  });
  return false;
});

skillService.intent("AMAZON.HelpIntent", {},
  function(request, response) {
    console.log("Fired 'AMAZON.HelpIntent'.");
    getRideHelper(request).then(function(helper){
      var help = "This is 'Should I Ride', the skill that let's me tell you whether or not you should ride your bike today.";
      if (helper.zipcode !== null) {
Example #19
0
var alexa = require('alexa-app');

// Allow this module to be reloaded by hotswap when changed
module.change_code = 1;

// Define an alexa-app
var app = new alexa.app('number_guessing_game');

app.launch(function(req, res) {
  var number = Math.floor(Math.random() * 99) + 1;
  res.session('number', number);
  res.session('guesses', 0);
  var prompt = "Guess a number between 1 and 100!";
  res.say(prompt).reprompt(prompt).shouldEndSession(false);
});

app.intent('GuessIntent', {
    "slots": { "guess": "NUMBER" },
    "utterances": ["{1-100|guess}"]
  },
  function(req, res) {
    var guesses = (+req.session('guesses')) + 1;
    var guess = req.slot('guess');
    var number = +req.session('number');
    if (!guess) {
      res.say("Sorry, I didn't hear a number. The number was " + number);
    } else if (guess == number) {
      res.say("Congratulations, you guessed the number in " + guesses + (guesses == 1 ? " try" : " tries"));
    } else {
      if (guess > number) {
        res.say("Guess lower");
Example #20
0
// Allow this module to be reloaded by hotswap when changed
module.change_code = 1;

// Define an alexa-app
var app = new alexa.app('cavemaster');

//var caveMasterTemplate = new CaveMaster();
//var allActionWords = CaveMaster.getAllActions(CaveMaster.createRooms());

app.launch(function (req, res) {


    var caveMaster = new CaveMaster();
    var currentRoom = caveMaster.currentRoom;
    var sndPath = encodeURI('https://jimmyalexaskills.azurewebsites.net/' + caveMaster.currentRoom.soundPath);

    res.shouldEndSession(false);
    res.session("currentRoom", currentRoom.name);
    res.say("<audio src='" + sndPath + "' />");

    //  res.say("<audio src='https://jimmyalexaskills.azurewebsites.net/output.mp3' />");

});
var getAllActions = function () {
    var caveMasterTemplate = new CaveMaster();
    var allActionWords = caveMasterTemplate.getAllActions();
    return allActionWords.join("|");
}
app.intent('ActionIntent', {
    "slots": { "ACTION": "LITERAL" }
    , "utterances": ["{" + getAllActions() + "|ACTION} "]
}, function (req, res) {
Example #21
0
var alexa = require('alexa-app');
var api = require('./api');


// Allow this module to be reloaded by hotswap when changed
module.change_code = 1;

// Define an alexa-app
var app = new alexa.app('iot');
app.launch(function(req,res) {
	console.log("IOT Starting");
	res.say("This is the IOT app");
});

app.dictionary = { "pinStates":["on","off"]};

app.intent('SetPinIntent', {
	"slots": {"PIN_STATE":"PIN_STATES","PIN_NAME":"PIN_NAMES","ROOM":"ROOMS"},
	"utterances": [
		"turn {-|PIN_STATE} the {-|PIN_NAME} {light|pin|one} in the {-|ROOM}",
		"turn {-|PIN_STATE} the {-|ROOM} {-|PIN_NAME} {light|pin|one}",
		"set the {-|ROOM} {-|PIN_NAME} {light|pin|one} to {-|PIN_STATE}",
		"turn the {-|ROOM} {-|PIN_NAME} {light|pin|one} {-|PIN_STATE}"
	]
	}, function(req,res) {
		var pinValue = req.slot('PIN_STATE');
		var pinAlias = req.slot('PIN_NAME');
		var deviceAlias = req.slot('ROOM');
		res.say("OK, I'll turn "+pinValue+" the "+pinAlias+" one on the "+deviceAlias+" thing.");
		doPin(deviceAlias,pinAlias,pinValue, function(err,response) {
			if(err) {
    response.shouldEndSession(true);
  } else {
    if (stepValue !== undefined) {
      madlibHelper.currentStep++;
    }
    response.say("Give me " + madlibHelper.getPrompt());
    response.reprompt("I didn't hear anything. Give me " + madlibHelper.getPrompt() + " to continue.");
    response.shouldEndSession(false);
  }
  response.session(MADLIB_BUILDER_SESSION_KEY, madlibHelper);
  response.send();
};

skillService.launch(function(request, response) {
  var prompt = "Welcome to Madlibbuilder." +
    "To create a new madlib, say create a madlib";
  response.say(prompt).shouldEndSession(false);
});

skillService.intent("AMAZON.HelpIntent", {},
  function(request, response) {
    var madlibHelper = getMadlibHelper(request);
    var help = "Welcome to madlibbuilder." +
      "To start a new madlib, say create a madlib." +
      "You can also say stop or cancel to exit.";
    if (madlibHelper.started) {
      help = madlibHelper.getStep().help;
    }
    response.say(help).shouldEndSession(false);
  });
Example #23
0
var _ = require('lodash');
var Alexa = require('alexa-app');
var app = new Alexa.app('shakespeare');
var DataHelper = require('./data_helper');
var Quotes = require('./quote.json');
var mathRandom = require('./math_random');
var index=0;
var randoms =[];

app.launch(function(req, res) {
    var prompt = "Here is a famous quote from Shakespeare. ";
    randoms = new mathRandom().randomGenerator(Quotes.length);
    res.session('randoms',randoms);
    res.session('index',0);


    var helper = new DataHelper();
    var sharespeareQuote =helper.formatQuote(helper.requestQuote(randoms, index)) ;
    prompt += sharespeareQuote;
    prompt += " Would you like another quote? ";
    res.say(prompt).reprompt(prompt).shouldEndSession(false);
});


app.intent('AMAZON.YesIntent', function (req, res){
    console.log(req);

    var index =  1;
    var randoms =  [];
    if (req.session && req.session.attributes) {
        index = parseInt(req.session.attributes.index);
Example #24
0
  prompt = 'With CARVIS you can order the cheapest or fastest car available. For example, you can say, CARVIS, find me the cheapest ride to Hack Reactor';
  reprompt = 'Tell me to book the cheapest or fastest car, and where you want to go';
  helpSpeech = 'CARVIS finds you the cheapest and/or fastest ride to your destination. ';
  helpSpeech += 'To begin, tell me to book the cheapest or fastest car, and where you want to go';
  utterances = ['{Find|Get|Order|Call|Book} {a|one|the|me the|me a} {MODE} {car|ride} to {DESTINATION}'];

  slots = {
    'MODE': 'MODE',
    'DESTINATION': 'DESTINATION',
    'DESTINATION_ONE': 'DESTINATION_ONE',
  };
}

app.launch(function (req, res) {
  res.say(prompt)
    .reprompt(reprompt)
    .shouldEndSession(false);
});

app.intent('GetEstimate', {
    'slots': slots,
    'utterances': utterances
  },
  function (req, res) {
    var slots = req.data.request.intent.slots;
    console.log('slots:', slots);
    var userId = req.userId; // the unique alexa session userId
    var mode = (staging) ? 'cheapest' : req.slot('MODE'); // cheapest or fastest

    // find the ORIGIN slot that is populated in this request, if any
    var originArray = _.filter(slots, function (slotValue, slotKey) {
'use strict';
module.change_code = 1;
var _ = require('lodash');
var Alexa = require('alexa-app');
var app = new Alexa.app('airportinfo');
var FAADataHelper = require('./faa_data_helper');

app.launch(function(req, res) {
  var prompt = 'For delay information, tell me an Airport code.';
  res.say(prompt).reprompt(prompt).shouldEndSession(false);
});

app.intent('airportinfo', {
  'slots': {
    'AIRPORTCODE': 'FAACODES'
  },
  'utterances': ['{|flight|airport} {|delay|status} {|info} {|for} {-|AIRPORTCODE}']
},
  function(req, res) {
    //get the slot
    var airportCode = req.slot('AIRPORTCODE');
	console.log("The airport code is"+airportCode);
    var reprompt = 'Tell me an airport code to get delay information.';
if (_.isEmpty(airportCode)) {
      var prompt = 'I didn\'t hear an airport code. Tell me an airport code.';
      res.say(prompt).reprompt(reprompt).shouldEndSession(false);
      return true;
    } else {
      var faaHelper = new FAADataHelper();

faaHelper.requestAirportStatus(airportCode).then(function(airportStatus) {
Example #26
0
module.change_code = 1;

var _ = require('lodash');

var Alexa = require('alexa-app');

var app = new Alexa.app('airportinfo');

var FAADataHelper = require('./faa_data_helper');

app.launch(function(req, res){ //this method get triggered when skill is invoked 
    var prompt = 'For delay information, tell me an Airport code.';
    
    res.say(prompt).reprompt(prompt).shouldEndSession(false); //reprompt when to expect response from user
    														  //shouldEndSession stays open to recieve user message 
    
    
    
});

app.intent('airportinfo', {
	'slots' : {
		'AIRPORTCODE' : 'FAACODES'

	},

	'utterances': ['{|flight|airport} {|delay|status} {|info} {|for} {-|AIRPORTCODE}']

	},
var alexa = require('alexa-app');


// Allow this module to be reloaded by hotswap when changed
module.change_code = 1;

// Define an alexa-app
var app = new alexa.app('facialrecognition');

var Client = require('node-rest-client').Client;

var client = new Client();

app.launch(function(request,response){
    var prompt = "Hello, what would you like me to do?";
    response.say(prompt).reprompt(prompt).shouldEndSession(false);
});

app.intent('retrieveFaceIntent', {
    "utterances": [
        "Recognise me"
    ]
}, function(request, response) {

    var url = "http://ec2-54-210-185-131.compute-1.amazonaws.com/WebServer/rest/image/name";

    client.get(url, function (data, callback) {
        console.log(data);

        var name = data.name;
        var confidence = data.confidence;
Example #28
0
var alexa = require('alexa-app');
var http = require('http');
var app = new alexa.app();

/**
 * LaunchRequest.
 */
app.launch(function(request,response) {
  var greeting = "Welcome to reminders. You can ask me to remind you to do things by saying something like, Jeeves, remind me to make dinner at six pm.";
  var card = {
    type: "Simple",
    title: "Reminders",
    content: greeting
  };
	response.say(greeting);
	response.card(card.title, card.content);
  response.shouldEndSession(false);
});


/**
 * IntentRequest.
 */
app.intent('ScheduleReminderIntent',
  {
    'slots':{
      'REMINDER':'LIST_OF_REMINDERS',
      'DATE': 'AMAZON.DATE',
      'TIME': 'AMAZON.TIME'
    },
    'utterances':[
Example #29
0
// Verify incoming Alexa requests
app.use((req, res, next) => {
  if (!req.headers.signaturecertchainurl) {
    return next();
  }
  var { signaturecertchainurl: cert, signature } = req.headers;
  verifier(cert, signature, JSON.stringify(req.body), (err) => {
    if (err) return next(err);
    console.log("Verified Alexa request!");
    next();
  });
});

alexaApp.launch((req, res) => {
  res.say("Welcome to the Developer Toolbelt!");
});

for (var intent in speech) {
  console.log("Registering " + intent + " intent");
  alexaApp.intent(intent, speech[intent], handlers[intent]);
}

alexaApp.express(app, "/alexa/");

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  var err = new Error('Not Found');
  err.status = 404;
  next(err);
});
Example #30
0
    "{guns|drugs|blood|homeless people|NAME}"
  ],
}, (request, response) => {
  response.say(`what type of ${request.slot('NAME')} do you want?`)
  response.shouldEndSession(false)
})

alexaApp.intent('specify', {
  slots: { "TYPE": "LITERAL" },
  utterances: ["{I'll take|maybe|} {human|TYPE} {blood please|}"]
}, (request, response) => {
  response.say('I too hunger for blood. A drone is headed your way with 10 pints')
})

alexaApp.launch((request, response) => {
  response.say('welcome to the black market! right now we have guns, drugs, blood, and homeless people. Which are you interested in?')
  response.shouldEndSession(false)
})

// start app

alexaApp.express(app, '/echo/')

app.post('/echo/sample', ({ body }, res) => {
  alexaApp
    .request(body)
    .then((response) => res.json(response))
})

app.listen(PORT, () => console.log('started :)'))