Reputation: 3
I am establishing two entities in my Dialogflow CX agent:
These two entities are used in different phrases of the same intent.
The goal is to make the agent behavior in a certain way if the numeric ID inserted by the user exists; otherwise, the agent will say that such ID does not exist. For this purpose, I created two different routes. The first one is activated when the first entity is matched; the second one is activated when the regex entity is matched.
Since routes are evaluated in the order they are presented, I would expect that if the user inserted a valid ID, the first route would be activated; if the user inserted an ID that does not exist, then the first route would be discarded and the second one will be activated.
However, I noticed that the second route is always activated, as if the regex entity is always preferred to the regular one when Dialogflow parses the entities in an intent.
Can anyone confirm this behavior, or otherwise point to any mistake I am making?
Upvotes: 0
Views: 426
Reputation: 98
According to your description above, the entity "id" and the entity "wrongId" have overlapping values. Specifically, regular expression \d{5,6}
can match all examples you provided for the entity "id".
Here's a screenshot from https://regex101.com/:
That is, when you input a correct id, either one or the other entity can be matched.
Using entities with competing values is against agent design best practices. Avoiding to use conflicting (also referred to as competing or ambiguous) training data when designing your agent will help you avoid conflicts at runtime.
If you have a small number of correct id's, you could add them as entity exclusions to the "wrongId" entity.
Another approach could be to match both correct and wrong id's with the same (broader) entity and validate collected values against your id's database in the backend.
Upvotes: 1