Let me explain how I am doing follow-me and call forwarding
With a2billing I am doing three things, calling cards, sip/iax connectivity via PBX and trixbox-type VoIP service, each with its own agi-conf
Forget about the calling card part of business because that isn't applicable to what you need
For the people who interconnect via PBX, well, everything is set up on their end. They can change their caller ID all they want; as long as they are going through my trunk they are being billed for international calls. If this is not working for you I can post an example of my agi-conf for that context
As for VoIP service, I have a separate box (trixbox) that I use for that stuff. I send incoming calls straight to trixbox, outbound calls via a2billing in order to take advantage of least cost routing and special routing. Normally, the extension number is the 10 digit telephone number of the customer, so in a2billing I just add that 10 digit number to the customer's Caller ID and everything works from there. However, call forwarding and follow me will not work. If only we could utilize the "accountcode" part of FreePBX for this, but it will only work if a2billing and freepbx are on the same exact server. Because this isn't the case, I created two outbound routes in the following order:
CF-Intl
CF-USA
For the "intl" trunk I have this entered, and all the calls are going through the default zap trunk (which generates all circuits are busy)
Code:
00.
011.
1242NXXXXXX
1246NXXXXXX
1264NXXXXXX
1268NXXXXXX
1284NXXXXXX
1340NXXXXXX
1345NXXXXXX
1441NXXXXXX
1473NXXXXXX
1649NXXXXXX
1664NXXXXXX
1670NXXXXXX
1671NXXXXXX
1684NXXXXXX
1721NXXXXXX
1758NXXXXXX
1767NXXXXXX
1784NXXXXXX
1787NXXXXXX
1808NXXXXXX
1809NXXXXXX
1829NXXXXXX
1849NXXXXXX
1868NXXXXXX
1876NXXXXXX
1907NXXXXXX
1939NXXXXXX
1NXX555XXXX
242NXXXXXX
246NXXXXXX
264NXXXXXX
268NXXXXXX
284NXXXXXX
340NXXXXXX
345NXXXXXX
441NXXXXXX
473NXXXXXX
649NXXXXXX
664NXXXXXX
670NXXXXXX
671NXXXXXX
684NXXXXXX
721NXXXXXX
758NXXXXXX
767NXXXXXX
784NXXXXXX
787NXXXXXX
808NXXXXXX
809NXXXXXX
829NXXXXXX
849NXXXXXX
868NXXXXXX
876NXXXXXX
907NXXXXXX
939NXXXXXX
NXX555XXXX
X11
For the USA trunk I just have the regular NXXNXXXXXX and 1NXXNXXXXXX inputted there.
After these first two routes comes the a2billing routes
Next step is to create a context. Since I want to give everyone local X11 and 7 digit dialing capabilities, I create a context for every area code. Here's an example of area code 212
Code:
[from-212]
exten => _XXXXXXX,1,noop(${EXTEN})
exten => _XXXXXXX,n,set(EXTEN=212${EXTEN})
exten => _XXXXXXX,n,goto(from-internal,${exten},1)
include => from-user
exten => 211,1,Dial(IAX2/A2Billing/12126399675)
exten => 211,2,Hangup
exten => 311,1,Dial(IAX2/A2Billing/12126399675)
exten => 311,2,Hangup
exten => 511,1,Dial(IAX2/A2Billing/18776905116)
exten => 511,2,Hangup
exten => 711,1,Dial(IAX2/A2Billing/18004211220)
exten => 711,2,Hangup
exten => 811,1,Dial(IAX2/A2Billing/18002724480)
exten => 811,2,Hangup
[from-user]
;This stuff MUST be in the correct order if you want this to be done correctly
include => from-internal-additional-custom
include => from-internal-custom
include => ext-group
include => ext-local
include => ext-group
include => ext-findmefollow
include => fmgrps
include => ext-queues
;include => outbound-allroutes-custom
;include => outrt-001-CF-Intl
;include => outrt-002-CF-USA
include => outrt-003-Emergency
include => outrt-004-International
include => outrt-005-USA
include => outrt-006-NY_PBX
exten => foo,1,Noop(bar)
include => from-internal
Fix up the outrt stuff according to your trunks. To get the outrt numbers, take a look at extensions_additional.conf. My outrt #s 3, 4 and 5 all go to the a2billing trunk. The last one is just for 611 dialing.
Make sure the top two trunks and outbound-allroutes-custom are commented out. This means that outbound calls will not go through these trunks.
Now you need to set the context per each extension to from-718 in this case.
Why is this going to work?
Out of the box, FreePBX only listens to the "context" definition when a call is physically placed from that extension. If you set up call forwarding, follow-me, or even do the built-in transfer that FreePBX gives you, it will automatically use the from-internal context. Although this isn't something good when setting restrictions, in our case it is 100% useful and never had a problem. Only disadvantage is that you cannot do LCR within USA with this setup, but then again how often are people setting up follow-me and call forward? I only have three customers doing follow-me and the average customer only does 1,500 minutes a month. If I am charging them $26.95 for unlimited divided by 1,500 minutes, that's almost 1.8 cents per minute that I am theoretically "charging" them. I am using tiered termination and it is very hard to get to 1.8 cents per minute, you need to be calling a VERY rural town.