Programmable Voice

  1. Home
  2. Docs
  3. Programmable Voice
  4. How do I
  5. Create a Simple IVR

Create a Simple IVR

Voice Elements Makes It So Much Easier

When I began working at Inventive Labs, my background was in Web and Windows Form Development using C#.  I had absolutely no background in VoIP or telephony development. When I began writing Voice Applications, I was surprised how quickly I was able to come up to speed. At the time I didn’t think anything of it, however, as part of my job I began testing some competing products.  I 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?

IVR stands for “Interactive Voice Response” and in its most basic form, it allows users to enter the digits (DTMF) or speak the choice (speech recognition) to give information to a computer system. We have all experienced that moment when our call is answered and we are given menu options to reach the department of our choice.  The caller would press or say ‘1’ to be routed to that selection in the IVR.  Voice Elements can easily accomplish these tasks for your application.

Sample Code

For example, often an IVR includes asking the caller for their 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 the features commonly used in IVRs:

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

The source code included with our demo sample solutions will help provide a more in-depth look at creating your own telephony app.

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

Want more information? Check out the following articles:

IVR with Transfer (Demo Sample Solution)
Start Coding Voice Elements – Write Your First Application In Minutes
Why Should I Develop My Own Voice Application?
Create a Simple Speech Recognition Application
Voice Elements Class Library

 

Was this article helpful to you? Yes 14 No