Search code examples
c#tapi

Dial second part of an organization number when phone line is answered by TAPI in C#


I'm developing an application by TAPI technology in C#.

Suppose that I want to make a call to an organization that has a central device. I want when the target machine answers the phone line, my app dials the second number that is an internal number to that organization. I don't know how to dial the second number.

For example I want to call +1234567890 and when the phone line is answered, I want to dial 101 that is an internal number. My app dial's the first part of number perfectly, but i don't know how to code the second part.

numberList = "001234567890#101".Split('#');

tapiManager = new TapiManager(ProjectName);
tapiManager.Initialize();
lineName = (tapiManager != null && tapiManager.Lines.Length > 0 ? tapiManager.Lines[0].Name : string.Empty);
tapiline = tapiManager.GetLineByName(lineName, true);

if (tapiline == null)
     tapiline = tapiManager.GetLineByName(lineName, true);

if (!tapiline.IsOpen)
     tapiline.Open(MediaModes.DataModem);

makeCallParams = new MakeCallParams();
makeCallParams.DialPause = 2000;

tapiCall = tapiline.MakeCall(numberList[0], null, makeCallParams);

As you see the last line of my code dials the first number, but I can't find a way to dial the second part.

Any ideas about how I can do that?


Solution

  • This very much depends on what this central device is and how it handles your call, so I'll give a few examples:

    • An older (think analogue) PBX/Appliance will likely accept any digits after it has accepted the call. This you can do by including pauses in your number (usually "." or "," or "p") so "001234567890,,,,,101" (warning: not all TAPI drivers will support this). How many pauses really depends on the speed this central device picks up, too few it will cut of a part of the number, too much and it might hangup.
    • An IVR or PBX trunk that is specifically configured for this kind of setup should simply accept the full number in the original call, strip off the root number "001234567890" and dial "101" itself (strip out the "#").
    • An IVR/Voicemail or some other system that play's a message like "Which extension do you wish to call?" usually only accept digits after the message starts or end (barge-in allowed or not). Detecting voice is notoriously difficult, your best bet here is just to guess how long the message is, wait and then put the "101" on the line. (i don't know the lib you are using but the function is probably called GenerateDigits)