How to Create A Simple IVR

From VESupport

Jump to: navigation, search

How to Build a Simple Telephony Application or IVR

I started working for Inventive Labs just a little over 2 and a half years ago. My background was in Web and Windows Form Development using C#, and had absolutely no background in VoIP or telephony development. When I started at Inventive Labs, I began writing Voice Applications, and was able to come up to speed quickly, at the time I didn't think anything of it. However, as part of my job, I began testing some competing products, and realized just how much work it is to develop Voice Applications using other products. Our goal is to allow experienced .NET developers hit the ground running in developing their Voice Applications. Here is an example of how easy it is to build a simple IVR.

What is an IVR

Anytime you call a large service provider such as a cable company, phone company, or bank the chances are that they have implemented some type of IVR system. IVR stands for "Interactive Voice Response" and in its most basic form allows users to enter digits to give information to a computer system. Sample Code For example, your phone provider may prompt you for your account number. To do this using Voice Elements, you would write code that looks like the following:

    public class InboundIVR
    {
        public ChannelResource ChannelResource
        {
            get;
            set;
        }
 
        public VoiceResource VoiceResource
        {
            get;
            set;
        }
 
        public TelephonyServer TelephonyServer
        {
            get;
            set;
        }
 
        public Log Log
        {
            get;
            set;
        }
 
        public string DeviceName
        {
            get;
            set;
        }
 
        public bool ExistsAccount(string account)
        {
            return true;
        }
 
        public void RunScript()
        {
            // Instruct the voice resource NOT to clear the digit buffer on the next voice function.
            // In this way, if the user began pressing digits during the previous play, those digits will not get lost.
            VoiceResource.ClearDigitBuffer = false;
 
            // Instruct the voice resource to return a maximum of 10 digits
            VoiceResource.MaximumDigits = 10;
 
            // Instruct the voice resource to terminate the next voice function on just a "#" DTMF digit.
            VoiceResource.TerminationDigits = "#";
 
            for (int i = 0; i < 3; i++)
            {
                // Prompt the user for their account number
                VoiceResource.PlayTTS("Please enter your account number, followed by the Pound sign");
 
                // Wait until the above condition are met.
                VoiceResource.GetDigits();
 
                // Log the response.
                Log.Write("Digits Returned: " + VoiceResource.DigitBuffer);
 
                // Now you can call a database method that checks to see whether the account exists
                bool doesAccountExist = ExistsAccount(VoiceResource.DigitBuffer);
 
                if (doesAccountExist)
                {
                    // Decide what you would like to do
                    // Perhaps play back their balance
                    VoiceResource.PlayTTS("Your balance is ten dollars");
                    break;
                }
                else
                {
                    VoiceResource.PlayTTS("I'm sorry your account number is not valid");
                    // Perhaps you would like to replay the prompt?
                }
            }
 
        }
    }

Next Steps The digits that the user has entered will be contained in the DigitBuffer. Because you are using .NET, you can use the database classes that you are familiar with to validate the account number, and direct the user to the appropriate next response. For example, you could replace the ExistsAccount method, with code that performs a web service or database lookup, and expand your application from there.

Voice Elements supports all of the common features that you need to create your own Voice Application.

Voice Elements supports the following features:

  • Text To Speech
  • Speech Recognition
  • Conferencing
  • Fax (T.30 / T.38)
  • Beep Detection
  • Call Progress

For a more indepth look at creating your own telephony app, feel free to download our demo, which includes a Sampler that contains code examples for using many of these features.

Voice Elements is also priced very competitively. Most of the telephony toolkit providers license 3rd party technology, but because we have developer Voice Elements from the ground up, we are able to provide our solutions at a better price.

Personal tools