0

Alexa 最近发布了自定义技能的 CanFulfillIntentRequest 功能或 Name-free Interaction。我正在尝试在我现有的使用 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
    }
}

此功能是否仅在 ASK SDK v2 for Node.js 中可用?我们可以在使用 alexa-sdk 开发的技能中实现它吗?谁能告诉我?

谢谢

4

0 回答 0