How to Get ANI information

I am assigned to write an application. It needs to get the caller phone number using ANI service. I am looking for an API to get the caller information using ANI.

  1. Can I use Asterisk to get the caller number using ANI?

  2. Does Asterisk work with all phone carriers and telephony products?

I am very new to this technology and Asterisk and appreciate your help,


We are asking the same question, jalilf. Look at my post, may be it could help me. So far, the answer I got did not make me more advanced.

Hi Jalilf,

So far, I found out two solutions (with a little bit programming).

Solution 1)

Connect to the Asterisk server IP port 5038 and listen to NEWCHANNEL events with an application.

Solution 2)

May be also you can configure your ATA so that it send new calls to any port on the PC connected to the ATA. Then you have write a dummy application server behaving like a mini-Asterisk (looping for waiting new calls events).

I did not try it ; but, my programmer’s backgroud tell me that it works. For doing that kind of programmation you need to have knowledge a little bit TCP/IP SOCKET programming in any programming language.

If you read french, you can have more understanding of the solutions in my thread (in Asterisk France) :

there are a ton of ways to get the callers ANI.

Asterisk Manager Interface (AMI) - can send you events over an open TCP connection which would let you know when a new call arrived.

AGI or FastAGI scripting - can allow you to temporarily gain control over the call and access its variables, which include caller-id

System calls - can allow you to pass ANI to some system executable

those are just three of the most common.

Thanks for your reply G2010,

I you see any code sample talking about those three solutions please let us know.