Callcentric and multiple DID Inbound routing [SOLVED]
Hi all,
I thought I'd post this message in case someone else is trying to accomplish the same thing with DID routing using Callcentric as a SIP provider.
My requirements were to use as little custom modification as possible and rely on Trixbox/FreePbx for everything else.
Background
You can get cheap DIDs with CallCentric however Callcentric stores the incoming DID identifier in the SIP header in the "TO:" field. So in Asterisk terms ${SIP_HEADER(TO)}.
This seems to cause problems for Trixbox as this is not where it seems to look for DID information.
In my case I have a few DIDs for my business and one for my home phone. I need to route any calls to my business DIDs into a time condition that will further route the call based on whether it's during business hour or not (this routing is handled by standard Trixbox and is not covered here). As for the home phone number, I want to route that to a ring group that will ring all of my home extensions (again, this ring group is setup the normal Trixbox way).
How to do it
In order to properly route calls based on the DID the caller dialed we need to add our own custom context to handle grabbing the correct DID number and routing on it.
The easiest way to do this is to place our contexts in the extensions_custom.conf file.
I'll write this so it will be easy for you to figure out how to handle your own situation.
First open up extensions_custom.conf in your favorite editor.
Add the following code and modify it to suite your particular situation (ie Your Callcentric number and DID numbers):
[custom-incoming]
exten => s,1,Set(Var_TO=${SIP_HEADER(TO)})
exten => s,n,GotoIf($["${Var_TO}" = <sip:1777XXXXXXX@callcentric.com>"]?timeconditions,1,1)
exten => s,n,GotoIf($["${Var_TO}" = <sip:15551234@ss.callcentric.com>"]?timeconditions,1,1)
exten => s,n,GotoIf($["${Var_TO}" = "<sip:15554321@ss.callcentric.com>"]?ext-group,200,1)
exten => h,n,Macro(hangupcall)
As you can see above, I've replaced my Callcentric id with Xs and used fictitious phone numbers. Obviously you'll want your own Callcentric account id and DID numbers in there.
The next step is to modify your default inbound route in Trixbox. You will need to set the destination of your inbound route to our custom context, using the Custom App: feature. So set the destination to be Custom App: with the following text:
custom-incoming,s,1
Once you apply the changes you should be all set!
Customizing
This custom context can easily be modified to route incoming calls to different contexts. I found the best way to figure out what Trixbox is calling a particular context is to temporarily set the incoming routes destination to the context I'm interested in, say a particular ring group or voice mail number. Then apply the changes and take a look at the extensions_additional.conf file and look for the "ext-did" context. We're interested in the last line of the context:
[ext-did]
include => ext-did-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => s,1,Set(__FROM_DID=${EXTEN})
exten => s,n,GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)
exten => s,n,Set(CALLERID(name)=${CALLERID(num)})
exten => s,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => s,n,Ringing()
exten => s,n,Goto(custom-incoming,s,1)
So in this case you can see by the last line there that our DID is routing to our custom-incoming context. But if you play around with your inbound routings you can see how it will refer to other contexts. For example, if I set the destination to be IVR: Main (my main Automated Receptionist) , the ext-did context revealed:
[ext-did]
include => ext-did-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => s,1,Set(__FROM_DID=${EXTEN})
exten => s,n,GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)
exten => s,n,Set(CALLERID(name)=${CALLERID(num)})
exten => s,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => s,n,Ringing()
exten => s,n,Goto(ivr-2,s,1)
Great! Now I know how to set my custom routing for IVR: Main. I just use "ivr-2,s,1" (your ivr number is probably different). Now setting the incoming route destination back to the Custom App: "custom-incoming,s,1". I can modify my custom-incoming context to route one of my other DID numbers by inserting the following line in my custom context:
exten => s,n,GotoIf($["${Var_TO}" = <sip:15551255@ss.callcentric.com>"]?ivr-2,s,1)
Just remember to restart or reload Asterisk after whenever you modify the extensions_custom.conf file or Asterisk won't see your changes.
Conclusion
So by just creating a simple custom context I can handle DID routing with Callcentric.
Hope this helps somebody out. I know I was frustrated with it for some time.
Good stuff.
Let me tell how I solved the same problem.
1) I opened a second free Callcentric account.
2) I registered this second account in Trixbox with it's own set of rules, etc
3) I went to the first account and setup call treatment in Callcentric. Every time a call arrives to the XYZ number, it gets forwarded to the SIP number of the second account.
Works perfectly and does exactly what your solution does. The forwarding to a SIP number is free. So I pay nothing more.
Good luck
NR
I have 10 DIDs with Callcentric, and am looking for the most efficient way to route by DID inside of trix.
The First post seems to address several DIDs coming into one account, where the last poster's idea seems to need an extra account for EACH DID. Therefore, I would need nine "freedom" accounts for treatments (forwarding)?
I am asking for someone to clarify my above statements.
Thanks
1. Create INBOUND ROUTE _1777XXXXXXX to HANGUP
2. Create INBOUND ROUTE 17031234567 (hereis your DID) to YOUR DEST (whatever you want as usual)
3. add to extensions_custom.conf
[from-pstn-custom]
exten => _1777XXXXXXX,1,Set(Var_TO=${SIP_HEADER(TO)}) ;get header
exten => _1777XXXXXXX,n,Set(SHT=${CUT(Var_TO,\:,2)}) ; cut before : -> 17031234567@ss.callcentric.com>
exten => _1777XXXXXXX,n,Set(CUSTOM_DID=${CUT(SHT,\@,1)}) ; cut after @ -> 17031234567
exten => _1777XXXXXXX,n,Goto(ext-did,${CUSTOM_DID},1) ; goto ext-did
So you can handle multiple CALLCENTRIC ACCOUNTs/DIDs :)
Please add the following into your extensions_custom.conf file:
[custom-incoming]
exten => s,1,Set(Var_FROM_DOMAIN=${CUT(CUT(SIP_HEADER(TO),@,2),>,1)})
exten => s,2,GotoIF($["${Var_FROM_DOMAIN}" = "callcentric.com"]?5:3)
exten => s,3,GotoIF($["${Var_FROM_DOMAIN}" = "ss.callcentric.com"]?5:4)
exten => s,4,GotoIF($["${Var_FROM_DOMAIN}" = "66.193.176.35"]?5:7)
exten => s,5,Set(Var_TO_DID=${CUT(CUT(SIP_HEADER(TO),@,1),:,2)})
exten => s,6,GotoIF($["${Var_TO_DID}" != ""]?ext-did,${Var_TO_DID},1:7)
exten => s,7,GoTo(from-pstn,s,1)
exten => h,8,Macro(hangupcall)
After doing so within the Trixbox CE interface please click on the “Tools” tab then “Custom Destination”. After doing so you would then create a Custom Destination that has “custom-incoming,s,1” (without quotes).
Then under Inbound Routes please create an inbound route, if you have not done so, with “17772847255” (without quotes) in the DID field and on the lower portion under Set Destination please make sure to select the Custom Destination that you have configured.
After doing so you should be able to add each of your DIDs (full numbers as shown on your Callcentric dashboard) within the FreePBX interface and send them to the destination of your choice.

Member Since:
2007-01-30