私はAlexaのデバイスがgoogleのニュースAPIからタイトルを読み上げるAlexaのスキルを作ろうとしています。私はJSON urlを持っていて、タイトルを解析してAlexaデバイスで読むことができるように関数を作りたいと思っています。ここでは、これまでの私のコードは次のとおりです。あなたは、APIへのリクエストを行い、アレクサさんのtell機能にその結果を使用する必要がAlexaのスキルをJSONデータ(node.js)を読み込むには?
/**
* 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);
};
実行している/質問している特定の問題はありますか? – httpNick
@httpNick私は、ニュース記事のタイトルしか持たないように、URLからデータを解析しようとしています。それについてどうすればいいですか? –