ask_sdk_runtime.exceptions.DispatchException:无法找到合适的请求处理程序

问题描述

我正在使用Alexa开发我的第一项技能,并且正在使用插槽,但是在插槽响应方面我有一个小问题。并且出现错误ask_sdk_runtime.exceptions.dispatchException:无法找到合适的请求处理程序,我该如何解决

this is the error

解决方法

我建议添加一个 RequestInterceptor 来记录所有传入的请求。通过这种方式,您可以找出导致问题的请求类型。

示例代码:

class LogRequestInterceptor(AbstractRequestInterceptor):
    def process(self,handler_input):
        logger.info(f"Request type: {handler_input.request_envelope.request.object_type}")

然后像其他处理程序一样将其添加到您的技能构建器中: sb.add_global_request_interceptor(LogRequestInterceptor())

Python AbstractRequestInterceptor 文档:https://alexa-skills-kit-python-sdk.readthedocs.io/en/latest/api/core.html?highlight=requestinterceptor#ask_sdk_core.dispatch_components.request_components.AbstractRequestInterceptor