同时询问多个Dialogflow命令 [英] Multiple Dialogflow commands asked at same time

查看:90
本文介绍了同时询问多个Dialogflow命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Action,用户可以在其中设置不同参数的值。目前,这种实现方式是这样的,并且效果很好:

I have an Action where the user can set values of different parameters. Currently this is implemented something like this, and it works well:

现在,我想使对话变得不像机器人,更加灵活,因此我希望允许用户一次设置或更改多个值。他们应该能够说这样的话

Now I want to make the conversation less robot-like and more flexible, so I would like to allow users to set or change more than one value at a time. They should be able to say things like


将利率更改为4%,将期限更改为15年。

Change the Interest Rate to 4% and the Term to 15 years.


将利率更改为4%到15年,平均本金年为3。

Change the Interest Rate to 4%, the Term to 15 years, and the Years to Average Principal to 3.


推荐答案

这样做的方法很多,但是没有一个很好,当您尝试扩展它们时,所有这些都存在某种问题。 (因此,对于输入的两个或三个参数,它们可能会很好地工作,但对其他参数来说,它们可能会工作得不好。)

There are a couple of ways to do this, but none of them are great, and all of them have issues of some sort when you try to scale them. (So they might work well for two or three parameters entered, but they probably won't work well for more than that.)

(值得注意的是,仅用于参考,助手本身最近才开始一次接受多个指令。但是它只能处理两个指令,并且不适用于所有命令。)

(It is worth noting, just for reference, that the Assistant itself has only recently started accepting more than one instruction at a time. But it only handles two, and this doesn't work for all commands.)

添加带有其他参数的短语

使用此解决方案,您将用一组相似的短语来补充收集一个参数的短语。收集两个参数。然后另一个集合也收集三个参数。

With this solution, you would supplement the phrases you have that collect one parameter with a similar set of phrases that collect two parameters. And then another set that also collect three parameters. You should be able to do these all as a single Intent and, in your fulfillment, determine which ones have been set.

看起来应该是这样的:

看上去它开始变得复杂了,没有它?您需要列出绝对值和百分比的每种组合。如果您有其他类型,则还需要包括每个组合。对于3个可能的参数,这开始变得笨拙,并且肯定在此之上。您还冒着可能会混淆应该将哪个参数设置为哪个值的风险(我尚未测试过-这是理论上的问题)。

That looks like it starts getting complicated, doesn't it? You need to list each combination of absolute values and percentages. If you have other types, you need to include each of those combinations as well. That starts getting unwieldy for 3 possible parameters, and certainly is above that. You also run the risk that it might get confused about which parameter should be set with which value (I haven't tested this - it is a theoretical concern).

添加可选的连续短语并递归处理

您也可以将其视为用户说设置值,然后执行其他操作并将其他操作部分视为对Dialogflow的另一条声明。该Intent可能看起来像这样:

You can also treat this as the user saying "set a value, and then do something else" and treat the "do something else" part as another statement made to Dialogflow. The Intent might look something like this:

您可以使用Dialogflow API实现对Dialogflow的另一条语句。在Dialogflow V1中,您将使用查询端点。在Dialogflow V2中,您可以使用 detectIntent端点。无论哪种情况,您都将发送查询的附加部分(如果用户说了些话),然后从中获取结果。您可以将调用产生的消息添加到设置当前值集的消息中,然后将整个消息发送回去。

You can implement the "another statement made to Dialogflow" using the Dialogflow API. With Dialogflow V1, you'd use the Query endpoint. With Dialogflow V2, you'd use the detectIntent endpoint. In either case, you'd send the additional part of the query (if the user said something) and would get back the results from that. You'd add the resulting message from the call to the message from setting the current set of values and send the whole thing back.

作为递归调用,确实会占用时间。由于对Dialogflow的初始调用确实需要在5秒钟内得到答复,因此对Dialogflow的所有其他调用(以及随后的实现)都需要尽快处理。但是即使这样,在前端发生超时之前,您可能也将无法处理其中的2或3个以上。

As a recursive call, however, this does take up time. Since the initial call to Dialogflow really needs to be answered within 5 seconds, every additional call to Dialogflow (and then to your fulfillment) needs to be handled as quickly as possible. But even so, you probably won't be able to handle more than 2 or 3 of these before things time out on the front end.

或好处),则可以在其他部分中调用 edit.attribute 意图之外的其他意图。如果要限制这种风险,可以设置上下文以确保仅调用具有传入上下文的Intent。

It also runs the risk (or benefit) that other intents besides the edit.attribute Intent might be called in the "additional" portion. If you want to limit the risk of this, you could set a context to make sure that only Intents that have that incoming context would be called.

摘要

这确实不是一个容易解决的问题。一方面,您不得不列出所有组合。另一方面,递归需要时间,因此您没有太多时间来处理所有内容。在这两种情况下,确实有可能会误解该短语,并且在某些值已更改而其他值未更改的情况下,您需要弄清楚错误处理。

This really isn't an easy problem to solve. On one hand, you have the problem of having to list out every combination. On the other hand, recursion takes time, and you don't have a lot of time to process everything. In both cases, there is a real possibility of the phrase being understood incorrectly and you'll need to figure out error handling in the case where some values have been changed and others haven't.

您可能需要进行大量实验,结果可能仍不令人满意。

You may need to experiment a lot, and the results may still not be satisfactory.

这篇关于同时询问多个Dialogflow命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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