来自webhook的dialogflow触发事件

Sto*_*son 3 actions-on-google dialogflow-es

我有一个意图I1与动作x和一个意图I2调用webhook.

有没有办法从I2 webhook响应中触发x,以便在webhook给出答案后将用户"重定向"到I1?

有没有办法从dialogflow控制台这样做?

编辑:添加图表以进一步说明.处理"否"后续部分的正确方法是什么?

在此输入图像描述

Pri*_*ner 10

意图代表用户的输入(通常是他们所说的),而不是你"正在做什么".

虽然您可以从webhook(例如I2处理程序)重定向到事件(可能由I1选取),但您无法在"webhook"回复之后执行此操作.这将取代webhook的结果.(尽管可能,但通常不是解决问题的最佳方法.)

您也无法通过Dialogflow配置执行此操作.必须通过webhook完成.

根据您的图表进行更新.

您的图表说明了为什么我们鼓励人们考虑对话和用户说的内容,而不是"我们做什么".会话图与流程图并不完全相同.让我重新构建一些脚本(稍后我们将对其进行注释).

脚本1:

User:  Talk to number or letter
Agent: Welcome! Would you like to hear a number or letter? 
User:  How about a number
Agent: 1 is the loneliest number. Would you like another?
User:  Yes
Agent: 2 is the only even prime. Care for another?
User:  No
Agent: Ok, would you like to hear a number or letter?
Run Code Online (Sandbox Code Playgroud)

脚本2:

User:  Talk to number or letter
Agent: Welcome! Would you like to hear a number or a letter?
User:  Number, please
Agent: 42 is the answer Another one, so to speak?
User:  sure
Agent: 21 is blackjack. Care for another?
User:  nope
Agent: Ok, care for a letter or a number?
Run Code Online (Sandbox Code Playgroud)

脚本3:

User:  Talk to number or letter
Agent: Howdy! Would you like a letter or a number?
User:  Let's go for a number
Agent: A googol is 10 to the 100th power. Ready for another?
User:  How about a letter this time
Agent: The letter "A" is one of only two letters that are also words. Want another?
Run Code Online (Sandbox Code Playgroud)

从中可以了解到以下几点:

  • 当被问到一个问题时,人们以许多不同的方式回应 意图使用许多示例短语,加上一些ML算法,以匹配用户所说的内容以及他们如何回复.
  • 在真实的对话中,用户可以在任何方向上进行对话.因此,虽然我们已经问过是或否的问题,但他们可能会尝试以完全不同的方向进行对话.
  • 我们如何回复取决于两件事:
    1. 我们处于什么状态
    2. 用户说的是什么
  • 上述第(1)点的结果是我们应该跟踪用户的状态以确定我们所说的内容,因此即使用户没有看到,新状态也会成为回复的一部分.

有了这个,让我们添加更多信息,看看Intent会匹配什么,然后我们的webhook会做什么 - 无论是状态集还是发送的回复.

脚本1:

User:  Talk to number or letter
Match: intent.welcome
Logic: Set replyState to "prompt"
       Pick a response for the current replyState ("prompt")
       and the intent that was matched ("intent.welcome")
Agent: Welcome! Would you like to hear a number or letter? 

User:  How about a number
Match: intent.number
Logic: Set replyState to "number"
       Pick a response for the current replyState ("number")
Agent: 1 is the loneliest number. Would you like another?

User:  Yes
Match: intent.yes
Logic: Pick a response for the current replyState ("number")
Agent: 2 is the only even prime. Care for another?

User:  No
Match: intent.no
Logic: Set replyState to "prompt"
       Pick a response for the current replyState ("prompt")
       and the intent that was matched (not "intent.welcome")
Agent: Ok, would you like to hear a number or letter?
Run Code Online (Sandbox Code Playgroud)

有了这个,我们可以看到我们的回复是基于当前状态和用户意图的组合.(我们的状态可能更复杂,要跟踪用户听到的内容,他们访问了多少次等等.这非常简单.)

我们也看到"是"不会改变国家.它不需要.

如果我们看一下脚本2,我们会看到它的相同之处:

User:  Talk to number or letter
Match: intent.welcome
Logic: Set replyState to "prompt"
       Pick a response for the current replyState ("prompt")
       and the intent that was matched ("intent.welcome")
Agent: Welcome! Would you like to hear a number or a letter?

User:  Number, please
Match: intent.number
Logic: Set replyState to "number"
       Pick a response for the current replyState ("number")
Agent: 42 is the answer Another one, so to speak?

User:  sure
Match: intent.yes
Logic: Pick a response for the current replyState ("number")
Agent: 21 is blackjack. Care for another?

User:  nope
Match: intent.no
Logic: Set replyState to "prompt"
       Pick a response for the current replyState ("prompt")
       and the intent that was matched (not "intent.welcome")
Agent: Ok, care for a letter or a number?
Run Code Online (Sandbox Code Playgroud)

事实上,如果你看一下"匹配"和"逻辑"部分,就程序而言,它们是相同的对话.唯一的区别是用户使用的确切单词和我们回复的确切短语.从根本上说,它们是完全相同的对话.

这在脚本3中是如何发挥作用的?

User:  Talk to number or letter
Match: intent.welcome
Logic: Set replyState to "prompt"
       Pick a response for the current replyState ("prompt")
       and the intent that was matched ("intent.welcome")
Agent: Howdy! Would you like a letter or a number?

User:  Let's go for a number
Match: intent.number
Logic: Set replyState to "number"
       Pick a response for the current replyState ("number")
Agent: A googol is 10 to the 100th power. Ready for another?

User:  How about a letter this time
Match: intent.letter
Logic: Set replyState to "letter"
       Pick a response for the current replyState ("letter")
Agent: The letter "A" is one of only two letters that are also words. Want another?
Run Code Online (Sandbox Code Playgroud)

在这里,用户突然要求我们跳到完全不同的状态.但这不是问题 - Dialogflow只是看到了这一点,就好像他们从提示问题请求该状态并且处理程序对此做出同样的反应.

因此,我们不是必须构建许多后续意图,而是要捕获用户所说的内容,然后使用我们的webhook基于此更改状态.