We have recently refreshed our branding across our offerings and changed the names of our pricing plans. If you have signed up before Aug 9, 2021, please click Previous plans to view your applicable plans.
We assure you that this change will not impact your product experience, and no action is required on your part.

A string of characters that creates a search pattern is known as a RegEx or Regular Expression. RegEx can be used to determine whether a string includes a given search pattern. You can configure the dialogs in the Freshchat bot builder to only accept a specific response pattern.

For example, if you're building a chatbot to collect flight booking information, you can use RegEx to validate the passenger name record (PNR), an alphanumeric string of six characters. By setting up a RegEx pattern in the chatbot builder, you can ensure your customers enters a valid PNR and prevent errors or misunderstandings.

  • Navigate to the specific bot flow where you want to validate a string based on the RegEx.

  • Add a dialog, enter the content for the dialog, and select Custom as the input type.

  • For our example, the bot should only accept strings containing only six alphanumeric characters. The RegEx would be ^[a-zA-Z0-9]{6}$
  • Here's what it'll look like once you're done:

Note: Here's how this RegEx can be broken down

^ : Matches the start of the string

[a-zA-Z0-9] : Matches any alphanumeric character (letters or numbers)

{6} : Matches exactly 6 instances of the previous match (alphanumeric character)

$ : Matches the end of the string

Here are a few more examples of RegEx for some familiar strings:

  • Social Security Number - ^\d{3}-\d{2}-\d{4}$
  • Validate a zip code in the United States (ZIP+4 format) - ^\d{5}(-\d{4})?$ 
  • An order that always starts with ABC followed by 4 digits - ^ABC\d{4}$
  • An email address in the "freshworks.com" domain - ^[a-zA-Z0-9._%+-]+@freshworks\.com$
  • An eight-character string that contains only alphanumeric characters - ^[a-zA-Z0-9]{8}$

If you're facing difficulties with identifying what the RegEx should be for your specific patterns, we've found some external resources that might help:

  1. www.autoregex.xyz: Specify your use case in English to get the respective RegEx
  2. regex101.com: Test and build out RegEx for your custom use case
  3. We've also tried using chat GPT which can even explain how that RegEx works