来自webhook的dialogflow触发事件 [英] dialogflow trigger event from webhook

查看:104
本文介绍了来自webhook的dialogflow触发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有动作x的意图I1和一个称为Webhook的意图I2。

I have an intent I1 with action x and an intent I2 which calls a webhook.

是否有一种方法可以按顺序从I2 Webhook响应中触发x在Webhook给出答案之后将用户重定向到I1?

Is there a way to trigger x from the I2 webhook response, in order to "redirect" the user to I1 after the webhook has given its answer?

是否可以从dialogflow控制台中将其重定向到I1?

Is there a way to do so from the dialogflow console?

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

added diagram for further clarification. What is the correct way to handle the "no" followup part?

推荐答案

意图表示用户的输入(通常是他们说的话),而不是您在做什么。

Intents represent a user's input (typically what they say), not what you are "doing".

尽管您可以从一个Webhook(例如您的I2处理程序)重定向到一个事件(该事件可能被I1接收),但是您不能在Webhook回复之后执行该操作。这将替代webhook的结果。 (而且,虽然可能,但通常不是解决问题的最佳方法。)

Although you can redirect from a webhook (such as your I2 handler) to an event (which might be picked up by I1), you can't do it "after" the webhook replies. This would replace the result from the webhook. (And, while possible, it is usually not the best approach to a problem.)

您也无法从Dialogflow配置中执行此操作。

You also cannot do this from the Dialogflow configuration. It must be done through a webhook.

更新根据您的图表。

您的图表说明了为什么我们鼓励人们思考对话和用户所说的而不是我们做什么。会话图与流程图并不完全相同。让我将其重组为一些脚本(稍后将进行注释)。

Your diagram illustrates why we encourage people to think about conversations and what the user says rather than "what do we do". Conversation diagrams aren't quite the same as flow charts. Let me restructure that as a few scripts (which we will annotate later).

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

有一些要学习的地方:


  • 当被问到问题时,人们以多种不同的方式回应。意向使用许多示例短语以及一些ML算法,以使用户所说的内容与他们可以回复的方式相匹配。

  • 在实际对话中,用户可以沿任何方向进行对话。因此,尽管我们问的是或否,但他们可能会尝试朝着完全不同的方向进行对话。

  • 我们的回复方式取决于两件事:

  • People respond in many different ways when asked a question. Intents use many sample phrases, plus some ML algorithms, to match what the user says to how they can reply.
  • In real conversations, users can take the conversation in any direction. So although we've asked a yes or no question, they may try to take the conversation in a whole different direction instead.
  • How we reply depends on two things:

  1. 我们所处的状态

  2. 用户说的话


  • 上面第(1)点的结果是,我们应该跟踪用户的状态以确定我们所说的内容,因此即使用户没有看到,新的状态也成为答复的一部分。

  • 有了这一点,让我们添加更多的信息来了解Intent将被匹配,然后我们的网络钩子将做什么-两者都状态集并发送答复。

    With that, let's add a little more information to see what Intent would get matched and then what our webhook would do - both in terms of state set and the reply sent.

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

    有了这个,我们可以看到我们的回复是基于当前状态和用户的回复意图。 (我们的状态可能会更复杂,以跟踪用户所听到的内容,访问的次数等。这非常简化。)

    With this, we can see that our replies are based on a combination of the current state and the user's intent. (Our state could be more complex, to keep track of what the user has heard, how many times they've visited, etc. This is very simplified.)

    我们还可以看到是不会更改状态。

    We also see that "yes" doesn't change the state. It doesn't need to.

    如果我们看一下脚本2,我们会看到它的播放方式完全相同:

    If we look at script 2, we'll see it plays out identically:

    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?
    

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

    In fact, if you look at the "Match" and "Logic" parts, they are identical conversations as far as the program is concerned. The only difference is the exact words the user used and the exact phrases we replied with. They are, fundamentally, the exact same conversation.

    这在脚本3中如何播放?

    How does this play out in script 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看到的效果与他们从提示问题中请求该状态相同,并且处理程序的反应方式也相同。

    Here, the user has suddenly requested we jump to an entirely different state. But that isn't a problem - Dialogflow just saw this the same as if they requested that state from the prompting question and the handler for that reacts the same way.

    所以

    这篇关于来自webhook的dialogflow触发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆