alexa在node.js中实现CanFulfillIntentRequest

时间:2018-09-11 11:51:26

标签: alexa-skill alexa-sdk-nodejs

Alexa最近针对自定义技能发布了CanFulfillIntentRequest功能或无名称交互。我正在尝试使用alexa-sdk的现有技能来实现它。请在下面找到我的代码:

'use strict';
const Alexa = require('alexa-sdk');

var handlers = {
    'LaunchRequest': function() {
        var speechOutput = "You can ask me to read out quotes from Steve Jobs";
        var repromptText = "Sorry I didnt understand";
        this.emit(':tell', speechOutput, repromptText);
    },
    'RandomQuote': function() {
        let data = getQuoteFunction();
        const author = data[0];
        const quote = data[1];

        let cardTitle = "Quotation from author";
        let cardContent = "Actual quote";
        let speechOutput = "Actual quote";

        // Speak out the output along with card information
        this.emit(':tellWithCard', speechOutput, cardTitle, cardContent);   
    }    
}

exports.handler = function (event, context, callback) {
    const alexa = Alexa.handler(event, context, callback);
    alexa.registerHandlers(handlers);
    alexa.execute();
};

我们是否需要像我对其他处理程序所做的那样为CanFulfillIntentRequest添加处理程序?例如:

var handlers = {
    'LaunchRequest': function() {
    },
    'RandomQuote': function() {
    },
    'CanFulfillIntentRequest': function() {
        //code to handle
    }
}

此功能仅在Node.js的ASK SDK v2中可用吗?我们可以用使用Alexa-SDK开发的技能来实现它吗?有人可以让我知道吗?

谢谢

0 个答案:

没有答案