【发布时间】:2021-01-20 07:10:00
【问题描述】:
我正在使用 alexa 开发我的第一个技能并且我正在使用插槽,但是在插槽响应方面我遇到了一个小问题。我有错误 ask_sdk_runtime.exceptions.DispatchException: Unable to find a suitable request handler 我该如何解决?
【问题讨论】:
标签: python python-3.x alexa-skills-kit alexa-slot
我正在使用 alexa 开发我的第一个技能并且我正在使用插槽,但是在插槽响应方面我遇到了一个小问题。我有错误 ask_sdk_runtime.exceptions.DispatchException: Unable to find a suitable request handler 我该如何解决?
【问题讨论】:
标签: python python-3.x alexa-skills-kit alexa-slot
我建议添加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
【讨论】: