Reputation: 75
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?
Upvotes: 0
Views: 715
Reputation: 732
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.
Upvotes: 2