Once in a while it happens that I need my call routing script to be able to play announcements in different languages, depending on the caller’s location.
With this article series I want to provide some best practice for how to handle such requirements. Part 1 will deal with own announcements (self recorded), Part 2 which will follow soon will deal with system announcements (being provided by SwyxWare, like dates, times or numbers).
Multi language own announcements
Within Graphical Script Editor (GSE) blocks like Play Announcement or Get DTMF Char you can define a WAV file to be played. This WAV files needs of course to be pre-recorded and available for SwyxServer in the Swyx database. If you need just one language to be supported you can directly record the announcements from within the GSE and select them from a drop-down list. This is the most easiest way, but also the most inflexible one.
If you need to support different languages depending on the caller’s location you have to use a much more flexible attempt to be able to select the language / wav files at run time of the script.
The following example is a very simple call routing script playing a welcome announcement at the beginning and providing afterwards an ivr/dtmf menu to select a destination the call should be connected to.

(click to enlarge)
Two announcements are used in this script, the welcome announcement and the announcement within the Get DTMF Char block to explain the usage of the menu:
- 01_welcome.wav
- 02_menu.wav
The script should be able to handle 5 different languages
- German for calls from Germany and Austria
- French for calls from France
- Dutch for calls from the Netherlands
- Italian for calls from Italy and
- English for calls from any other country plus for calls without number signaling
Of course this would be a perfect moment to start arguing about countries like Switzerland or Belgium which are multi-language themselves. To keep it simple I simply ignore these countries, meaning they will get English announcements.
So before start scripting you need to prepare the two announcements in all of the mentioned languages and load them in the script users User Scope within the SwyxWare database. If you are not familiar with this you can take a look into the Open Queue manual here from the Swyx Forum website. It explains in chapter 3.1.2.1 how to use the IpPbx File Explorer.
- 01_welcome_de.wav
- 01_welcome_fr.wav
- 01_welcome_nl.wav
- 01_welcome_it.wav
- 01_welcome_en.wav
- 02_menu_de.wav
- 02_menu_fr.wav
- 02_menu_nl.wav
- 02_menu_it.wav
- 02_menu_en.wav
Once this is done we can start scripting…
Within the two blocks we are not using hard coded filenames any more but instead global variables to take the filenames from. These two variables need to be defined on the Parameter page of the Start block:
1:
2: Dim s01_Welcome
3: Dim s02_Menu
4:
Within the two blocks Play Announcement and Get DTMF Char we will use these variables now:


(click to enlarge)
Finally we need to write a little bit of VBScript code that identifies the the caller’s location and sets the correct filenames into the two variables. This should be done in a VBScript function which needs to be defined also on the Parameter page of the Start block:
1:
2: Dim s01_Welcome
3: Dim s02_Menu
4:
5: Function InitLanguages
6:
7: PBXScript.OutputTrace "----> InitLanguages"
8:
9:Dim sCountryCode
10: sCountryCode = "0044" ' United Kingdom, Default Langauge English
11:
12:If Len(IpPbx.CallingNumber) > 4 then sCountryCode = Left(IpPbx.CallingNumber, 4)
13:
14: PBXScript.OutputTrace "sCountryCode = " & sCountryCode
15:
16:Select Case sCountryCode
17:
18:Case "0049" ' Germany
19: s01_Welcome = "01_welcome_de.wav"
20: s02_Menu = "02_menu_de.wav"
21:
22:Case "0043" ' Austria
23: s01_Welcome = "01_welcome_de.wav"
24: s02_Menu = "02_menu_de.wav"
25:
26:Case "0033" ' France
27: s01_Welcome = "01_welcome_fr.wav"
28: s02_Menu = "02_menu_fr.wav"
29:
30:Case "0031" ' The Netherlands
31: s01_Welcome = "01_welcome_nl.wav"
32: s02_Menu = "02_menu_nl.wav"
33:
34:Case "0039" ' Italy
35: s01_Welcome = "01_welcome_it.wav"
36: s02_Menu = "02_menu_it.wav"
37:
38:Case "0044" ' United Kingdom
39: s01_Welcome = "01_welcome_en.wav"
40: s02_Menu = "02_menu_en.wav"
41:
42:Case Else ' Every other country / no caller number signaled
43: s01_Welcome = "01_welcome_en.wav"
44: s02_Menu = "02_menu_en.wav"
45:
46:End Select
47:
48: PBXScript.OutputTrace "s01_Welcome = " & s01_Welcome
49: PBXScript.OutputTrace "s02_Menu = " & s02_Menu
50:
51: PBXScript.OutputTrace "<---- InitLanguages"
52:
53: End Function
54:
55: InitLanguages
By calling our function at the end of the code definition the script becomes self-initializing.
If you need to identify more languages / countries the following page provides you with the needed country codes:
If you need some other default language all you have to do is to modify the lines 10, 43 and 44.
Feel free to give any feedback via the comment function of the blog.