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.

2
  • Are you using a GUI such a FreePBX on this Asterisk box?
    – dkwiebe
    Nov 16, 2012 at 22:14
  • No, I'm using a terminal to make all these changes. Nov 17, 2012 at 23:13

2 Answers 2

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.

3
  • 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. Nov 19, 2012 at 14:20
  • Does ${CDR(src)} give you what you're looking for?
    – dkwiebe
    Nov 22, 2012 at 19:10
  • Unfortunately, no. I was able to get it from ${CALLERID(num)} Jun 6, 2013 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .