Advanced Trigger conditions using regular expressions (V2)

This article will cover more complex Trigger conditions. We'll lead you through an example scenario to demonstrate how trickier use cases can be solved by using regular expressions.

The Scenario

A business wishes to test the numbers their callers dial. They have various lines to serve a number of European countries. Their numbers for Germany and Austria begin with their respective country calling codes: 49 and 41.

Somewhere in their call flow, an IVR menu has been configured to allow callers to choose between two lines: "Press 1 for sales, or press 2 for support". The business has German-speaking teams for sales and support, and English-speaking teams to handle all other calls.    

The business therefore needs to make separate agent selections for the DE sales team, the DE support team, the EN sales team and the EN support team.

The agent selections can be achieved with one Trigger only. However, we must build both 'ANY' and 'AND' conditions into it, something which cannot be achieved solely via the user interface. For instance, have a look at the Trigger for the DE support team. We want the Trigger to fire if the caller dialed a phone number beginning with either 49 or 41, and pressed 2 in the menu.

Regular expressions (short RegEx) are rules which evaluate whether a string of numbers match the rule's conditions. They offer the possibility to test multiple conditions at once. Let's take a look at what the above Trigger looks like in babelforce:

mceclip0.png

The bottom condition is simply testing the caller's dial pad input choice at the IVR menu. But what is that above it?!

^(49|41)[0-9]*$

Once we break the expression down, it looks less intimidating:

  • ^_______$ ...... These characters are merely formal. They mark the start and end of the string.
  • (49|41) ...... Since this bit comes first, this tests whether the string begins with 49 or 43. The "|" is a pipe function, which here essentially means "or".
  • [0-9]* ...... This part just checks if the string is made of the numerical characters 0 to 9, the asterisk allowing the string to be of any length.

According to the trigger above, a customer in Austria dialing 41123456789 and a customer dialing 49123456789 (provided they both press 2) will both pull the trigger for the DE support team.

The business will need the corresponding inverse Triggers as well, in order to achieve the same thing with the EN team selections. For the EN sales team, for example, they will require a Trigger which says "If the caller dialed a phone number not beginning with either 49 or 41, and pressed 1 in the menu, pull this Trigger."

In this case the regular expression uses a special operator at the beginning to test the prefix:

^(?!(49|41))[0-9]*$

If the 'To number' (i.e. number dialed) is a string of any length which does not begin with 49 or 41, it will match this regular expression. The Trigger for EN sales would therefore look like this:

mceclip0.png

N.B.

Note that regular expressions like those above are very useful for other tests, too. You can imagine a scenario where you would like the Trigger to test whether the number dialed was one of multiple inbound numbers you operate:

^(49123456789|44123456789|33123456789)$

Also, you could test whether an IVR input - for example a customer reference number - is valid, by testing the first few characters and its length:

^(323)\d{6,8}$

where "\d{x,y}" will make the string match only if it is between x and y characters long.

Test with your own regular expressions at http://myregexp.com/  

Have more questions? Submit a request