'Why does a regex entity have priority in Dialogflow CX?

I am establishing two entities in my Dialogflow CX agent:

  • the first one, called "id" contains some numeric IDs that exist in my domain: e.g. 29042, 29145, 28248, ...
  • the second one, "wrongId", is defined by a regex that is supposed to capture all numeric sequences similar to the previous entities: \d{5,6}

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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source