Dialogflow中“意图”和“动作”之间是什么关系? [英] What is the relationship between 'intents' and 'actions' in Dialogflow?

查看:87
本文介绍了Dialogflow中“意图”和“动作”之间是什么关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难在Dialogflow代理中概念化意图和动作之间的关系。

I'm having a bit of trouble conceptualizing the relationship between 'intents' and 'actions' in a Dialogflow agent.

我发现意图映射了用户的口头表达请求执行服务的特定功能,可以选择将参数作为输入变量。这是在官方文档中定义的意图:

I get that intents map the user's spoken request to a particular feature of my fulfillment service, optionally carrying parameters as input variables. This is how intents are defined in the official documentation:


意图表示用户所说的内容与软件应采取的
操作之间的映射。

"An intent represents a mapping between what a user says and what action should be taken by your software."

但是动作是什么? 其定义几乎完全相同:

But what then are actions? Their definition reads almost exactly the same:


某操作对应于用户输入触发
特定意图时应用程序将采取的步骤。

"An action corresponds to the step your application will take when a specific intent has been triggered by a user’s input."

动作是在意图的上下文中定义的,这意味着每个意图只能有一个动作,并且一个动作不能附加到多个意图上。动作似乎不只是其名称,这也是完全可选的,因为无论我是否指定动作名称,其意图都相同。

Actions are defined within the context of intents, which means there can only be one action per intent and an action can't be attached to multiple intents. An action doesn't seem to be more than its name, which is also entirely optional as the intent works the same whether I specify an action name or not.

那又怎样呢?是他们的目的吗?为什么我要让我的服务对操作而不是意图做出反应?

So what is their purpose? Why would I have my service react to actions instead of intents?

推荐答案

您的问题有一个轻微的错误陈述,但这说明了Dialogflow意图和动作之间的区别。语句

You have one slight misstatement in your question, but it illustrates the difference between a Dialogflow Intent and Action. The statement


动作不能附加到多个意图

an action can't be attached to multiple intents

不是真的。您可以对多个Intent名称使用相同的Action名称。在这种情况下,这意味着您可以将Action用作实现中函数的映射,而不必列出代码中映射的每个Intent。

isn't true. You can use the same Action name for multiple Intent names. In this case, it means that you can use the Action as a map to a function in the fulfillment without having to list each Intent that maps in your code.

在Dialogflow中,Intent不仅可以匹配特定的用户短语-还可以用于匹配处于特定状态(由设置的上下文确定)或特定非短语事件的会话。由于您可能希望将其中的几个映射到后端的同一操作(例如,如果您有两个不同的传入上下文需要与不同的用户短语匹配),则可以为它们设置相同的操作,但使用不同的用来标识它们的意图名称。

In Dialogflow, the Intent does more than just match a particular user phrase - it also is used to match conversations that are in a particular state (determined by Contexts that are set) or for particular non-phrase events. Since you may wish to map several of these to the same action on the back-end (for example, if you have two different Incoming Contexts that you need matched with different user phrases), you can set the same Action for them but use different Intent names to identify them.

某些库,例如 Google行动 v2和多声

Some libraries, such as actions-on-google v2 and multivocal let you work with either, whichever makes the most sense.

当我命名Intent时,我通常会开始使用相同的名字做大致相同的事情。用于操作,但添加一个后缀以指示意图不同的原因。 (具有不同的上下文名称,事件名称或参数。)

When I name Intents, I will generally start all of them that do roughly the same thing with the same name I use for the Action, but add a suffix indicating why the Intents are different. (With the name of the context, or event, or parameters that are different.)

更新以澄清一些事情

我通常将动作名称用作触发我的功能的名称,但是在某些情况下,我仍然可以按动作对事物进行分组(因为这样组织起来很有意义) ,但为其中一种意图开辟了例外。可以将其视为OO模型中的子类。经验法则是使用动作名称,但如果有充分的理由不使用它,则不要刻板地使用它。 (例如,使用多声道的例子,该库定义了一个未知动作,它涵盖了误解的输入和没有输入的内容。但是有时候我想以不同的方式处理其中之一,因此,我将定义一个仅适用于意图。)

I generally use the Action name as the one that triggers my functions, however there are a few cases where I might still group things by action (because it makes sense to organize them that way), but carve out an exception for one of the Intents. Think of this as subclassing in an OO model. Rule of thumb would be to use the Action name but don't hold this rigidly if there is a good reason not to. (An example of this is using multivocal, the library defines an "unknown" Action that covers both misunderstood input and no input. Sometimes I want to handle one of these differently, however, so I'll define a handler that works on just the Intent.)

Action名称应该在Dialogflow在 queryResult.action 中发送您的成就的JSON中可用。我不确定为什么文档现在会忽略这一点。

The Action name should be available in the JSON that Dialogflow sends your fulfillment in queryResult.action. I'm not sure why the documentation omits this at the moment.

这篇关于Dialogflow中“意图”和“动作”之间是什么关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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