【发布时间】:2021-05-09 19:21:40
【问题描述】:
我正在研究一个玩具 Alexa 技能,我正在按照数字猜谜游戏 (code here) 中的示例进行操作。在示例中他们
from ask_sdk_core.handler_input import HandlerInput
@sb.request_handler(can_handle_func=is_request_type("LaunchRequest"))
def launch_request_handler(handler_input):
"""Handler for Skill Launch.
Get the persistence attributes, to figure out the game state.
"""
# type: (HandlerInput) -> Response
attr = handler_input.attributes_manager.persistent_attributes
这个attr 对象允许我在整个会话中保留信息。在 Alexa 开发人员控制台中,我在 JSON 中的 'session':'attributes' 下看到了这些数据 - 我还看到了 'session':'user':'userId'
如何使用此函数中的 handler_input 访问 userId 数据?
【问题讨论】: