【问题标题】:Keeping Alexa session open between intents在意图之间保持 Alexa 会话打开
【发布时间】:2021-04-09 13:05:32
【问题描述】:

我拥有具有多种意图的 Alexa 技能和使用 Python SDK 构建的客户后端。我目前可以在我的扬声器上使用该技能。我想尝试解决的问题是保持会话打开,或者在意图之间保持扬声器上的蓝灯。所以而不是:

Me: Alexa, start the quiz 
Alexa: Hi, tell me your name 
Me: my name is Jeff 
Alexa: Nice to meet you Jeff, where are you from? 
Me: Alexa, I'm from Texas

^ 在给她我的名字后想要使用 CaptureCustomerLivingIntentHandler() 类时,我需要叫醒说话者告诉她我来自哪里。我想让演讲者听​​听下一个意图。如下所示:

Me: Alexa, start the quiz
Alexa: Hi, please tell me your name
Me: My name is Jeff
Alexa: Nice to meet you Jeff, where are you from?
Me: I'm from Texas

我需要在我的代码中添加什么来让扬声器在每个意图之间保持开启,这样扬声器就不会关闭?我尝试找到一些有关此的文档,但找不到可以解释如何使用 Python 作为后端来构建技能的解决此问题的内容。

【问题讨论】:

    标签: python alexa alexa-skill


    【解决方案1】:

    如果您想保持会话打开,您需要在响应中包含shouldEndSession 参数,并确保将其设置为False

    在 Python 中,这可能如下所示:

    {
      "version": "1.0",
      "response": {
        "outputSpeech": {
          "type": "PlainText",
          "text": "Nice to meet you Jeff, where are you from?", 
        },
        "shouldEndSession": False,
    }
    

    或者如果使用 ASK SDK for Python:

    handler_input.response_builder.speak(
        "Nice to meet you Jeff, where are you from?").set_should_end_session(False).response
    
    

    重要的是要指出,当您保持会话打开时,亚马逊指南规定需要确保您提示用户提供更多输入(即向用户提问)——您在示例中正确地这样做了。

    您可能已经看过这里,但认为值得专门链接到有关 managing the skill session 的文档。

    【讨论】:

    • 感谢您的详尽解释。这正是我所需要的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-28
    相关资源
    最近更新 更多