【问题标题】:How to loop back to a previous intent depending on users input?如何根据用户输入循环回到先前的意图?
【发布时间】:2018-11-26 22:17:52
【问题描述】:

我的意图是提出是/否问题。如果用户说“不”,他们会接受一系列问题,最后一个问题还是一个是/否问题。在回答“否”时,我希望循环重新开始。我已经试过here提供的解决方案,还是不行。

【问题讨论】:

    标签: python dialogflow-es facebook-chatbot


    【解决方案1】:

    该链接上给出的上下文技巧应该可以工作,您只需要正确处理上下文和响应,请考虑以下示例系列的意图

    - intent that asks yes/no question (say 'question X')    <--[set the output context (say 'loop-back')]
    |
    |--- intent that accepts 'no' as user input    <--[set 'loop-back' context as input context for this]
       |
       |--- chain of questions...
          |
          |--- last yes/no question
             |
             |--- intent that accepts 'no' as user input    <--[set the output context 'loop-back']
                  [response from agent should be the same yes/no question 'questionX']
                |
                |--- [if user replies 'no' the loop continues...]
    

    确保正确设置上下文“回送”的生命周期(可能是 1/2),这样它就不会被存储太久。

    这里我们从“questionX”开始,最后一个意图给出响应为“questionX”。实际上,开始(是/否 questionX)意图永远不会再次被触发,但是接受“否”之后的意图由于上下文而被触发,这会创建正确的循环:)


    看看这个例子是否有帮助,

    - [start intent fires]
      {intent A}
      Agent("are you afraid to talk to me ?")    <--[set the output context (say 'loop-back')]
    |
    |{intent B}
    |--- User("no")
         Agent("What are you afraid of then ?")    <--[set 'loop-back' context as input context for this]
       |
       |{intent C}
       |--- User("nothing")
            Agent("more questions")
          |
          |{intent D}
          |--- User("more answers")
               Agent("are you afraid to talk to daemons ?")
             |
             |{intent E}
             |--- User("no")
                  Agent("and are you afraid to talk to me ?")    <--[set the output context 'loop-back']
                |
                |{intent B}
                |--- User("no")
                     Agent("What are you afraid of then ?")
                     [and the loop continues...]
    

    看看两个 [set output context] (intent A & E) 行,它们都有相同的代理响应,这会创建一个循环...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-12
      • 1970-01-01
      • 2022-12-12
      • 1970-01-01
      相关资源
      最近更新 更多