我一直在阅读有关Dialog流的文章,还有一件事我还不清楚。我试着举个例子。
我希望实现如下转换:
User: Hello Google, what are some interesting cities?
Bot: Hello there! Sydney, New York and Berlin are nice.
User: Could you tell more about the second city?
Bot: Sure. New York is amazing. In New York, you can ...正如您所看到的,我正在构建一个数据上下文。在第一个问题之后,我们应该记住我们回答了Sydney, New York and Berlin,所以我们理解了the second city在第二个问题中的实际含义。
我们应该将这些数据存储在web钩子服务中,还是存储在对话流中的上下文中?如果我们必须将这些数据存储在web钩子服务中,我们如何区分不同的正在进行的对话?
发布于 2017-12-01 13:41:54
将其存储在对话框流上下文中是一个理想的解决方案--这正是上下文创建的目的!你用同一个词表达你的问题,这不是巧合。
从概念上讲,您可以使用这样的设置来完成此操作:
User: What are some interesting cities?
Dialogflow sees no contexts and matches an Intent asking for cities.
Agent replies: Sydney, New York, and Berlin are nice.
Agent sets context "cities" with parameter "cities" -> "Sydney, New York, Berlin"
User: Tell me more about the second one?
Dialogflow has an Intent that expects an incoming context of "cities" with a text pattern like "Tell me more about the (number index) one?" It sends the request to that Intent along with the currently active contexts.
Agent get a parameter with the index and the context "cities". It looks up the parameter for it, turns the string into an array, and gets the city based on the index.
Agent replies: New York is a fun place to visit!
Agent sets context "city" with parameter "current" -> "New York"
User: Tell me more!
Dialogflow matches this phrase and that the "city" context is still active and sends it to an event that reports more.
Agent says: More awesome stuff about New York.
User: Tell me about that first city instead.
Dialogflow matches it against the same intent as before.
Agent says: Sydney is pretty cool.
Agent changes the "city" context so the parameter "current" -> "Sydney" and "previous" -> "New York".您现在可以创建其他意图来处理诸如“比较这两种语言”或“告诉我更多关于另一种语言”之类的短语。
更新
这种设置在对话框流做得很好(解析消息和确定会话的当前状态)和web钩子做得好(确定这些问题的最佳答案)之间取得了很好的平衡。
你可能可以在对话框中做很多事情,但是它很快就会变得非常混乱。您需要创建多个意图来单独处理来自每个值的结果,这是不缩放的。您还需要为每个城市创建一个上下文(因此您将有一个"city_ny“和"city_sydney”上下文),因为您只能在上下文存在的情况下匹配,而不能匹配它可能具有的参数。
使用web钩子(即使是我们现在的内置实现系统)可能会工作得更好。
https://stackoverflow.com/questions/47591980
复制相似问题