【问题标题】:Alexa: Chaining Intents with Dialog.Delegate and PythonAlexa:使用 Dialog.Delegate 和 Python 链接 Intent
【发布时间】:2019-09-17 09:50:31
【问题描述】:

我正在寻找一些示例代码,例如本文中描述的 nodejs 的示例代码:

https://developer.amazon.com/blogs/alexa/post/9ffdbddb-948a-4eff-8408-7e210282ed38/intent-chaining-for-alexa-skill

我试图调用另一个意图但没有成功

def handle(self, handler_input):
    #some code
    return handler_input.response_builder.add_directive(DelegateDirective(updated_intent= {"name":"OrderIntent", "confirmationStatus": "None", "slots" : {}}))

【问题讨论】:

    标签: python alexa alexa-skills-kit alexa-skill alexa-slot


    【解决方案1】:

    我知道这个问题是很久以前提出的。我认为发布答案可能对寻找基于 python 的 Alexa 问题的其他人有所帮助。

    经过大量测试,通过api docs,并试图自己解决这个问题,我想出了以下方法来让它工作。我个人的问题是我找到了一个解决方案here,它允许当前函数调用另一个意图的句柄函数;但是,这不会产生我需要的必需的强制插槽对话框。

    我的解决方案如下:

    from ask_sdk_model.dialog import delegate_directive
    from ask_sdk_model.intent import Intent
    
    def handle(self, handler_input):
        speak_output = "We're going to another intent"
        return handler_input.response_builder.speak(speak_output).add_directive(delegate_directive.DelegateDirective(updated_intent=Intent(name="<insert_intent_name>"))).response 
    
    

    只需将上述 sn-p 中的 &lt;insert_intent_name&gt; 更改为您尝试调用的任何意图。像这样调用它时,它会确保保持意图模型的所有部分都完好无损。 IE。如果您需要插槽,它们将像最初触发初始意图时一样被处理。

    注意:在测试过程中,我不断遇到错误,说明: [ERROR] AttributeError: 'ResponseFactory' object has no attribute deserialized_types'。我发现这是因为我没有在 return 语句的末尾添加.response

    它应该允许基于原始意图中的设置属性的 YesIntent 和 NoIntent 转换。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-13
      • 2019-01-14
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 2020-06-26
      相关资源
      最近更新 更多