SMS Regexp to route content to proper routing rule

To configure routing based on the content, you can use the following option in the Start/SMS/Routing/Routing rules interface:

  • Inclusive content pattern: - serves to process traffic within a specific rule containing the specified pattern
  • Exclusive content pattern:’ - serves to process traffic within a specific rule except for the specified pattern

Kindly note that these fields are defined by the regular expressions in Python.

For the correct configuration, it is necessary to determine the pattern of messages for which this routing is required.

Once a pattern is defined and a regular expression is constructed based on it, there are several ways to check its correctness.

  1. Start/Reference/Regular Expressions interface. You can find detailed step-by-step description in this screenshot:

    Also, you can find detailed description of this interface in our manual.

  2. To create a test routing rule and perform a simulation. You can check whether this rule will be applied for routing, or find out the reason for the opposite.
  3. To use website https://regex101.com/. You can find detailed step-by-step description in this screenshot:

In conclusion, here are some of the most used examples of text patterns:
1. Any message containing the ‘OTP’ or ‘code’ word:
^(.*)(OTP|code)(.*)$
To make this case-insensitive (to match ‘otp’ and ‘CODE’ also), you need to adjust regular expression with a (?i) option at the beginning:
(?i)^(.*)(OTP|code)(.*)$

2. Any message containing the link:
^(.*)([.]\w{2,3}[/])(.*)$
This message will match if in the text there is a dot sign, after that comes the top level domain (.com/.de and so on), and a ‘/’ sign right after that.

3. Any message containing from 4 to 8 digits in a row:
^(.*?)(\d{4,8})(.*?)$
The number of digits in a row is configurable using the parameter {x,y}, where x - from how many digits in a row, y - up to how many.
If this 8-digit code is divided into two parts through the '-' sign, the following pattern can be used:
^(.*?)(\d{4}[-]\d{4})(.*?)$

4. Any message containing codes only (length from 1 to 10):
^\d{1,10}$

5. Any message without digits:
^\D*$

If you need additional advice, please contact the support team at TT.

 

AKBSMS - Alaris Knowledge Base

Related questions:
How to route content to the proper routing rule?
How to detect URL in the content?
How to configure routing for the OTP messages?
What does the inclusive content pattern means?
What does the exclusive content pattern means?
How to create inclusive content pattern regular expression?
How to create exclusive content pattern regular expression?
How to check the correctness of a regular expression?

Link to this article: https://helpdesk.alarislabs.com/en/knowledge_base/article/270/category/134/