Skip to content

Instantly share code, notes, and snippets.

@harveyslash
Created February 8, 2017 21:53
Show Gist options
  • Save harveyslash/62c138df8bbbb81fa0351e461d16a988 to your computer and use it in GitHub Desktop.
Save harveyslash/62c138df8bbbb81fa0351e461d16a988 to your computer and use it in GitHub Desktop.
/* eslint-disable func-names */
/* eslint quote-props: ["error", "consistent"]*/
/**
* This sample demonstrates a simple skill built with the Amazon Alexa Skills
* nodejs skill development kit.
* This sample supports multiple lauguages. (en-US, en-GB, de-DE).
* The Intent Schema, Custom Slots and Sample Utterances for this skill, as well
* as testing instructions are located at https://github.com/alexa/skill-sample-nodejs-fact
**/
'use strict';
const Alexa = require('alexa-sdk');
const request = require('request');
const APP_ID = "amzn1.ask.skill.b7e70429-f9fa-4318-9a35-2acd3e7ab45f"; // TODO replace with your app ID (OPTIONAL).
var handlers = {
'HelloWorldIntent': function () {
let that = this;
request('http://api.openweathermap.org/data/2.5/weather?q=London,uk&APPID=9aa2a9582d72ef0179f13e3fcf9821bd',
function(error,response,body) {
console.log(response.statusCode); // 200
console.log(response.headers['content-type']); // 'image/png'
console.log("LOGGING ",body); // 'image/png'
let bodyJson = JSON.parse(body);
let resp = bodyJson.weather[0].description;
that.emit(":tell",resp);
});
// this.emit(':tell', 'Hello World!');
}
};
exports.handler = (event, context) => {
const alexa = Alexa.handler(event, context);
alexa.appId = APP_ID;
alexa.APP_ID = APP_ID;
// To enable string internationalization (i18n) features, set a resources object.
// alexa.resources = languageStrings;
alexa.registerHandlers(handlers);
alexa.execute();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment