【发布时间】:2020-05-23 17:53:48
【问题描述】:
我正在用 Python 开发 Alexa 技能,我需要为用户动态添加实体以更新插槽类型,以便用户可以选择一个选项。
我的页面 Use Dynamic Entities for Customized Interactions 有 Node.js 和 Java 的文档和示例,但没有 Python 的示例。查看 Python SDK 的 Documentation,我不清楚如何在 Python 中做同样的事情。
我创建了一个名为 test 的 Slot Type 并尝试了以下代码:
test_directive = {"object_type": "Dialog.UpdateDynamicEntities", "update_behavior": "REPLACE", "types": [{"name": "test", "values": [{"id": "round-rock", "name": {"value": "Round Rock Express", "synonyms": ["Round Rock", "Express"]}}, {"id": "corpus-christi", "name": {"value": "Corpus Christi Hooks", "synonyms": ["Corpus Christi", "Hooks", "Corpus"]}}]}]}
response_builder.add_directive(test_directive)
但我得到了错误:
'dict' object has no attribute 'object_type'
在 Python 中添加动态实体的正确方法是什么?
【问题讨论】:
标签: python amazon-web-services alexa alexa-skills-kit