Jump to content
Tom Wellige

Best practice for multi-language call routing scripts

Recommended Posts

HINT: there is also a blog post available, discussing this topic in a bit more detail: #7: Welcome to Babylon!

 

This post is taken from the Swyx Forum Archive (2007-2014) and was originally posted 06.01.2011 by me

 

Every 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. So in this article I want to explain one possibility (my preferred one) to solve this problem.

 

Within the Graphical Script Editor (GSE) blocks like Play Announcement or Get DTMF Char you can define a WAV file to be played. This WAV file 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.

 

Windows-Live-Writer-Best-practice-for-multi-language_C3B6-multi_lang_part1_pic1_2.jpg

 

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:
 

  • 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

 

Now these filese need to get uploaded into the User scope of the script user.  This can be done with the SwyxWare Adminstration:
 

  • start SwyxWare Administration
  • open the Server Properties
  • switch to Files page
  • click the Edit... button
  • click the Add... button
  • click the ... button and select all prepared WAV files
  • set Scope to User
  • set Category to Announcements
  • set User to the script user
  • click OK
  • click Close
  • click OK

 

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:

Dim s01_Welcome
Dim s02_Menu

 

Within the two blocks Play Announcement and Get DTMF Char we will use these variables now:

 

Windows-Live-Writer-Best-practice-for-multi-language_C3B6-multi_lang_part1_pic2_2.jpg

 

Windows-Live-Writer-Best-practice-for-multi-language_C3B6-multi_lang_part1_pic3_2.jpg

 

 

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:

 

Dim s01_Welcome
Dim s02_Menu

Function InitLanguages
	PBXScript.OutputTrace "--------> InitLanguages"
	
	Dim sCountryCode
	sCountryCode = "0044"  ' United Kingdom, Default Langauge English

	If Len(IpPbx.CallingNumber) > 4 then sCountryCode = Left(IpPbx.CallingNumber, 4)

	PBXScript.OutputTrace "sCountryCode = " & sCountryCode

	Select Case sCountryCode
		Case "0049" ' Germany
			s01_Welcome = "01_welcome_de.wav"
			s02_Menu    = "02_menu_de.wav"

		Case "0043" ' Austria
			s01_Welcome = "01_welcome_de.wav"
			s02_Menu    = "02_menu_de.wav"

		Case "0033" ' France
			s01_Welcome = "01_welcome_fr.wav"
			s02_Menu    = "02_menu_fr.wav"

		Case "0031" ' The Netherlands
			s01_Welcome = "01_welcome_nl.wav"
			s02_Menu    = "02_menu_nl.wav"

		Case "0039" ' Italy
			s01_Welcome = "01_welcome_it.wav"
			s02_Menu    = "02_menu_it.wav"

		Case "0044" ' United Kingdom
			s01_Welcome = "01_welcome_en.wav"
			s02_Menu    = "02_menu_en.wav"

		Case Else ' Every other country / no caller number signaled
			s01_Welcome = "01_welcome_en.wav"
			s02_Menu    = "02_menu_en.wav"

	End Select

	PBXScript.OutputTrace "s01_Welcome = " & s01_Welcome
	PBXScript.OutputTrace "s02_Menu = " & s02_Menu

	PBXScript.OutputTrace "<-------- InitLanguages"
End Function

' run the language initialization automatically on script start
InitLanguages

 

You might have noticed that after the function declaration the function is also directly called. This will automatically be executed once the call routing for the new call starts end actually even before the GSE script is getting started.

 

This finalizes this article about how to setup multi-language call routing scripts.

 

Enjoy!

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.