[英]Add parameter to context without webhook in Dialogflow
Im wondering if it is possible to add set matched entity properties as context.我想知道是否可以将设置匹配的实体属性添加为上下文。
I am describing my use case which hopefully clarifies why I am trying to do this: Imagine I have a entityType called "Animals" with the following properties -> synonyms mappings我正在描述我的用例,希望能阐明我为什么要这样做:假设我有一个名为“Animals”的实体类型,具有以下属性 -> 同义词映射
{
Cow: ['Mammal','Moo'],
Frog: ['Amphibian','Croak']
Dog: ['Mammal','Bark']
}
I have an Intent("Intent1") which has Animals entityType as a parameter我有一个 Intent("Intent1") 以 Animals entityType 作为参数
Use case 1: If Intent1 is called I want to add the matched animal in context.用例 1:如果 Intent1 被调用,我想在上下文中添加匹配的动物。 For example if the user says "Bark", I want to add "Dog" in context.
例如,如果用户说“吠”,我想在上下文中添加“狗”。 I would also like to have a follow up intent to intent1 (call it Intent2) which displays the matched animal from context.How can I make this work
我还想对 intent1(称之为 Intent2)有一个后续意图,它显示上下文中匹配的动物。我怎样才能完成这项工作
Use case 2: I want to get matched with one and only one animal such that when Intent2 is invoked it only displays one matched animal not many.用例 2:我想与一只且只有一只动物匹配,这样当调用 Intent2 时它只显示一只匹配的动物,数量不多。 So for example if Intent1 is invoked with "mammal", I want to add "Cow" and "Dog" in context.Such that when intent1 is invoked again it only tries to create a match from the earlier matched entities.
因此,例如,如果使用“哺乳动物”调用 Intent1,我想在上下文中添加“牛”和“狗”。这样当再次调用 intent1 时,它只会尝试从较早的匹配实体创建匹配项。 Thus if the user says Croak after having said Mammal then Frog should not get matched.
因此,如果用户在说完 Mammal 之后说 Croak,那么 Frog 不应该被匹配。
So the workflow should be:所以工作流程应该是:
Intent1 invoked with "Mammal" -> ["Cow","Dog"] put in context
Intent1 invoked with "Croak" -> ["Cow","Dog"] remain in context
Intent2 is invoked -> "Please narrow down to one animal"
Intent1 is invoked with "Dog" -> "Dog" is put in context
Intent2 is invoked -> Your matched animal is "Dog"
When you add a parameter to an intent that has a output context, the parameters are automatically added to the outputContext.当您将参数添加到具有 output 上下文的意图时,参数会自动添加到 outputContext。 As long as the context is available you should be retrieve the parameters in your follow-up intent by using
#[ContextName].[ParameterName]
.只要上下文可用,您就应该使用
#[ContextName].[ParameterName]
在后续意图中检索参数。
Intent1意图1
Intent 2意图 2
Result结果
Usecase 2用例 2
Since you prefer an option without webhook, your options are a bit limited.由于您更喜欢没有 webhook 的选项,因此您的选择有点受限。 It's not possible to narrow down on the available entity values based on what the user said.
不可能根据用户所说的缩小可用实体值的范围。 Dialogflow will always attempt to match the user input to all available values of an entity.
Dialogflow 将始终尝试将用户输入与实体的所有可用值相匹配。
If you decided to use a webhook, you would have a second option.如果您决定使用 webhook,您还有第二个选择。 You could set "Dog" and "Cow" in the context and if the user gets invoked again, you check the user input against the values in your context.
您可以在上下文中设置“Dog”和“Cow”,如果再次调用用户,您将根据上下文中的值检查用户输入。 If the user says "Croak" you can return a no match response via code.
如果用户说“Croak”,您可以通过代码返回不匹配响应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.