对话框流(API.ai)中的数据上下文在哪里 [英] Where is the data context in Dialog Flow (API.ai)

查看:77
本文介绍了对话框流(API.ai)中的数据上下文在哪里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读有关Dialog Flow的信息,还有一件事我仍然不清楚。我会尝试举一个例子。

I have been reading about Dialog Flow and there is one thing that is still unclear for me. I'll try to give an example.

我要实现以下转换:

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 ...

如您所见,我正在构建数据上下文。在第一个问题问完之后,我们应该记住,我们回答了悉尼,纽约和柏林,因此我们理解了第二个城市实际上是第二个问题。

As you see, I am building a data context. After the first question, we should remember that we answered Sydney, New York and Berlin, so we understand what the second city actually means in the second question.

我们应该将这些数据存储在webhook服务中还是将其存储在Dialog Flow的上下文中?如果必须将此类数据存储在webhook服务中,我们如何区分正在进行的不同对话?

Should we store this data in the webhook service or is this stored in a context in Dialog Flow? If we have to store such data in the webhook service, how can we distinguish between different ongoing conversations?

推荐答案

将其存储在Dialogflow上下文中是一种理想的解决方案-这正是上下文的目的!您用相同的术语来表达您的问题,这绝不是巧合。

Storing it in a Dialogflow Context is an ideal solution - this is exactly what Contexts were made for! You phrased your question using the same term, and this is no coincidence.

从概念上讲,您可以使用以下设置来做到这一点:

Conceptually, you might do this with a setup like this:

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".

您现在可以创建其他意图来处理比较这两个或告诉我更多有关

You can now create other intents that handle phrases like "Compare these two" or "tell me more about the other one".

更新

此设置在Dialogflow做得好(解析消息并确定对话的当前状态)以及您的webhook做得好(确定这些问题的最佳答案)。

This setup strikes a good balance between what Dialogflow does well (parse messages and determine the current state of the conversation) and what your webhook does well (determine the best answers to those questions).

可以在Dialogflow中做很多事情,但是很快就会变得非常混乱。您将需要创建多个Intent来分别处理每个值的结果,而这不会扩展。您还需要为每个城市创建一个上下文(因此您将拥有一个 city_ny和 city_sydney上下文),因为您只能在存在上下文的情况下进行匹配,而不能匹配其可能具有的参数。

You could probably do much of that inside Dialogflow, but it would start to get very very messy very quickly. You would need to create multiple Intents to handle the results from each value individually, which doesn't scale. You'd also need to create a Context for each city (so you'd have a "city_ny" and "city_sydney" Context), since you can only match on the presence of a Context, not the parameters it might have.

使用网络挂钩(甚至我们现在拥有的内置履行系统)可能会更好。

Using the webhook (even the built-in fulfillment system that we now have) will likely work much better.

这篇关于对话框流(API.ai)中的数据上下文在哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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