Get the extension number of the phone

I have an digium app that talks to a dual-headed JSON<->PHP<->AMI and it get MailboxStatus (and perhaps anything on AMI) I don’t want to talk directly to AMI as I want to have AMI listen only to loopback.

I need to pass the extension number to the “id” of the JSON request.
how do i get the extension number (and hopefully the context) and other details of a phone?

The extension number isn’t something known by the phone. Only Asterisk knows the extensions. The API also doesn’t expose the SIP user or pass to custom applications. So, if you want to pass in something to an application that’s analogous to an extension, just pass in your own values when you load the application onto the phone.

If you’re going the XML route, see the “settings” child element here: … ovisioning


I know that custom apps are different than factory default apps. But how did the “Voicemail” app able to determine the extension number of the phone?

When i use the Voicemail app on a digium phone, it just gives me the list directly.

I hope there’s another way to get the line number and potentially the context so I can move that to AMI’s MailboxStatus routine.


Because DPMA knows the session of the phone and the SIP peer for that session, and, by inference, the app_voicemail mailbox for that SIP peer. Custom apps have no such ability to reach into the bowels of Asterisk that way. It’s DPMA magic.

You’ll have to figure that out, and you’ll have to pass it to your application as settings. Your app won’t be able to derive that from Asterisk.


I had a similar problem lately and maybe you can use the way I solved it, too:

The account_id in the Auth-Object equals the phone number in our company so if you do the following you’ll may get the info you need:

var app = require(‘app’);
var authObj = app.getAuth();
var Account_ID = authObj.getAccountId();

If not: The authObj has a method getCredentials() also where you possibly find the information you need…