Raymond Douwes
Raymond Douwes

Reputation: 11

Dialogflow CX; RegExp Entities: I want to request a standard format

I want to build a conversation where customers needs to fill in there customer number. The customer number is always build in the format XX-XX-XXXXXX (2 numbers-2 numbers-6 numbers).

I don't have too much experiences with DialogflowCX or in general with too technical stuff. I know how to request a complete string of numbers with: ^[0-9]{10}$ but how do I manage that I force customers to also type the - sign in their answer.

Upvotes: 1

Views: 400

Answers (1)

Florian Feldhaus
Florian Feldhaus

Reputation: 5932

I recommend that you build regular expressions at regex101.com, it is easy to use and allows you to quickly test against examples.

For your specific problem, this is a regular expression which will work:

[0-9]{2}-[0-9]{2}-[0-9]{6}

I recommend to not use ^ and $ unless you really want to restrict a parameter input to the specific entity.

Here is the difference, let's assume the following input

My customer number is 12-34-567890

A parameter with a regular expression entity type containing [0-9]{2}-[0-9]{2}-[0-9]{6} matches the customer number as expected, but the customer number is not matched with ^[0-9]{2}-[0-9]{2}-[0-9]{6}$.

Upvotes: 1

Related Questions