Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Aws lambda Alexa SDK v2的响应错误无效_Aws Lambda_Alexa_Alexa Skills Kit - Fatal编程技术网

Aws lambda Alexa SDK v2的响应错误无效

Aws lambda Alexa SDK v2的响应错误无效,aws-lambda,alexa,alexa-skills-kit,Aws Lambda,Alexa,Alexa Skills Kit,两天来,我一直担心使用ask sdk core v2.0.2的lambda函数返回无效响应 非常简单的设置: HelloIntent由HelloIntentHandler处理: const HelloIntentHandler = { canHandle(handlerInput) { return handlerInput.requestEnvelope.request.type === 'HelloIntent'; }, handle(handlerI

两天来,我一直担心使用ask sdk core v2.0.2的lambda函数返回无效响应

非常简单的设置:

HelloIntent
HelloIntentHandler
处理:

const HelloIntentHandler = {
    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'HelloIntent';
    },
    handle(handlerInput) {
        const speechText = 'Hello back';

        return handlerInput.responseBuilder
            .speak(speechText)
            .reprompt(speechText)
            .getResponse();
    }
};
当我称之为意图时,模拟器直接进入:

请求的技能的响应有问题

使用ErrorHandler,我进行了检查,
handlerInput.requestEnvelope.request.error的结果是:

{ type: 'INVALID_RESPONSE',
message: 'An exception occurred while dispatching the request to the skill.' }

问题:这里有什么问题?当我使用调用名称打开技能时,
LaunchRequestHandler
被调用并正确响应,但任何其他意图都不起作用。

好的,我发现了问题,很难从上述错误中扣除:

canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'IntentRequest'
        && handlerInput.requestEnvelope.request.intent.name === 'HelloIntent';
},
canHandle
函数中,需要检查请求类型和意图名称