我正在开发Python中的Alexa技能,我需要为用户动态添加实体来更新插槽类型,以便用户可以选择一个选项
I页面Use Dynamic Entities for Customized Interactions有Node.js和Java的文档和示例,但没有Python的示例。查看pythonsdk的Documentation,我不清楚如何在Python中执行同样的操作
我创建了一个名为test的插槽类型,并尝试了以下代码:
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中添加动态实体的正确方法是什么
我在链接中找到了答案:https://forums.developer.amazon.com/questions/210684/dynamic-entities-in-python.html。Python中的一个简短示例:
相关问题 更多 >
编程相关推荐