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.

  • Are you using a GUI such a FreePBX on this Asterisk box? – dkwiebe Nov 16 '12 at 22:14
  • No, I'm using a terminal to make all these changes. – Alfero Chingono Nov 17 '12 at 23:13
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.

|improve this answer|||||
  • Thanks for the insightful response. However, I still need the functionality to detect the caller because, I send different caller Ids depending on which destination it is. I have several inbound numbers for different regions. – Alfero Chingono Nov 19 '12 at 14:20
  • Does ${CDR(src)} give you what you're looking for? – dkwiebe Nov 22 '12 at 19:10
  • Unfortunately, no. I was able to get it from ${CALLERID(num)} – Alfero Chingono Jun 6 '13 at 17:29
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

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.