这是我的代码:
'use strict';
const Alexa = require('alexa-sdk');
const APP_ID = undefined;
const skill_name = "Quote of the Day";
const kote = require('kote-api');
exports.handler = function(event, context, callback) {
var alexa = Alexa.handler(event, context);
alexa.appId = APP_ID;
alexa.registerHandlers(handlers);
alexa.execute();
};
var handlers =
{
'LaunchRequest': function ()
{
this.emit('QuoteOfDay');
},
'QuoteOfDay': function ()
{
var quoteDay = kote.goodReads().then(quote => {
this.emit(quote);
});
this.emit(':tellWithCard', quoteDay);
}
};
这是我的日志输出:
{
"version": "1.0",
"response": {
"shouldEndSession": true,
"outputSpeech": {
"type": "SSML",
"ssml": "<speak> [object Promise] </speak>"
}
},
"sessionAttributes": {}
}
答案 0 :(得分:0)
您应该将对象解析为JSON,然后再将其发回,如下所示
this.emit(JSON.parse(quote));