I'm working on an AWS Lambda function in Node.js to call a PHP URL that will return a JSON encoded response so that Alexa (Amazon Dot, etc.) can reply to a user query. I've got all my intents set up properly and Alexa (online test) replies to the question, but the tag contains "Unchanged" (see code), indicating it isn't getting anything from the http.get() function in Node.js.
Here's the function to get the text that Alexa should speak:
function getData(mypath) {
var http = require('http');
var options = {
host: 'www.gypsysticks.com',
port: 80,
path: mypath
};
var mydata = "Unchanged";
http.get(options, function(res) {
res.on("response", function(chunk) {
mydata = chunk;
});
});
return mydata;
}
I'm building this "Skill" for Alexa for my band, Gypsy Sticks. Currently the url and path points to www.gypsysticks.com/echo/tonight.php which is supposed to return the location and time of the show for tonight. Right not I've just got it returning a JSON string with { "response" : "Test Success" }
I'm not familiar with Node.js, or the http.get() function. Can someone help me figure out what I'm doing wrong?
via Richard Murff
No comments:
Post a Comment