Ich bekomme ein Problem mit dem folgenden Code mit Amazon Lambda und dem Alexa Skills Kit. Ich habe unzählige Stunden damit verbracht und kann es nicht zur Arbeit bringen. Ich bekomme diese Nachricht immer wieder und kann nicht herausfinden, warum der http get fehlschlägt. "Bitte versuche es später noch einmal". Es druckt nicht einmal die Konsolenmeldungen.Amazon AWS Lambda Alexa HTTP Problem
var Alexa = require('alexa-sdk');
var http = require('http');
var APP_ID = "omitted";
var SKILL_NAME = 'omitted';
var options = {
host: 'api.forismatic.com',
path: '/api/1.0/?method=getQuote&lang=en&format=text',
method: 'GET'
};
exports.handler = function(event, context, callback) {
var alexa = Alexa.handler(event, context);
alexa.APP_ID = APP_ID;
alexa.registerHandlers(handlers);
alexa.execute();
};
var handlers = {
'LaunchRequest': function() {
this.emit('Inspiration');
},
'IntentRequest': function() {
this.emit('Inspiration');
},
'InspirationIntent': function() {
this.emit('Inspiration');
},
'Inspiration': function() {
var speechOutput = '';
var text = '';
http.get(options, function(res) {
console.error("Got response: " + res.statusCode);
res.on("data", function(chunk) {
console.error("BODY: " + chunk);
text = chunk;
});
}).on('error', function(e) {
text = 'error' + e.message;
console.error("Got error: " + e.message);
});
if(text == ''){
speechOutput = "Please try again later";
}
else{speechOutput = text;}
this.emit(':tellWithCard', speechOutput, SKILL_NAME, text);
},
'AMAZON.HelpIntent': function() {
var speechOutput = "You can ask Inspirational Quote for some advice.";
var reprompt = "What would you like me to do?";
this.emit(':ask', speechOutput, reprompt);
},
'AMAZON.CancelIntent': function() {
this.emit(':tell', 'Goodbye!');
},
'AMAZON.StopIntent': function() {
this.emit(':tell', 'Goodbye!');
},
'Unhandled': function() {
this.emit('AMAZON.HelpIntent');
}
};
Dank. Das hat es getan – logepoge1