Using a2billing for caller ID callback

Setting up callback in A2Billing can be a tricky thing!

Here I’ll do a walk through that will hopefully get you at least some of the way.

This guide was written using a SysAdminMan VPS running A2Billing version 1.9.4. I will be using for outbound calls and a inbound number for the callback access number.


This VPS template already has the following set up (if you are using your own installation you will need to ensure this) –

  • A2Billing callback daemon installed and running
  • Your callback server is correctly configured in A2Billing Admin – CALLBACK / Server
  • If you want to route the inbound call using FreePBX then you need a Custom Destination described here
  • Also described in that post is setting up a context to pass the call to A2Billing. For a2billing-cid-callback I now use a slightly modified version as below. This was to prevent double callback entries being created –
exten => h,1,Hangup
exten => _X.,1,Ringing
exten => _X.,n,Wait(2)
exten => _X.,n,DeadAgi(a2billing.php,1,cid-callback,) ;last parameter is the callback area code
exten => _X.,n,Hangup(38)

As I said the setting above are already included on the SysAdminMan VPS. One change we need to make is tell A2Billing which country the callback will be happening in. This is because the Caller ID will normally be presented without the country code, and we need to add that on to give A2Billing the correct number to dial.

My callback access number is going to be in the UK so I’m going to edit the context above and set the callback area code to ’44’. Don’t forget to reload Asterisk after making the change –

exten => h,1,Hangup
exten => _X.,1,Ringing
exten => _X.,n,Wait(2)
exten => _X.,n,DeadAgi(a2billing.php,1,cid-callback,44) ;last parameter is the callback area code
exten => _X.,n,Hangup(38)

I’m also going to assume you have the following set up already –


First we need to pass the inbound call to A2Billing. To do this I am going to create an Inbound Route in FreePBX and initially set the destination to ‘Terminate Call / Put caller on hold forever’ –

This is a great first step as it means we can call the number and should get music-on-hold. If we have any problems at this stage we know it’s absolutely nothing to do with A2Billing.

So, give the access number a call, make sure you get music, and then check in the FreePBX CDR reports and check that your CLID number is being presented (so that A2Billing will know where to call you back) and what format it’s in –

FreePBX CDR report

If your access number works OK then change the Inbound Route destination to a2billing-cid-callback –

customer destination a2billing-cid-callback


Now that our inbound call is working we need to tell A2Billing that if a call comes in with a certain caller ID it belongs to a specific customer. To do this edit the A2Billing customer and add the caller ID. We must add the caller ID in the format it it being presented by our DDI provider –

a2billing customer caller id


If you call your access number now you should get a couple of rings and then the call gets disconnected. You should see an entry getting added in A2BillingĀ  to CALLBACK/Add –

an a2billing callback entry

So, I got my entry in the callback queue but there are 2 problems with it! The first is that the number it’s trying to call is 44447… As my DDI provider presents the number in an international format there is no need for me to add it on again. So I can edit the extensions_custom.conf file above and remove the ’44’ that I added on to the a2billing-cid-callback context. You must reload Asterisk following this change –

exten => _X.,n,DeadAgi(a2billing.php,1,cid-callback,) ;last parameter is the callback area code

The second problem is that the call stays as ‘PENDING’. The callback daemon should be running every minute and picking up that entry and making the call. As it’s not changing from ‘PENDING’ we know it’s not doing this. Sometimes the callback daemon will start before MySQL, or loses its connection to MySQL. You can resolve this by restarting it –

service a2b-callback-daemon restart


And that’s it. I can now call the access number and a callback entry gets created –

working a2billing callback entry

The system then calls me back and tells me my balance and asks me to type the number I want to call. You must enter the number to call in a format that A2Billing understands (in other words it must work in the simulator –


Hopefully that will get you started, but it’s by no means easy. I hope to write a further post with some troubleshooting tips.

Be aware that if you plan on doing this in Elastix then that has an old version of A2Billing (and doesn’t have the callback daemon installed by default) so it’s likely to be much more complicated.

11 thoughts on “Using a2billing for caller ID callback

  1. Sugel

    The main reason CallBack is used as opposed to typical prepaid or postpaid calling platforms is simply to avoid international legality issues. Since VoIP calling cards and calling services are illegal in so many countries throughout the world CallBack allows the system Admin to place the equipment in a legal country and make the call from there.

  2. Tim

    Hi Matt,

    You mention that CallerId has to be inserted to customer’s CallerID list. But isn’t that tedious to do with many customers? Is there automated way?
    Maybe insert CID-Callback DID on all customer tables by default? But if it changed, you’ve to change it again.

    Also, what would be the Asterisk dial plan code for setting up inbound number to callback extension that you did using FreePBX in this post?


  3. akbari

    i install elastix 2.3 and configure a2billing with this site help but when i want to active cid-callback , i cant find a2b-callback-daemon.
    please help me about it.

  4. matt Post author

    If I remember correctly the callback daemon for a2billing is not installed as part of Elastix.

  5. akbari

    what should i do for resolve this problem? i browes a lat of page in the internet but don’t find any things for active cid-callback in elastix ? is there any other way for work with cid-callback integrated with freepbx?
    thanks a lot for your answer

Comments are closed.