Click or drag to resize

Get Started Coding : Write Your First Voice Application in Minutes

This page provides a starting point from which to launch a basic telephony project using Voice Elements in Visual Studio. It will walk you through some samples provided by Inventive Labs to get you started. It will provide a basic framework for inbound and outbound calling in both C# and Visual Basic.

This topic contains the following sections:

This guide will require you to have the Voice Elements toolkit installed. It will also refer to and show samples from the "Sampler" and "Skeleton" Projects, which you should locate and have ready to get started. First, let's make sure you have these ready.

Voice Elements Toolkit

If you have not already, you must at least download a demo version of Voice Elements and install it from here.

Voice Elements Sampler

This sample program, including a working Windows form application and all source code is included in your Voice Elements toolkit installation. You may run the application from the Start Menu and place some test calls. We suggest you do this before proceeding. You may find it here: Start Menu > Voice Elements Developer > VE Sampler Program.

There is also a full Visual Studio solution for this program, called "VESampler.sln", which is installed by default into C:/Inventive Labs/Voice Elements Developer/VESampler directory. Note that the installed sampler is written in C#, not Visual Basic. To obtain the VB version, you can download it here. If you cannot find the sampler at all, please re-install Voice Elements.

Skeleton Projects

These basic solutions provide you with an easy way to get started by giving you one place to build your solution with just the needed components without the overhead of the samplers. They consist of solution files, project files and some basic classes we will walk through below.

They are installed by default into C:/Inventive Labs/Voice Elements Developer/VESampler/VE directory. You can simply copy them, rename and start building your application. If you do not have them or are not sure if you have the latest versions you may download them any time.

Download the C Sharp Skeleton

Download the Visual Basic Skeleton

Step 1: Connect to a Telephony Server

Whether your application handles inbound calls, places oubound calls or does both, you must first connect to a Voice Elements Server. When you download the Voice Elements (VE) demo and install it, you receive 120 minutes to use on the Inventive Labs Telephony Bank. You may also setup your own server and connect to it as described below. For information on setting one up and licensing, contact Inventive Labs sales.

Below is the Starting Point Code used for telephony server connection and setup in the skeleton projects.

  • In the C# Skeleton, go to "IvrApplication.cs"
  • In the VB Skeleton, go to "IvrApplication.vb"
  • Using VE Sampler, go to "Sampler.cs"

    System.Net.IPAddress[] ips = System.Net.Dns.GetHostAddresses("");

    if (ips == null || ips.Length == 0) throw new Exception("Error: Could not resolve Telephony Server specified!");

    string sIpaddress = @"gtcp://" + ips[0].ToString() + ":54331";

    Log.Write("Connecting to: {0}", sIpaddress);

    s_TelephonyServer = new TelephonyServer(sIpaddress, "username", "password");

        // Client Session mode means that the server will stream and cache the files to/from your client machine.
            // Files are flushed after you disconnect.
        // Server mode means that the files reside on the server and will use the full path name to find them there.
            // Server mode can only be used on your own dedicated VE server.
    s_TelephonyServer.CacheMode = VoiceElements.Interface.CacheMode.ClientSession;

    // Subscribe to the new call event.
    s_TelephonyServer.NewCall += new VoiceElements.Client.NewCall(s_TelephonyServer_NewCall);

    // Subscribe to the connection events to allow you to reconnect if something happens to the network connection to the server.
    // If you are running your own VE server, this is less likely to happen except when you restart your VE server.
    s_TelephonyServer.ConnectionLost += new ConnectionLost(s_TelephonyServer_ConnectionLost);
    s_TelephonyServer.ConnectionRestored += new ConnectionRestored(s_TelephonyServer_ConnectionRestored);

As you can see, the comments in the code explain where to replace critical settings and give some indication of the critical steps. Below is a list of the important elements used in order so you can use this page to link off into the documentation and explore the classes, methods and properties used to better understand the concepts behind the code.

Now let's step through the code above in detail. Follow the links to explore the individual elements.

  1. Use System.Net namespace classes to resolve th IP address of your VE Server.
  2. Create a new TelephonyServer object. By creating it, you are "connecting." This object and its children will provide you with all voice functions in your application.
  3. Set your CacheMode. This determines how your application handles the storage of any voice files you will play.
  4. Subscibe to NewCall events. This will tell the server to raise new events when inbound calls arrive. All inbound processing will occur from this event.
  5. Register inbound DNIS numbers or number ranges. Do this using the RegisterDNIS method and its overloads to tell the server which specific number(s) you would like sent to your application.
  6. Lastly, subscribe to all ConnectionLost and ConnectionRestored events to allow your application to execute support actions if your connection to the server is somehow interrupted.

Step 2: Drop Into a Loop and Wait for Events or Delegate Outbound Calls

This step is coming soon.