How to achieve auto answer for SIP telephony in C#

/ Published in: C#
Save to your folder(s)

I had a go at softphone development some months ago. It isn’t secret that I want to build a powerful IVR system to make the current call centers much more effective. Yes, there are many similar software available on the market for this purpose, but I believe in my idea that can turn call centers better than ever. I’m intended to give a taste of my project from time to time. First, I present a short and concise guide on how to implement auto answering to be able to accept a SIP phone call immediately.

Let’s look at the prerequisites:

- PBX: To be able to make and receive SIP voice calls, a phone system (e.g. Asterisk) is essentially needed. You need to add a new SIP account in your PBX for this console application.
- Visual Studio: This solution is based on a console softphone, so a new Visual C# Console Application is just enough.
- VoIPSDK.dll: I used prewritten VoIP components to implement the SIP telephony feature. The necessary .dll file can be found on this website: It should be added to your references.
- Test phone: To test your application you can use any VoIP phone that supports video calling (e.g. Bria softphone).

After checking the prerequisites, take a look at the code. As it can be seen, just a few lines of C# code are enough to connect the application to a PBX and to build the auto answering. First of all, you need to implement the SIP registration. Thereafter, you need to create a softphone and a phone line object, then you need to specify the SIP account to be used for the phone line. These configurations are needed to be able to register to your PBX. After calling the RegisterAccount method the registration procedure starts, and the application will indicates its status due to the line_RegStateChanged method. The softphone_IncomingCall method is used to perceive the incoming calls, while the Auto_Answer_Method is responsible for accepting the incoming calls automatically. The call_CallStateChanged method is used to indicate the state of the call.

Test the program:

In order to demonstrate how this solution works, I provided valid SIP account details for this console application to be able to register to my PBX, and I also configured an other SIP account for my Bria softphone. After running the application, I dialled the telephone number of the console application by using Bria, and the console application accepted the incoming call automatically – without any human intervention.


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.