Currently, I am working on a project to develop an Alexa skill that can read out the headlines from the Google News API. I have obtained a JSON URL and now I am trying to create a function that can extract and read the titles using the Alexa device. Here is what I have coded so far: (I still need to add the main function with JSON parsing)
/**
* Skill's App ID
*/
var APP_ID = undefined;
/**
* The AlexaSkill prototype and helper functions
*/
var AlexaSkill = require('./AlexaSkill');
var News = function () {
AlexaSkill.call(this, APP_ID);
};
// Extend AlexaSkill
News.prototype = Object.create(AlexaSkill.prototype);
News.prototype.constructor = News;
News.prototype.eventHandlers.onSessionStarted = function (sessionStartedRequest, session) {
};
News.prototype.eventHandlers.onLaunch = function (launchRequest, session, response) {
handleNewsRequest(response);
};
News.prototype.eventHandlers.onSessionEnded = function (sessionEndedRequest, session) {
};
News.prototype.intentHandlers = {
"NewsIntent": function (intent, session, response) {
handleNewsRequest(response);
},
"AMAZON.HelpIntent": function (intent, session, response) {
response.ask("You can ask me for the latest news headlines in the world right now. Simply ask Top News for the latest news.");
},
"AMAZON.StopIntent": function (intent, session, response) {
var speechOutput = "Goodbye";
response.tell(speechOutput);
},
"AMAZON.CancelIntent": function (intent, session, response) {
var speechOutput = "Goodbye";
response.tell(speechOutput);
}
};
/**
* News API
*/
function handleNewsRequest(response) {
/**
* This is where I need help!!!!!!!!
*/
// Create speech output
var speechOutput = ;
var cardTitle = "Top News";
response.tellWithCard(speechOutput, cardTitle, speechOutput);
}
// Create the handler that responds to the Alexa Request.
exports.handler = function (event, context) {
// Create an instance of the Top News skill.
var news = new News();
news.execute(event, context);
};