我正在使用Alexa技能套件,因为我想访问用户所说的文本。我安装了ask-sdk来帮助我做到这一点。下面的代码是我从ask-sdk对get_slot
的调用
28 @ask.intent('MoveIntent')
29 def send_action(self, handler_input):
30 #publish_movement()
31 nameVal = get_slot_value(handler_input, slot_name="name")
32 action_msg = 'Taking you to {}'.format(nameVal)
33 return statement(action_msg)
这是我得到的错误:
File "/Users/aramis/env/lib/python3.7/site-packages/ask_sdk_core/utils/request_util.py", line 214, in get_slot
request = handler_input.request_envelope.request
AttributeError: 'NoneType' object has no attribute 'request_envelope'
在get_slot
中发生,这在get_slot_value
中称为。以下是get_slot
中的代码:
214 request = handler_input.request_envelope.request
215 if isinstance(request, IntentRequest):
216 if request.intent.slots is not None:
217 return request.intent.slots.get(slot_name, None)
218 else:
219 return None
220
221 raise TypeError("The provided request is not an IntentRequest")
[有人可以帮我理解为什么我会收到此错误的信息。我不知道None类型对象是什么。
此链接上称为“从请求获取插槽值”的部分说,它使用Alexa sdk对此。https://developer.amazon.com/docs/custom-skills/handle-requests-sent-by-alexa.html
这是Alexa-sdk的链接https://alexa-skills-kit-python-sdk.readthedocs.io/en/latest/GETTING_STARTED.html
您能解决吗?我正面临着同样的错误