Alexa开发人员:永远不会在js处理程序中调用canHandle和handle函数

时间:2019-05-08 14:07:38

标签: node.js amazon-web-services aws-lambda alexa-app

所以我有我的应用程序,它可以正常运行,但是我想添加APL,以便用户在听声音的同时可以看到图像。

在每个教程中,我都看到它们有两个目的:

canHandle( handlerInput ) {
        return handlerInput.requestEnvelope.request.type === 'LaunchRequest';
}
handle( handlerInput ) {
    // Here we can greet the user or whatever, depending on the handler we're using.
}

在第二个功能中,有必要放置代码以检查用户是否可以查看设备中的图像,如果可以,则将json文档与图像一起添加,如下所示:

handle( handlerInput ) {
    if(supportsAPL(handlerInput)) {
        handlerInput.responseBuilder.addDirective({
            type: 'Alexa.Presentation.APL.RenderDocument',
            document: require('./launchrequest.json')
        })
    }
}

我现在的问题是,无论我在这些函数中放置什么内容,它都永远不会执行。我已经尝试使用日志和语音消息,但它们并未显示。

为什么会这样,为了使APL正常工作,我该怎么办?似乎我确实需要变量handlerInput。如果不通过这些功能,该怎么办?

0 个答案:

没有答案