Ich versuche eine Alexa-Fähigkeit zu machen, in der das Alexa-Gerät die Titel aus der Google News API ausliest. Ich habe eine JSON url und ich möchte eine Funktion machen, damit der Titel vom Alexa-Gerät analysiert und gelesen werden kann. Hier ist mein Code so weit: (es ist die Hauptfunktion w/JSON und Sachen fehlt)Wie man eine Alexa Fähigkeit JSON Daten (node.js) auslesen lässt?
/**
* App ID for the skill
*/
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);
};
Gibt es ein bestimmtes Problem, in das Sie geraten sind? – httpNick
@httpNick Ich versuche, Daten von einer URL zu analysieren, so dass ich nur den Titel der Nachrichtenartikel habe. Wie gehe ich da vor? –