??!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
On this page you'll find some code for sample IVR applications. In general, the samples fall into three categories.
Note that we recorded the developer video tutorials using a weather forecasting web service provided by EJSE.com but that the code which we show here uses a different web service. On the upside, we prefer the new one because it does not require that an account be created with them and because in our experience it is always available. On the downside, the URL used to access the service and the XML 'document' it returns and the logic to parse it are somewhat different than what we showed in the videos.
Also note that the samples overlap I/O (the voice user interface) and computation (the delivery of the forecast) in a few different ways.
In the COM (e.g. VB) and Script (e.g. Ruby) samples we access the web service and fetch the content synchronously. We use the loopMessage() method of the call class to play "music on hold" while fetching the content.
In the .Net (e.g. C#) and Java samples, we manage the user interface in the 'main' thread and create a worker thread to perform the content fetch in the background. This offers additional benefits such as the ability to timeout a request as well as a nice separation of the user interface and business logic.
In the C++ example, we handle both the voice user interface and the content fetch using asynchronous functions in a single thread. This is harder to code to be sure, but in high line-density applications the savings in operating system resources may warrant the extra complexity. Of course, you may opt to forego the complexity and instead choose to run on a machine with sufficient memory and processing power.
To be clear, one could use a single threaded approach in a .Net application or a thread pool in a C++ application as one sees fit.
The voice user interface for an IVR application written in one of the .Net languages is implemented in a method named Answer() in a class derived from our base class named NetClientCall.
To the Common Language Runtime, an IVR application is just another class library which happens to reference the NetClientCall assembly which is located in the .\EEs directory of our installation.
As far as we know, the Visual Studio IDE provides no support for building applications with JScript.Net. We compiled the sample above using this command line
jsc /reference:NetClientCall.dll /lib:C:\Telephony\EEs
/target:library /debug HelloWorld.js
Note that we support both the .Net and Win32 versions of Delphi. The samples immediately below were developed with the 2006 version of Delphi and use managed code to create a class library application which is loaded by the .Net platform.
We also have links to samples that use the Win32 version of Delphi further down this page.
The voice user interface for an IVR application written in Java is a class file derived from one of our base classes - JavaClientCall for applications which run in-process with the server and JavaClientCallRemote for applications which run in a different Java virtually machine, possibly residing on a remote server. In either case, the class must override the method named Answer() where the voice user interface is implemented.
The voice user interface for an IVR application written with the 'native' edition of Delphi is implemented in a function named Answer() which is exported from a DLL which is loaded by the server and simulator. We have such DLL samples immediately below.
Note that we also support the the .Net version of Delphi. You'll find managed Delphi samples along with other .Net samples above.
The voice user interface for an IVR application written in a language which uses COM for its object model is implemented as in in-process COM server which implements the IDispatch interface. These components are sometimes called ActiveX DLLs. The component must have a method named Answer() in which the voice user interface is implemented.
We are sorry but because we just don't get FoxPro we won't be able to post any more samples in that language.
The voice user interface for an IVR application written in a native language is implemented in a function named Answer() which is exported from a DLL which is loaded by the server and simulator.
HelloWorld Weather (Keypad) Weather (Spoken)
Note that C and C++ samples differ from the other samples in the way in which they deal with handling the voice user interface while the content fetch is ongoing.
The samples using the script languages and COM friendly languages perform a synchronous fetch of the content. This is simple but it does not allow an application to detect an early disconnect by the caller.
The samples using the .Net languages and the Java language move the content fetch to a background thread which allows the user interface thread to detect a hangup and recycle the telephone line in a timely fashion on the caller's disconnect.
The C and C++ samples use asynchronous I/O in the user interface thread to communicate with the web service. This allows the application to react to the caller's hangup while not paying the time and space penalty associated with extra threads. In short it is a more scalable approach.
We wrote the sample that way because we expect that scalability is uppermost in the minds of developers who opt to use C++. There is however no reason why a C++ application could not use a background thread or why a .Net or Java or application could not use asynchronous I/O.
The voice user interface for an IVR application written in a script language is implemented in a publicly accessible procedure named Answer. That procedure receives as its only parameter a reference to a call object.
Note that we don't support a fixed set of script languages. Rather we support the platform's extendible script host. If the script host has an interpreter for a particular script language, and if that language supports COM components (of which our call object is one) then we support it.
You'll find samples below for the script languages we have tested.