gpt4 book ai didi

dialogflow-es - 来自 webhook 的 dialogflow 触发事件

转载 作者:行者123 更新时间:2023-12-03 10:00:28 26 4
gpt4 key购买 nike

我有一个带有 Action x 的意图 I1 和一个调用 webhook 的意图 I2。

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

有没有办法从对话流控制台执行此操作?

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

enter image description here

最佳答案

意图代表用户的输入(通常是他们所说的),而不是您正在“做什么”。

虽然您可以从 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?

脚本 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?

脚本 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?

有几点可以借鉴:

  • 当被问到问题时,人们会以多种不同的方式做出回应。 Intent 使用许多示例短语以及一些 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?

这样,我们可以看到我们的回复是基于当前状态和用户意图的组合。 (我们的状态可能更复杂,以跟踪用户听到的内容、他们访问过的次数等。这非常简单。)

我们还看到"is"不会改变状态。不需要。

如果我们查看脚本 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?

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

这在脚本 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?

在这里,用户突然请求我们跳转到一个完全不同的状态。但这不是问题 - Dialogflow 只是看到这一点,就像他们从提示问题中请求该状态一样,并且该处理程序的 react 方式相同。

因此,我们的目标是捕捉用户所说的内容,然后使用我们的 webhook 来更改基于此的状态,而不是构建许多后续意图。

关于dialogflow-es - 来自 webhook 的 dialogflow 触发事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52672920/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com