Using Asterisk.NET API

Hi all!

I’m trying to create a simple application in C# which pulls the specific website based on inbound DID number. I’m using Asterisk.NET API and created a form which allows me to connect to Asterisk and get the basic information about the incoming call by utilizing the following code:

private void astCon_NewState(object sender, Asterisk.NET.Manager.Event.NewStateEvent e)
textBox1.Text = e.Attributes[“connectedlinenum”];
textBox2.Text = e.Attributes[“connectedlinename”];
textBox3.Text = e.ChannelStateDesc;
textBox4.Text = e.Channel;

How would I be able to get the DID number through which the call was made and reached my extension? I’m assuming it will be another value in Asterisk.NET.Manager.Event.NewStateEvent.Attributes["???"] dictionary?

Thank you in advance

Very few people use AMI from .NET. Most will use PHP or Perl.

What gets passed to AMI clients will depend on the details of your dialplan. If ${EXTEN} doesn’t have the information you want, because the dialplan extension has changed from the DID number, you will need to add code to the dialplan to set the value into a variable.

In any case, the class libraries are third party developments, so you should be looking for their support pages, not the Asterisk ones.


Thanks for the prompt reply!

The reason why I use AMI.NET because I want to implement that little piece of code into ASP.NET web page. I haven’t really thought of using PHP, Perl or anything else.

How would I even get the ${EXTEN} into my C# code? From what I understand by using the classes in Asterisk.NET.Manager namespace I can pull the information on the incoming call.

The ${EXTEN} value is including in the Extension: parameter of the Newexten AMI event, which is generated for each new priority executed in the dialplan.

How that maps into your .NET class library will need to be asked on the forum (not on this board) that supports that class library.

Hi, I was wondering if you were successful in finding information about using AMI.NET? I’m trying to do something similiar