Have you ever had the necessity to create a call routing that somehow identifies the callers language and then provide all announcements afterwards in that language and maybe also connect to different destinations within the SwyxWare?
In this article I would like to show some approaches on how this could be done and also point out their pros and cons.
Lets assume you have a simple call routing that plays a welcome message, afterwards provide an IVR/DTMF menu and then connects the call to the selected user group or the operator if the caller can't decide or can't send DTMF:
In this example of course you have the announcements fixed and therefore in one language only.
But as you have business in lots of different countries you have to differ a few languages your callers might speak: English, German, Italian, French, Spanish, Portuguese Greek, Swedish or Dutch. 9 languages all together (I ❤️ Europe!).
The easiest way to decide what language should be used is of course by checking from where the call comes from, i.e. its country code. Of course there are countries where multiple of the above listed languages are spoken (e.g. Switzerland or Belgium) but for the ease of the call routing they will get one language.
With using the "Insert Script Code" block we can implement the language selection quite easily:
The following code goes into the "Parameters" page of the block:
Dim sCountryCode sCountryCode = "0044" ' United Kingdom, Default Langauge English If Len(IpPbx.CallingNumber) > 4 then sCountryCode = Left(IpPbx.CallingNumber, 4) Select Case sCountryCode Case "0044" ' United Kingdom UseExit = 0 ' -> English Case "0049" ' Germany UseExit = 1 ' -> German Case "0043" ' Austria UseExit = 1 ' -> German Case "0041" ' Switzerland UseExit = 1 ' -> German Case "0039" ' Italy UseExit = 2 ' -> Italian Case "0033" ' France UseExit = 3 ' -> French Case "0032" ' Belgium UseExit = 3 ' -> French Case "0034" ' Spain UseExit = 4 ' -> Spanish Case "0035" ' Portugal UseExit = 5 ' -> Portuguese Case "0030" ' Greece UseExit = 6 ' -> Greek Case "0046" ' Sweden UseExit = 7 ' -> Swedish Case "0031" ' The Netherlands UseExit = 8 ' -> Dutch Case Else ' Every other country / own country / no number signalled UseExit = 0 ' -> English End Select
You might or might not have noticed that I only differed 9 languages so far. Believe it or not, I did that intentionally If you need to differ more than 10 languages you could do something like this, and for that I need the tenth exit of the first "Insert Script Code" block to be free to use it to route to the next one.
Feel free to add any number of more languages here. The above is just a quick example, no discrimination intended.
Now that we know the language of the caller we need to implement our call routing accordingly.
Language aware Call Routing (1)
The most straight forward approach for the call routing would look like this
with having for each language the complete initial script with announcement, menu and connect to, e.g.
Lets take a look into the pros and cons of this straight forward approach:
- straight forward
- for each language a separate call routing
- therefore it is possible to have different call routing per language, not just different announcements
- the script is huuuuuuuge
- therefore not easy to understand when taking a look on it the first time
- therefore it is easy to break it when trying to modify it
- relatively huge amount of work to add new languages
I don't know about you, but I like things a little bit more easy to grasp at a first glance. Something like the very first screenshot on this page. So this brings me to a second possible approach for this.
Language aware Call Routing (2)
As said, I want to come back to the initial script, easy to grasp, just a hand full of blocks.
The idea now is to replace the announcements and destination numbers in blocks as we need them. This is easily be done by taking the announcements and number from variables and all we need to do at the beginning of the script is to initialize those variables properly.
We use the "Start" block to define the needed variables:
Dim sMsgWelcome Dim sMsgMenu Dim sNumSupport Dim sNumSales Dim sNumOperator
Without having them already initialized (will follow soon) we can change all 5 blocks in the script to make use of the variables, instead of using hard coded file names or numbers.
The welcome announcement:
The IVR/DTMF menu:
And the connect blocks to get the call where it should go to:
With having this done we can start thinking about the initialization of these variables i.e. the language selection and definition what values should be used for the variables. With a small VBScript function in the "Start" block this can be quickly done. You might notice that the code looks quite similar to what we have done in the first example in the "Insert Script Code" block. This is because we still use the same principle of language selection.
Function Initialize Dim sCountryCode sCountryCode = "0044" ' United Kingdom, Default Langauge English If Len(IpPbx.CallingNumber) > 4 then sCountryCode = Left(IpPbx.CallingNumber, 4) Select Case sCountryCode Case "0044" ' United Kingdom -> English sMsgWelcome = "MSG_WELCOME_EN.wav" sMsgMenu = "MSG_WELCOME_EN.wav" sNumSupport = "201" sNumSales = "301" sNumOperator = "101" Case "0049" ' Germany -> German sMsgWelcome = "MSG_WELCOME_DE.wav" sMsgMenu = "MSG_WELCOME_DE.wav" sNumSupport = "202" sNumSales = "302" sNumOperator = "102" Case "0043" ' Austria -> German sMsgWelcome = "MSG_WELCOME_DE.wav" sMsgMenu = "MSG_WELCOME_DE.wav" sNumSupport = "202" sNumSales = "302" sNumOperator = "102" Case "0041" ' Switzerland -> German sMsgWelcome = "MSG_WELCOME_DE.wav" sMsgMenu = "MSG_WELCOME_DE.wav" sNumSupport = "202" sNumSales = "302" sNumOperator = "102" Case "0039" ' Italy -> Italian sMsgWelcome = "MSG_WELCOME_IT.wav" sMsgMenu = "MSG_WELCOME_IT.wav" sNumSupport = "203" sNumSales = "303" sNumOperator = "103" Case "0033" ' France -> French sMsgWelcome = "MSG_WELCOME_FR.wav" sMsgMenu = "MSG_WELCOME_FR.wav" sNumSupport = "204" sNumSales = "304" sNumOperator = "104" Case "0032" ' Belgium -> French sMsgWelcome = "MSG_WELCOME_FR.wav" sMsgMenu = "MSG_WELCOME_FR.wav" sNumSupport = "204" sNumSales = "304" sNumOperator = "104" Case "0034" ' Spain -> Spanish sMsgWelcome = "MSG_WELCOME_ES.wav" sMsgMenu = "MSG_WELCOME_ES.wav" sNumSupport = "205" sNumSales = "305" sNumOperator = "105" Case "0035" ' Portugal -> Portuguese sMsgWelcome = "MSG_WELCOME_PT.wav" sMsgMenu = "MSG_WELCOME_PT.wav" sNumSupport = "206" sNumSales = "306" sNumOperator = "1064" Case "0030" ' Greece -> Greek sMsgWelcome = "MSG_WELCOME_GR.wav" sMsgMenu = "MSG_WELCOME_GR.wav" sNumSupport = "207" sNumSales = "307" sNumOperator = "107" Case "0046" ' Sweden -> Swedish sMsgWelcome = "MSG_WELCOME_SE.wav" sMsgMenu = "MSG_WELCOME_SE.wav" sNumSupport = "208" sNumSales = "308" sNumOperator = "108" Case "0031" ' The Netherlands -> Dutch sMsgWelcome = "MSG_WELCOME_NL.wav" sMsgMenu = "MSG_WELCOME_NL.wav" sNumSupport = "209" sNumSales = "309" sNumOperator = "109" Case Else ' Every other country / own country / no number signalled -> English sMsgWelcome = "MSG_WELCOME_EN.wav" sMsgMenu = "MSG_WELCOME_EN.wav" sNumSupport = "201" sNumSales = "301" sNumOperator = "101" End Select End Function
To start the initialization function we can directly use the "Start" block. By simply calling this function within the "Start" block it will automatically be called when the script starts.
' start the initialization automatically when the script starts Initialize
With having all the above 3 code snippets in the "Start" block our call routing script looks like this:
Lets take a look into the pros and cons of this approach:
- small and easy to grasp script
- easy to maintain, easy to add new languages
- as it uses the exact same call routing for every language it might be a little bit tricky to implement exceptions in the call routing for different languages
- if you are not too happy with a little bit of VBScript code it could be difficult to maintain
Of course it matters how many languages you have to differ and how many blocks you have in your call routing which differ per language. I created the examples in here with lots of languages purposely to show you where you could end up sooner or later if the number of supported languages grow over the time.
If you feel more comfortable with GSE blocks instead of a little bit of code there is nothing wrong with the first attempt. It has its pros as it has its cons. As the second one has its pros and cons.
Personally I would always tend to the second approach. But that is just me.
PS: don't miss to take a look into the ECR Useful Link Collection