[solved] how get the calling extension name?

Hello all !

I have an extention in my sip.conf :


Now, when 2102 dials *97 I wand the person to listen to his voice mails.

Before I did this :
exten => *97,1,Set(CALLBACKNUM=${CALLERID(number)})

But now the CallerID does not correspond any more to the mailbox name, so I would like to use the extension’s name. (1001).

Thanks a lot for any hint on how to get this done !


here’s what my dialplan looks like
; voicemail check
exten => 6099,1,VoiceMailMain(100)}@default)
exten => *97,1,VoiceMailMain(${CALLERID(num)}@default)
exten => 7000,1,VoiceMailMain(${CALLERID(num)}@default)

*97 and 7000 do the same thing. 6099 makes you enter your mailbox number.

Hello sethsdad0627,

thanks for your feedback !

Yes, I use the same. But the problem is that my Callerid(num) is not the same as the mailbox name. It is the extension name that is the same, so I am looking for a way to get the extension name - you have any idea how to get this ?


If anything can help, it will be the SIPCHANINFO function.

Hi David,

to see how it works I tried this :

exten => 2322,1,Answer()
exten => 2322,n,SayDigits(123)
exten => 2322,n,SayDigits(SIPCHANINFO(peername))

knowing that my extension’s name is :

This doesn’t work. Do you have any idea why ?

Thanks for any hint,

By the way, do you have any idea about this ?

Are you sure that you are actually matching the callers as peers, rather than anonymously?

I’m not sure I can help more, but I think the sip.conf entries and maybe the sip show channel information might need to be included for others to help.

I’m thinking that for this task, you should look at doing a simple AGI to get the value and return that to your dialplan. Check out www.nerdvittles.com for some examples.

Arrgh!!! This is an ex-girlfriend dialplan hack. This should do the trick
exten => *97/2102,1,Voicemailmain(1001@default)

I put this on another post, but it is part of the original question

CALLERID(num) has the value of the calling extension.

Hello sethsdad0627 and david,

thanks a lot for your input.

In fact the CALLERID(num) really sends the whole caller id number and not the extension’s name. But I solved my problem by using the last four digits of the CALLERID (which corresponds to the mailboxe’s name).

exten => *97,1,VoiceMailMain(${CALLERID(num):-4:4}@default,s)

Thanks to you and see you soon,

Just a footnote - on internal calls, callerid(num) provides the extension number, on external calls, callerid(num) is the telco callerid if available.

In Asterisk, there is no concept of extension number for the incoming side of a call. The caller ID is either that supplied by the phone, or that configured in your .conf file.

Hello you two,

I agree with david, the CALLERID(num) takes the value set as callerid in the extention’s number :

sip.conf :
callerid=“MyFirstName MyLastName” <0033160009999>

in this case CALLERID(num) will give “0033160009999”, not “9999”.


one of you don’t have any hint on this one ? :smile: