• Announcing Velocity Version 3.0
  • The Award Winning Development Toolkit
  • IVR and Speech Applications
  • Free SDK
  • The Developers Choice

Download

velocity_download
Velocity Toolkit C# .Net Sample PDF Print E-mail
 
using System; 
using Glorsoft.Velocity;
 
Namespace Sample
{

  class Program
  {
    static void Main(string[] args)
    {
      // create a new engine
      VelocityEngine engine = new VelocityEngine();
      // set the call handler on channel 1
      engine.SetCallHandler(1, new IVRApplication());
      // start the engine
      engine.Start();
      Console.WriteLine("Engine running - ESCAPE to quit");
      while (Console.ReadKey().Key != ConsoleKey.Escape);
      // stop the engine
      engine.Stop();
    }
  }
 
  class IVRApplication : VelocityAsyncCallHandler
  {
    public override void HandleCall(VelocityChannel Channel)
    {
      Channel.Log("Waiting for a call");
      Channel.WaitForCall();
      Channel.Log("Received a call");
      Channel.AnswerCall(VelocityEngine.CallType.Voice);
      Channel.Log("Answered a call");
      // play a file and stop it
      // prematurely if the caller presses *
      Channel.PlayFile("welcome.wav", "*");
      // prompt the user to enter some digits
      // digit collection will terminate when
      // the caller enters 5 digits or presses *
      // it will also terminate if 3 seconds
      // elapse between digit presses
      VelocityDigitCollectionResult result = Channel.GetDigits("enter_pin.wav", 5, "*", 3, 3);
      if (result.Digits == "1234")
      {
        Channel.PlayFile("logged_in.wav", ""); 
      }
      else
      {
        Channel.PlayFile("access_denied.wav", "");
      }
      Channel.DisconnectCall();
    }
  }
}

 

Share

Dialogic Partner Logo

dialogic application partner