0

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.

Alfero Chingono
  • 255
  • 1
  • 3
  • 15

2 Answers2

1

As per the VoIP Info Wiki you can specify the callerid information on SIP extensions on a per extension basis like this:

callerid="Tuomas Tammisalo" <1000>

UPDATE: You can access the CDR variables on the call has started. "${CDR(src)}" would give you the source extension of the call.

dkwiebe
  • 651
  • 3
  • 8
0

After some investigation, I found out that I can get the information I need from ${CALLERID(num)}.

So, this is what I did:

[local]
exten => _NXXNXXXXXX,1,Set(line=${CALLERID(num)})
same => n,Verbose(line variable is <${line}>)
same => n,GotoIf($["${line}" = "line1"]?business-out,${EXTEN},1:family-out,${EXTEN},1)

[business-out]
...

[family-out]
...

Hope that helps someone

Alfero Chingono
  • 255
  • 1
  • 3
  • 15