Click here to expand Table of Contents
If you place the script in the "[FS root dir]/scripts" you may access them by their basename without any path information; if you place them elsewhere you must include the full path to the script eg:
If located in [FS root dir]/scripts
Full path example:
Let's create a new application called HelloWorld.js and place it in the correct directory.
Your first JS app
var languageCode = "en";
var soundDir = "sound/";
function playFile(fileName, callBack, callBackArgs)
session.streamFile(soundDir + languageCode + "/" + fileName, callBack, callBackArgs);
That wasn't so hard, was it? The first line specifies which Human language we are using. We can switch language anytime during the session thanks to this variable.
The second variable specifies the root directory for the sound files.
We have created our own method called playFile which is used to play the correct language prompt. It also allows us not to care about where the sound files are located, which gives us the advantage of D.R.Y. (don't repeat yourself).
Session.answer() is the most important function in this script, since it answers the telephone call.
<condition field="destination_number" expression="^9910$">
|I had to modify: var soundDir = "ivr/8000";in order to play a wav file from the ivr group in order to get one of the IVR announcements to play. Also, there is no HelloWorld.wav that I can find. I'm certain it was meant as an example.Thanks for this example, John. Posted by firstname.lastname@example.org at Oct 27, 2017 10:17|