每当我想要获得当天的报价时,Alexa都会给我[对象产品]

时间:2017-10-08 00:15:14

标签: node.js lambda aws-lambda alexa-skills-kit

每当我试图用kote-api获得当天的报价时,Alexa就会给我[对象产品]。有办法解决这个问题吗?

这是我的代码:

'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": {}
}

1 个答案:

答案 0 :(得分:0)

您应该将对象解析为JSON,然后再将其发回,如下所示

this.emit(JSON.parse(quote));