Manipulating string values to internationalize telephone numbers

Christina Dechent
Christina Dechent
  • Updated

This article will solely concentrate on the string manipulation for the automated sending of SMS, and not go into detail describing how that Automation should be configured within the call flow. Knowledge of application configuration, including for Input Readers, will be assumed.

During a call, information in the form of text or numbers becomes known to the babelforce platform. It could be automatically processed, for example call information such as the caller's phone number; or it could be entered as an input by the caller, for example a reference number. These "strings" of letters and numbers can be used in other Automations in the same call flow.

Sometimes their form has to change in order for them to be used. In our example here, the string will be a mobile phone number and the Automation will be an automated SMS dispatch. The business would like to send a support SMS to the mobile phone number if the caller chooses that option. 

Automated SMS dispatch

There are 2 scenarios for the SMS dispatch:

  1. The call is made from a mobile phone. If this is the case, the babelforce platform will automatically recognize that and use it for the automated SMS. It won't require any manipulation.
  2. The call is made from a landline and the customer enters a mobile number into an Input Reader. To make this as reliable as possible and optimize the caller's experience, they are asked to enter it in its simple local form, i.e. '08912764718'. 

So how do we deal with the second scenario? First we will need to configure a Trigger which recognizes that the input number (saved in the Input Reader as a variable called "mobileinput") is local, i.e. that it isn't prefixed with the country code but instead starts with the standard "0" for local mobile phone numbers:

mceclip0.png
 

Note that the 'Expression' used here is found under the "App" section of the drop-down menu.

Now that we have a Trigger to test this, the local Automation can be configured in the module following the Input Reader. It is simply an Audio Player informing the caller that the SMS has been sent:

mceclip1.png
 

There are a couple of things to note here before we dive into the expression used in the field "To". Firstly, the position of the action should be "Before", because we want the Automation to run as soon as we get to the confirmation message, and because sending it at the end of the module is unreliable: what if the caller hears the confirmation and hangs up before it has finished? 

The Trigger should be the one we created above, which will ensure that the Automation will only send an SMS to a number prefixed with a 0. It is required to ensure that the expression in the field "To" is evaluated properly.  

Let's take a closer look at the expression now:

49{app.inputReader.mobileInput|substr:1} 

  • The part inside the curly braces but before the vertical line - "app.inputReader.MobileInput" - designates the given string for our variable "mobileInput". It filled with whatever is entered in the Input Reader for that call.
  • The next bit - "|substr:1" - takes the string declared in the first part and manipulates it, removing the first character.
  • Finally the "49" is added at the beginning of the string. 

We used "49" as an example (it is the German country code so you should know from which country your customers call you), but no matter what is used, the end result will be a string which resembles a phone number with an international country code prefix, e.g. "498912764718". This is the format which babelforce requires to be able to send the SMS. 

When a caller reaches the Input Reader and enters a mobile number, the string is assigned to the variable "mobileInput". This string has to be entered correctly, so it is crucial that the Input Reader is configured correctly. An explanatory audio must inform the caller of the format, and if you would like the customer to set a "Termination key", you should use a special character like a "#" to prevent number confusion.

Further reading - some more information on string manipulation

As mentioned at the beginning of the article, there are many more use cases for this kind of manipulation. A common one would be a business which makes use of customer reference numbers (CRN).

Let's say this business has 8-character customer reference numbers which have the following structure:

  • 87 - the first two numbers indicate the department
  • 65 - the second two indicate the department section
  • 4321 - the last 4 designate the customer's unique number

When a caller enters their number, the business wishes to manipulate the CRN and use the resulting sub-strings with their Helpdesk integration, updating the content of tickets. 

They require manipulations which isolate the different parts on the CRN. Let's take "custrefno" as our variable. The following expressions correspond to the sub-strings we are looking for:

  • {app.inputReader.custrefno|substr:0:2} - department
  • {app.inputReader.custrefno|substr:2:4} - section
  • {app.inputReader.custrefno|substr:4:7} - unique number 

The numbers after the "substr" expression refer to positions of characters in the variable. The first number designates which position to start with (beginning with the 0th position), and the second number is the non-inclusive endpoint. This means that the corresponding character is not included in the sub-string, only the one before it.

Think of the first expression above ("{app.inputReader.custrefno|substr:0:2}"). It means we select the sub-string which begins at position 0 [the first character] and runs until, but not including, position 2 [the third character].

Was this article helpful?

/

Comments

0 comments

Please sign in to leave a comment.