Determine which user initiated call in Asterisk
Posted
by
adaptive
on Server Fault
See other posts from Server Fault
or by adaptive
Published on 2012-11-16T15:33:41Z
Indexed on
2012/11/18
23:06 UTC
Read the original article
Hit count: 177
asterisk
I had the following code in my extensions.conf
file:
[local]
exten => _NXXNXXXXXX,1,Set(CALLERID(name)=${OUTGOING_NAME})
exten => _NXXNXXXXXX,n,Set(CALLERID(num)=${OUTGOING_NUMBER})
Now I want to change this code to set the CallerID and number based on the user/extension that is making the call. In fact I have four(4) users/extensions in my sip.conf
and only one of them (the one I use for business) is supposed to send a different caller id/number.
Everything is in the same context (for simplicity) since all lines need to be able to pick up an incoming call. The only difference is when line1
needs to make a call, it has to send a different caller id/number and use a different provider.
This is what I have so far:
[local]
exten => _NXXNXXXXXX,1,Set(line=${SIP_HEADER(From)})
exten => _NXXNXXXXXX,n,Verbose(line variable is <${line}>)
exten => _NXXNXXXXXX,n,Set(CALLERID(name)=${IF($[ ${line} = line1 ]?${COMPANY_NAME}:${FAMILY_NAME})})
exten => _NXXNXXXXXX,n,Set(CALLERID(num)=${IF($[ ${line} = line1 ]?${COMPANY_NUMBER}:${FAMILY_NUMBER})})
exten => _NXXNXXXXXX,n,Dial(${IF($[ ${line} = line1]?SIP/${EXTEN}@${COMPANY_PROVIDER}:SIP/${EXTEN}@${FAMILY_PROVIDER})})
I really don't know if this is correct and I'm afraid to commit these changes to my extensions.conf
before validating.
Any help will be greatly appreciated.
© Server Fault or respective owner