Created
February 8, 2017 23:08
-
-
Save harveyslash/2ec9dcf5718e5eb00b2774488fe0dbb0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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; | |
let location = this.event.request.intent.slots.city.value; | |
console.log(location); | |
request('http://api.openweathermap.org/data/2.5/weather?q='+location+'&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