I have an issue developing an agent with dialogflow (api.ai). I am using a lot of entity values which are all different from one another. however there are similar synonyms for some entity values but the agent is returning only one value.
How can i get all the possible matches or ask question to resolve the ambiguity
for example i have an intent like: tell me the location of ABC express train
if my entity values are :
entity synonym
15127 ABC express
12345 ABC express
I want it to return two values or ask question to resolve such ambiguity
how can i work this out
Thanks in advance
If you enable fulfillment for this intent, you can take a look at the value the user said and ask a further question if you need to disambiguate between entities.
Let's imagine you are extracting an entity called "trains". The parameters table in your intent might look like this:
By default, if the user says ABC express, the fulfillment webhook will be called with the following parameter hash:
"parameters": {
"trains": "15127"
}
This isn't enough information to decide if the request was ambiguous, since train 15127 might also have non-ambiguous synonyms.
You can configure Dialogflow to send the original text of the entity, alongside the resolved value. This means you will receive the following information to your webhook:
"parameters": {
"trains": "15127",
"original": "ABC express"
}
You can then use some simple logic to ask a further question if the value of original appears in a list of known ambiguous synonyms.
To have Dialogflow send this data, modify your parameters table so it looks like the following:
This will cause the original synonym to be sent to Dialogflow alongside the resolved value.
Related
I have the following custom entity named 'department'. The entity defines like below:
department [Define synonyms - checked]:
appliances| stove, washer, appliance has, appliance part, appliances, appliances department.
An intent uses this entity type (department) in training phrases. ML is enabled for the corresponding intent.
The issue:
when in the DF console I enter 'appliances department', DF does not evaluate the value as 'appliances' and set it to be equals to original value (appliances department). If I use other synonyms, the value is evaluated correctly.
Could you please help me to resolve this case.
Thank you in advance!
I have reproduced the entity, and it is working for me.
I believe that maybe Dialog Flow is seeing the synonym ‘appliances department’ as redundant since the value is ‘appliances’ and it is contained in the synonym list, as well.
Also, there is a possibility that the same value is being overlapped by other entities.
Since #sys.airport only exists for the default English locale, I want to create a custom entity that emulates it for other locales.
From what I've read here, you can put subentity types into the value fields, say, the system entity #sys.geo-city:city and a custom entity #usr.iata-code:iata, and it will match either one or the other.
But I don't understand how you would tell Dialogflow which city and which IATA code go together, so that Dialogflow (ES) would know to send the complete object {"city":"Amsterdam", "iata": "AMS"} to the webhook after matching either "Amsterdam" or "AMS", as it does happen with #sys.airport.
Thanks for any input!
It will be difficult to create a custom entity that works just like #sys.airport. The #sys entities are special and can do somethings custom entities can't, for instance, pairing values together.
As you pointed out, you can put multiple entities together in one single entity by using Composite Entities, but the only thing this does is allow you to recognize two values made up from other #sys or custom entities in a single entity. It doesn't give you the option to create pairs between the values of the entities.
If you would want to create something like this, you would need some code that does a look up in a dictionary or list. So when "AMS" is matched, the code fills in the missing property "Amsterdam" or vice versa.
I have a composite entity working fine. But when I try to change its value by another composition in fulfillment, it's been interpreted as a string value:
const entity = {
"name":"projects/myproject/agent/sessions/" + sessionID +
"/entityTypes/lia_parametro1",
"entities":[{
"value":"#sys.email:email",
"synonyms":[
"#sys.email:email"
]
},
When I put this value directly in Dialogflow Console(#sys.email:email) it works fine, but when I try to do this dynamically as above, it understands "#sys.email:email" as a value, instead of a System Entity.
Is there a special way to declare System Entities in Json format?
Many thanks for any tip!
Diego Mesquita
I think you're getting confused about what the purpose of entities are.
Entities are used when extracting parameters - they're hints to Dialogflow to say "I'm trying to grab a piece of data from whatever the user has said, by the way the piece of data I want you to extract looks like this -> [the values of #sys.email]".
When something reaches your fulfillment code, that whole data extraction process has been done, and therefore entities become irrelevant. You can run whatever code you wish to extract data (for example a regex), then assign that as a parameter value to some output context.
To quote the documentation:
Each intent parameter has a type, called the entity type, which dictates exactly how data from an end-user expression is extracted.
I hope this helps - if not, can you give a little more info about your use-case?
I want to create an entity that has any value except the values that are defined in another entity.
For example, i have an entity that contains all the possible products categories that i use in the bot, and if the user type a value that is not in that entity i want to react in some way.
It's like a fallback but only triggered when that condition is met.
Any suggestion?
Entity extraction is based on some definite value that can be identified and separated. There should be some basic features defined for the agent to train on. Based on these trained features, the agent will look for an entity and extract it from the user's response.
If you have already defined an entity to look for, it will be extracted by the Dialogflow based on the training data. If there is nothing defined it will not be identified as an entity as the agent will be not sure what to look for.
So, what you can do is,
Make the entity (already defined) as not required. Uncheck the "required" checkbox in the Dialogflow.
Add the "#sys.any" in the Entity you defined and make it a composite Entity with the combination of your Entity and "#sys.any" something in the line of
Train your agent to look for this new Entity with your Basic Entity data and Anything else data.
Collect this in the webhook.
OR
You when you want to collect anything else, you can collect user utterance from the agent object and parse the data using Regex pattern of your choice.
I have an intent that requires the user to give a path:
plot the file in /home/user/path
Is there a way to extract the path with dialogflow and to get its value into an entity? I think that this case cannot be approached with synonyms.
NO, as DialogFlow doesn't support Regex in entities, there is no easy way to parse path value in DialogFlow using entity.
You have two options to parse Paths into an entity.
One: Use #sys.any entity in place of the path and on fulfilment side check if the value of the entity is actually a valid path or not using Regex.
Two: Create your own entity for paths and use DialogFlow Agent-API to keep updating values in that entity whenever new file/folder is created/updated/deleted in whatever file system you are working on. (Yeah this sounds crazy but I don't think there are any other options to achieve what you want)