I have created an agent in dialogflow, for which I want to define an entity based on regex values, I know we have regex capability in defining the entities, but I don't know how to use it or how to define regex while defining the entity. There are no examples or blogs available to help me with this. I want to see an example or syntax of how to define regex entities so that I can replicate the same for my case. Any help will be highly appreciated.
Try this. Go to the Entity page. Create a new Entity an call it whatever you want. In the entity screen select regex and enter this value [A-Za-z]{3}[0-9]{7,10}$. Save the Entity. This regex will validate any value that begins with three letters and 7 to 10 character. Example PAP1234567 or DWL123456789.
Now go to an, intent or create one, and on the training phrases add one that says:
My number is PAP12345678. Select the PAP12345678 to highlighted and the entities menu will appeared. Select the new regex entity and save.
Test the intent on DialogFlow. Hope this help.
Related
I am working on creating an entity that will match anything(letter/number)in an utterance, excluding another entity.
Right now, I have the below pattern added to my entity(Stockpattern):
MatchAnything .*
I want to edit this pattern to match anything except entity "Stock".
Any help is appreciated. I couldn't find any examples in the documentation
I have many intents that extract a parameter that could be almost anything. An example would be a company name. Lots of variation there: "VWR", "1-800-Flowers", "#1 Mufflers". This list can include names in many languages.
I'm using the #sys.any entity now but it doesn't work well if the text includes numbers or punctuation. I get this for the parameter for example: "1 - 800 - Flowers". There are spaces around the numbers and punctuation.
I was expecting the Regex entity to solve my problem but on save it throws and error saying its too broad. \S+[\s\S]*\S+ will catch anything in any language. Here's the error: "com.google.apps.framework.request.BadRequestException: Validate entity with entityName 'RegexAny' and entityId '149486a3-7a49-4171-b23c-860f7d47b713' failed because of the following reasons: Regular expression match is too broad: \S+[\s\S]*\S+."
How can I get around this unhelpful restriction and capture the user's input just as they typed id?
I've had this problem happen to me as well. What I do is use the #sys.any parameter and do the regex check in my fulfillment code. Here you can remove any punctuations and spaces. If you decide to do it this way I'd recommend removing any output contexts and setting them programmatically if you find a match with that regex. If there's no match I will set the same context as the input contexts for that intent.
This works wonderfully.
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 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)