1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Check out the 6 new Certified Incredible PBX Builds for Asterisk 11 and 13 featuring CentOS 6, Ubuntu 14, Raspberry Pi 2, and Asterisk-NOW.
    Dismiss Notice

A2Billing - An Adventure in PBX Billing - Part 1

Discussion in 'Add-On Install Instructions' started by tshif, Dec 18, 2008.

  1. tshif

    tshif Guru

    Free Extension to Extension Calls via DID


    I spent some time thinking about this one - and then talked with Joe about it. We agree that Joe's original answer is correct for the typical install of A2B, but in our situation - it wont quite work.

    Because we are billing for inbound calls, we already have a rate for the DID - its the inbound rate. If we change that rate to zeros, the outside inbound calls would be billed as zero also..

    I'm going to suggest another approach. It keeps the calls from being seen by A2B, so if you need A2B to have call records of these calls - this plan will NOT work for you. If you do not bill for inbound calls - then use Joe's original solution - and your DID-dialed extension-to-extension calls will be free, AND they will be listed in A2B. At the moment, I don't have a way to both bill for inbound minutes, and allow for DID dialed extension to extension free calling.

    This should meet your goals of letting your extension users dial other extension users via their DID, and make the call free for both parties - as if they had dialed the extension.

    Free PBX: Create Misc Application
    In FreePBX, Under Setup, Misc Application, select Add Misc App.
    Create the Misc App with the following characteristics:
    Description: the 10 digit DID you are configuring-Local
    Feature Code: the 10 digit DID you are configuring
    Feature Status: ENABLED
    Destination: Extension: the extension of the DID you are configuring.

    When you have all the entries as described, save your changes, apply configuration changes, and continue with reload.

    Now, when any extension dials the Feature Code you established for the FreePBX Misc Application, it will be recognized as an extension to extension call, and not be sent to A2B. There are no dialing rules here, so the caller must dial the exact number you entered - as I recommend above, the 10 digit version of the number (for USA use).

    Let me know if I misunderstood you goals -

  2. tshif

    tshif Guru

    The Further Adventures in A2Billing – Calling Cards - Part 1

    For this adventure in A2Billing, we will activate another cool part of our Family Telephone System platform.

    In an earlier article I mentioned that A2Billing is a great platform for calling card services. Calling Card services allow a user to call into the PBX, authenticate themselves, and then place outbound calls from the PBX which are billed to their A2B account.

    In our case, we can think of it as being rather like DISA with billing.

    For a variety of reasons, it can be very desirable to be able to call into your PBX, get a dial-tone, and make an outbound call. So desirable in fact that FreePBX has DISA to facilitate that very thing. However – DISA isn’t billed – and that’s not going to work.

    What we need is a DISA like solution that keeps A2Billing happily in the loop and rating (billing) these calls.

    Here are the general steps we need to take to accomplish this.
    • Have an available DID to use for the inbound calls.
    • Create a new agi-conf context to be used to configure the behavior of A2B when it is handling calling-card calls.
    • Create a Custom Destination for the new agi-conf context.
    • Create a new context to route the inbound Calling Card DID to the new agi-conf context.
    • Configure A2B with users CID to allow for pass-through authentication in A2B. This way, the inbound callers’ caller id is used to authenticate them – and they are not prompted to authenticate by entering their card number.
    Creating the agi-conf
    The agi-conf contexts determine specific behaviors related to how A2B processes the calls run through it. We will create one designed for the Calling Cards behaviors. In FreePBX, Tools, Config Edit, open a2billing.conf.

    Near the bottom of the file, you will find the context called agi-conf1. This context was setup and configured during a previous article – to reflect the behavior we wanted for outbound calls. Review those settings briefly to recall your previous decisions.

    Now, in the editor, copy the context agi-conf1, and paste it immediately below. Change the context name of the newly pasted version to [agi-conf2].

    Within the newly created agi-conf2 context, locate the line:
    use_dnid = YES - and change it to use_dnid = NO

    When you have made the change, click UPDATE to save your changes.

    Since the rest of the settings in the agi-conf2 file are based on your previous decisions for outbound call behaviors (from agi-conf1) – there’s little benefit the changing any of the other settings. By leaving them, your users will experience very similar outbound call behaviors from both inside the system, and when using calling card services.

    Creating the Calling-Card Dial Plan
    Eventually we have to provide a FreePBX destination that gets the inbound calling-card user into the a2b agi-conf2 context that we created above. To do that, we will edit another config file in the FreePBX Config Editor: extensions_a2billing.conf.

    You will recall in a previous article we created 2 contexts at the bottom called [custom-a2billing] and [custom-a2billing-did], which we had based on the contexts at the top of the file called [a2billing] and [a2billing-did]. Those previously created contexts are used by A2B to process our inbound and outbound calls right now.

    At the bottom of the extensions_a2billing.conf file, paste the following new context:

    ;For call through service
    exten => _X.,1,Answer()
    exten => _X.,n,Wait(1)
    exten => _X.,n,deadAGI(a2billing.php|2)
    exten => _X.,n,Hangup

    This context is based on our [custom-a2billing] context, with some changes and additions.

    Because this context will be used by a process that plays a sound file, we have added the ANSWER line as the first line of the context. (Its not desirable in the [custom-a2billing] context because that context only transfers calls.)

    Because we want the line to finish connecting and stabilize before beginning the outbound sound file playback, we added the WAIT line as the second line.

    Lastly, we changed the final digit in the deadAGI line from 1, to 2. This is the change that actually directs the call to use the agi-conf2 context we created in the previous step.

    When you have made the change, click UPDATE to save your changes.

    Creating the Calling Card Custom Destination
    We must expose the new agi-conf2 context in FreePBX so that the Calling-Card DID can be routed to it. From Inside FreePBX, Tools, Custom Destinations, select Add Custom Destination.
    Create a New Custom Destination with the following characteristics:
    Custom Destination: custom-a2billing-2,${EXTEN},1
    Description: A2Billing Calling-Card
    And Submit changes to save your work.

    You will notice that the Destination context we specified is the exact name of the context we created in extension_a2billing.conf in Creating the Calling-Card Dial Plan, above.

    Direct the Calling-Card Access DID to the AGI-CONF2 Context
    The last piece of this puzzle is to direct the Calling Card DID to the new Custom Destination.
    From Inside FreePBX, Setup, Inbound Routes, decide if you are going to add a new DID route, or modify an existing one. Either way, Set Destination of the inbound route to:
    Custom Destinations: A2Billing Calling Card

    When you have made the change, click Submit to save your changes. Then Apply and confirm your configuration changes.

    Pick up any phone, and dial into the Calling Card DID. You should be prompted by recording to enter your Card Number. Punch in any A2B account card number that has credit enough to make a call. You should be asked for the destination phone number – which signals that you have been successful. Test it by entering a valid card number and making a call.

    When you have proven that our work so far has been successful, we will add another cool feature – what I call A2Billing pass-through authentication.

    A2Billing Pass-through (CID) Authentication
    A2Billing normally prompts calls coming in to the Calling Card DID for the users A2B Calling Card number. If you use the Calling Card facilities often, it could become tiresome to enter the card Number each time you want to make a call.

    Enable A2B Caller ID Authentication
    Nicely enough, A2B offers a way ‘round this. Once again, in FreePBX Config Edit, open a2billing.conf, and select the agi-conf2 for editing. Locate the line shown below and set cid_enable=YES

    ; enable the callerid authentication
    ; if this option is active the CC system will check the CID of caller
    cid_enable = YES

    Click Update to save your changes.

    This activates the caller ID authentication ability in A2B, but only for the Calling-Card Inbound Line.

    Add Caller ID information to A2B User Account
    Any user for whom you wish to activate Caller ID authentication will need at least one CID registered with A2B. There are two ways for this to happen. The A2B administrator may do it, or the end user may be permitted to do it.

    The Further Adventures in A2Billing – Calling Cards - Part 2
  3. tshif

    tshif Guru

    The Further Adventures in A2Billing – Calling Cards - Part 2

    The Further Adventures in A2Billing – Calling Cards - Continued

    User Managed CID Registrations
    To configure A2B to allow the users to manage their Caller ID registrations, we make another edit in a2billing.conf. This time, locate the context called webcustomerui. Inside that context locate the line which reads:
    ; Let the users add new callerid
    callerid = no

    and set it to

    callerid = yes

    Click Update to save your changes.

    Now, your users have a menu item in the A2B web interface called ADD CALLER ID. From here, they can add and remove Caller ID’s to and from their A2B account. Phones sending this Caller ID will be automatically authenticated by the A2B Calling Card service, and the user will not be prompted for their Card Number.

    Administrative Management of User Caller ID Registrations.
    The administrato may always add or remove users Caller ID registrations from inside the A2B Admin webui. Under CUSTOMERS, select List Customers. Locate the custom for whom you wish to manage CID registrations and Select EDIT.

    At the bottom of the User Account Details screen, you will see the controls for adding and deleting CID registrations for this customer. When you have finished, click Confirm data to save your changes.

    Weather the users manage their CID registrations, or the Admin does so, the caller ID’s entered must be exactly what A2B will receive from the carrier/device. If the phone sends 10 digit caller ID’s, that’s what must be entered into A2B. If the phone sends 11 digit caller ID’s, that’s what must be entered into A2B.

    Once you have completed these steps, call into the Calling Card DID with a phone whose caller ID you have registered with an A2B user account. Instead of being prompted for your Card Number, you should simply be asked for the number you wish to dial. Aint automation cool?

    Used without care, this capability could easily compromise your PBX security. All a person has to do to in order to place calls through your PBX is to call the Calling Card DID, and send a registered Caller ID – no other security measures are invoked.

    The Calling Card service is just another cool capability you may offer to your end users. Like any other special feature – it will be very popular with some users, and completely ignored by others. Ah well, like I’ve said before – people like choices.

    Until Next time –
  4. jroper

    jroper Guru

    Further to this, there is also a setting in A2Billing that will take the received caller ID, and attach it to the card number on first input of the correct PIN.

    Just got to be a bit careful so you don't leave public phones authenticated to your account.

  5. tshif

    tshif Guru

    The Further Adventures in A2Billing – Handling Multiple Extension in the Same Home

    One of the possible hurdles in VoIP use in the home is that VoIP phones don’t behave exactly like their analog cousins.

    For example, when you call someone’s “landline” all the phones in the house ring at the same time, and the call can be picked up on any of them. To do that today, VoIP needs ring groups.

    If one of the families involved in our phone system chooses to have multiple phones, we will want to emulate that “ring everywhere” behavior that users are accustom to.

    And what if someone wants to switch phones and continue the conversation in a different room? With analog, you just pick up the phone in the next room, and then hang up the original one. With VoIP, you might be able to transfer the call to another phone in the house – but then you have to remember every phones individual extension. That’s not very intuitive. But if all you have to do is remember a 4 digit (ring group) code, you can transfer a call back to the ring group so every phone will ring and you can pick it up again wherever you want to.

    Another reasonable expectation home users have is that they get a central “answering machine” or voice mail for the family telephone number. If we are trying to emulate analog phones, we need to have it work so that when a call comes in, all of the phones ring. Then, if no one answers, the call is sent to a “family” or common voice mail box. This way, any family member can retrieve it from any phone in the house.

    It should also be possible for some family members to have their own private inbound DID’s that go directly to their extensions, bypassing the Ring Group. If unanswered, callers should be sent to the users private voice mail box.

    Of course, we need to accomplish this without breaking our nice new A2Billing setup.

    Here are the design goals:
    • Route The Jones family DID to a Ring Group
    • The ring group must support as many extensions as exist in the Jones home
    • Route the Dedicated DID’s to the proper extension, bypassing the Ring Group
    • Support a common Voice Mail box for the “family” telephone number, and private voice mail for the extensions that have personal DIDs assigned to them.
    • Billing must not be broken.
      • Calls placed to the Ring Group must be billed to the Family A2B account.
      • Calls Placed to dedicated DID’s must be billed as the customer desires. Either to a common A2B account, or to the individual DID users A2B account.
    Here’re the basic steps we will take to get there from here.
    1. Create the Ring Group
    2. Create a misc application to provide a path to the Ring Group
    3. Create an A2B Rate Card to the new Ring Group Destination
    4. Edit the A2B Destination for the Jones’ DID
    5. Verify that the FreePBX Account Codes reference the correct A2B account for Billing Purposes
    6. Verify the FreePBX mailbox variable references the correct voice mail box for each household extension.
    We presume you already have set up your PBX as per the rest of the main 6 Part article,
    and that the DID we are working with is already routed to an end user successfully and working fine with A2Billing. If not, don’t bother proceeding now, as it won’t magically start working just because we are adding the Ring Group. Get it working before you continue.

    Making the Family ViOP PBX pretend it’s an analog home phone
    To accomplish our goals, virtually none of the call flow between FreePBX and A2Billing needs to be changed. Any DIDs dedicated to private-line use for individual family members that are already configured and working in the PBX will not have their configurations changed by these procedures. We will however verify that the correct financially responsible A2B account has been assigned for each extension in FreePBX.

    Essentially, the inbound call flow for the DID stays the same. It still requires an inbound route in FreePBX, and it still gets send directly into A2B via the FreePBX Custom Destination A2B-DID.

    The ONLY change to call flow, is the A2B destination for the family DID is changed to the extension of the Ring Group, instead of any of the Jones’ actual extensions.

    Step 1: Configuring Voice Mail Support in FreePBX
    Preparing the extensions for a Common Voice Mail Box
    First, pick an extension at the Jones home that is unlikely to have a dedicated user – such as the Living Room Phone. Well say that’s extension 1020. In FreePBX, when configuring this extension, and all other extensions that will not have a dedicated user, we will set their mailbox variable to the same value (1020@default). This means when the users of any of these “non-dedicated” extensions picks up and dials 97 for voicemail, they are connected to the common family inbox. This emulates an answering machine.

    Preparing the extensions for a Dedicated User Voice Mail Box
    Some of the extensions may be of a more dedicated nature – such as phones in bedrooms of family members who also have their own private DID assigned to their phone. In the new arrangement, these dedicated extension will ring for both the private inbound DID, and well as the family inbound DID. In FreePBX, these extensions should be configured to use their own private mailboxes (theirextension@default). In this way, when they dial 97 to reach VM, they are connected to their private voice mail boxes. (They can dial 98 to reach the family mailbox, as long as they know the proper extension and password)

    At this time it is also wise to verify that the FreePBX Account Code for each extension is correct. In the case of the main family DID – the Account Code should be the A2B account number of the Individual who is responsible for paying the phone bill that rings in on the ring group.

    I’m the case of dedicated extension, the A2B account code for the party responsible for paying for the calls to and from that particular extension should be entered in the FreePBX Account Code field. This may be another individual in the family who has primary use of that phone and whose DID is routed there. Or, it may be that the main family payor has agreed to cover the bills for this extension. Find out how your users want to be billed, and make those arrangements come true using the FreePBX account code filed for each extension.

    Step 2: Create the Ring Group
    In FreePBX, Setup, Ring Groups, select Add Ring Group. Create an IVR with the following characteristics:
    Ring Group Number: any valid extension (keep the 10xx pattern to maximize a2b integration ease.)
    Group Description: Jones Ring Group
    Ring Strategy: Ring All
    Ring Time: Any value you want before going to voicemail – Max 60
    Extension List: List all the extensions in the Jones House – including dedicated ones
    Play Music on Hold: Ring

    Destination if no answer:
    VoiceMail: the extension selected for the common “Living Room” phone at the Joneses.

    Step 3: Configure A2Billing
    In FreePBX, we leave the inbound route for the main Jones family DID going directly into A2B. The same thing for any Private user DID in the Jones household.

    Inside A2Billing, we need to make a couple of alterations.

    Add / Modify Rate
    Before A2B can route calls to the Jones Ring Group, it has to have a valid rate for that destination.

    If the family DID is already covered by a rate in the Local Destination RateCard, then you will edit it. From in A2B admin webui, Under RATECARD, select browse rates. In the dropdown box, select Local Destination, then click SEARCH.

    A list of your current DID Rates will be listed. Locate the DID to be used as the “main family” DID, and click EDIT.

    Change the PREFIX field to Your Ring Group Extension (Assigned in Step 2, above)

    Handling Multiple Extension in the Same Home - Part 2
  6. tshif

    tshif Guru

    Handling Multiple Extension in the Same Home - Part 2

    Handling Multiple Extension in the Same Home - Continued

    If the family DID is not yet covered by a rate
    in the Local Destination RateCard, we will add one. From inside the A2B admin webui, under RATE CARD select add rate. Create or edit the rate for this DID with the following characteristics:
    RATECARD: Local Destination
    DIAL PREFIX: Your Ring Group Extension (Assigned in Step 2, above)
    DESTINATION: Jones Family 10 digit DID
    BUY RATE, BUYRATE DURATION, BUYRATE BILLING BLOCK, and the corresponding SELL RATES need to be set to the values you have determined are appropriate for this inbound DID. (As you did when you created the inbound DID billing function, in previous parts of this article.)

    When you have all the settings arranged as desired, save your changes with CONFIRM DATA.

    Create/Modify Destination
    Now, we must tell A2B to route The Jones Family inbound calls to the new Ring Group, instead of directly to any particular extension.

    If the family DID already has a destination listed in the DID Destination list (Under DID, List Destination, then you will edit it.

    From inside the A2B admin webui, under DID, select List Destination. Locate the destination for the Jones Family DID, and select EDIT.

    On the DESTINATION line, change the value from whichever extension it was assigned to the Ring Group Extension (Assigned in Step 2 above), and CONFIRM DATA.

    If the family DID does not yet have a destination listed in the DID Destination list, then we will create one. From inside the A2B admin webui, under DID, select Add Destination.
    On the DESTINATION line, theRing Group Extension (Assigned in Step 2 above)

    In the ID Card field, select (using the tiny little yellow arrow) the A2B account of the person financially responsible for inbound calls on this DID.

    In the DID drop down box, select the Jones Family DID.

    In the Activated radio button, select Yes

    VoIP_CALL must be set to NO.

    When you have the information arranged the way you want it, select CONFIRM DATA.

    That’s it – give it a try. Pick up a phone, and dial the Jones’ main inbound DID. All the extension in the house will ring. If they go unanswered, they will be sent to the common household voice mail extension of (1020).

    Any Private-line DIDs that were previously routed to other extension inside the Jones HouseHold are still working exactly the same as they always did, accept their phone now ALSO rings when the family number rings.

    Until next time -

  7. nsukho

    nsukho New Member


    Joe & Tony; thanks for your reply.
  8. tshif

    tshif Guru

    The Further Adventures in A2Billing – Adjusting Voicemail & Recordings Web Interface

    The Further Adventures in A2Billing – Adjusting the Voicemail & Recordings Web Interface
    Hurray and congratulations to cousin Michael – who along with his wife produced a brand new beautiful baby girl just a wee bit after Christmas.

    Upon arriving home with their new bundle of joy – they got onto the Family Phone System and in less than 1 hour – the new family member had been introduced – live and in color – by video phone to the entire family from Indiana to California and in between.

    Of course I am delighted – and I have to admit to heaving a big sigh of relief when I discovered that the entire family is not only using the Family Video Phone System – but they are using it a LOT. You never can tell when a new technology will excite folks, and when it will be a big fizzle. It looks like our instincts were good when we thought this would be popular. Yay!

    So – now the relatives on the other side of the family have seen what we have – and want to get involved. While they get ready to buy a Video Phone to add to the system – I thought we should take a quick look at fixing something that was a bit undesirable for our purposes, in the Web Voicemail & Recordings Interface (previously known as ARI) .

    When you log into Voicemail & Recordings, you are presented with your list of pending voicemails, and etc. In this VoiceMail Box view, there are controls along the top that allow the user to delete and move voicemails. These two controls are just fine, but the last set of controls in this area, the Forward_To Button and drop down box are a bit of an issue.

    Since we have multiple families – and now even a wider circle of families, using this system, being able to forward voice mails to everyone in the system seems cumbersome, and possibly fraught with privacy issues. I think we should NOT show a list of extensions and names of other users in this kind of environment. (Would AT&T Web Voice Mail allow you to forward your voicemail to anyone else on the AT&T network? YIKES)

    So – let’s get into the Voicemail & Recordings code and make a few quick changes.

    In winscp, locate /var/www/html/recordings/modules/voicemail.module. Job-one is to make a backup copy of the original on your local PC in case something dreadful happens during your editing.

    There are two areas we will be changing. The part of that collects the information to populate the Forward To dropdown box, and the parts that displays the Forward To button and dropdown box.

    Step 1:
    We will comment out the lines that would be used to build the contents of the Forward To drop down box. Since we won’t be displaying it, we might as well stop going through the time and effort to build it.
    Open the /var/www/html/recordings/modules/voicemail.module file for editing, and look for a section of code that starts with this line:

    [FONT=&quot] // forward options[/FONT]

    Continue to scroll down in the code until you find the next section, which begins with:
    [FONT=&quot] // table controls[/FONT]

    To perform the first edit – COMMENT OUT EACH LINE between [FONT=&quot]// forward options[/FONT]
    And [FONT=&quot]// table controls[/FONT]. (To comment a line, enter “//” {without the quotes} as the first two characters of each line.) That’s a total of 45 lines commented out.

    Step 2:
    We will comment out the lines that would be used to display the Forward to button, and the drop down selection box.

    Locate again the block of code that begins with [FONT=&quot] // table controls, [/FONT]the next change we make is within that section. Here is the original section:

      [FONT=&quot]// table controls[/FONT]
      [FONT=&quot]    $controls = "[/FONT]
      [FONT=&quot]          <button class='infobar' type='submit' onclick=\"document.voicemail_form.a.value='delete'\">[/FONT]
      [FONT=&quot]          " . _("delete") . "[/FONT]
      [FONT=&quot]          </button>[/FONT]
      [FONT=&quot]          <button class='infobar' type='submit' onclick=\"document.voicemail_form.a.value='move_to'\">[/FONT]
      [FONT=&quot]          " . _("move_to") . "[/FONT]
      [FONT=&quot]          </button>[/FONT]
      [FONT=&quot]          <select name='folder_rx' style='width:124px;'>[/FONT]
      [FONT=&quot]            <option VALUE=''>" . _("Folder") . "[/FONT]
      [FONT=&quot]            " . $move_options . "[/FONT]
      [FONT=&quot]          </select>[/FONT]
      [FONT=&quot]          <button class='infobar' type='submit' onclick=\"document.voicemail_form.a.value='forward_to'\">[/FONT]
      [FONT=&quot]          " . _("forward_to") . "[/FONT]
      [FONT=&quot]          </button>[/FONT]
      [FONT=&quot]          <select name='mailbox_rx'>[/FONT]
      [FONT=&quot]            <option VALUE=''>[/FONT]
      [FONT=&quot]            " . $forward_options . "[/FONT]
      [FONT=&quot]          </select>";[/FONT]
    The changes we need to make are near the bottom of this chunk of code.
    Here is the modified code:

      [FONT=&quot]// table controls[/FONT]
      [FONT=&quot]    $controls = "[/FONT]
      [FONT=&quot]          <button class='infobar' type='submit' onclick=\"document.voicemail_form.a.value='delete'\">[/FONT]
      [FONT=&quot]          " . _("delete") . "[/FONT]
      [FONT=&quot]          </button>[/FONT]
      [FONT=&quot]          <button class='infobar' type='submit' onclick=\"document.voicemail_form.a.value='move_to'\">[/FONT]
      [FONT=&quot]          " . _("move_to") . "[/FONT]
      [FONT=&quot]          </button>[/FONT]
      [FONT=&quot]          <select name='folder_rx' style='width:124px;'>[/FONT]
      [FONT=&quot]           <option VALUE=''>" . _("Folder") . "[/FONT]
      [FONT=&quot]            " . $move_options . "[/FONT]
      [FONT=&quot]          </select>[B]";[/B]
    [B]//[/B]        <button class='infobar' type='submit' onclick=\"document.voicemail_form.a.value='forward_to'\">[/FONT]
      [FONT=&quot][B]//[/B]         " . _("forward_to") . "[/FONT]
      [FONT=&quot][B]//[/B]        </button>[/FONT]
      [FONT=&quot][B]//[/B]        <select name='mailbox_rx'>[/FONT]
      [FONT=&quot][B]//[/B]           <option VALUE=''>[/FONT]
      [FONT=&quot][B]//[/B]            " . $forward_options . "[/FONT]
      [FONT=&quot][B]//[/B]          </select>[/FONT]
    Changes Detailed:
    The last 7 lines are commented out completely. Place “//” as the first two characters of the line to comment them out.

    On the last line that we did NOT comment out, a change has been made.
    Here was the original line:

    [FONT=&quot]</select> [/FONT]

    Here is the changed line. The change is the 2 added characters (“;) immediately after the </select> tag:


    NOTE: depending upon the editor you use, the lines may break differently for you than what is shown here. If that’s the case, just make sure that you add the “; immediately after the </select>, and the // are present to remark out the <button class…> portion of the line.

    Save your changes – that’s all the editing.

    To test your work, log into the Voicemail and Recordings Interface – and there should be no more sign of the Forward to Button or Drop Down Listbox.

    Until Next time -
  9. tshif

    tshif Guru

    The Further Adventures in A2Billing – PBX to PBX Trunks via IAX2 - Part 1

    The Further Adventures in A2Billing – PBX to PBX Trunks via IAX2 - Part 1

    This discussion focuses on the task of creating trunks between two PBXIAF servers. For our purposes, the goal is to join two Family Telephone Systems by IAX2 trunk.

    This trunk will be used to facilitate and allow Families on Both servers to dial by extension anyone on either server for free Video to Video calls.

    Only one of the PBX’s will actually have trunks to the outside world. Both PBX’s will dial out, and receive inbound calls from that PBX. We will therefore only need a single occurrence of A2Billing to handle both PBX’s billing.

    We’ll use an example that has two PBX’s.
    The PBX called MASTER has:
    • A2Billing installed
    • Trunks to Dial out to PSTN.
    • Local extension users
    • and is the destination for some DID’s.
    The PBX called SLAVE1 has:
    • Local extension users
    • No Trunks to PSTN
    • No A2Billing Installed
    • and is the destination for some DID’s.
    Users on Both PBX’s need to make and receive calls from the outside world.

    In this example our goals are:
    • Configure the SLAVE1 PBX to dial all outbound calls through the IAX2 trunk to the MASTER PBX, using its PSTN connections to make calls.
    • Configure the SLAVE1 PBX to be able to dial all users in the MASTER by extension numbers
    • Configure the MASTER PBX to be able to dial all users in the SLAVE1 by extension numbers
    • Allow DID numbers to arrive at MASTER PBX, and be routed to SLAVE1 PBX when the DID user destination is at the SLAVE1 PBX .
    In this example, we will create a route that allows the SLAVE1 PBX to dial out using the trunks of the MASTER PBX. We will also configure it so that extensions of each PBX can direct dial each other – and interact largely as if it were just one big happy PBX instead of two separate ones.

    Step 1: Creating the PBX-PBX Trunk

    The IAX2 trunk we are about to make has to be made on both PBX’s – albeit with slightly different details.

    In this example, we will call the two end points SLAVE1 and MASTER.
    SLAVE1 is the machine without any PTNS trunks of its own. It will dial thorough the MASTER PBX.

    On the SLAVE1, create a IAX2 trunk with t the following characteristics:

    Leave the caller ID blank.

    Trunk Name: SLAVE1-PEER
    Peer Details:
    host=address of remote PBX
    username= PROD-USER

    (Host entry must match the address of the other end of the IAX2 link.)

    Incoming Setting: SLAVE1-USER
    User Details:

    On the MASTER, create a IAX2 trunk with t the following characteristics:

    Trunk Name: MASTER-PEER
    Peer Details:
    host=address of remote PBX
    username= SLAVE1-USER
    (Host entry must match the address of the other end of the IAX2 link.)

    Incoming Setting: MASTER-USER
    User Details:

    The context=from-internal (above) means that calls going through this trunk have access to the entire dialplan on the MASTER PBX.

    Enable both trunks and you should be able to see them as qualified and ready in the control panel, and in the Asterisk report in FreePBX. Make sure the trunks show as registered – not unreachable.

    Step 2: Creating SLAVE1 PSTN Outbound Route and Dial Patterns

    In order for the trunks to be used, you must create outbound routes on the SLAVE1 PBX. Since it is the primary dial out route – it’s the only one to list in Trunk order. In FreePBX, Outbound Routes, Select Add Route.
    The Dial Pattern should be something like this (For USA):
    Route Name: Main Outbound
    Dial Patterns: 1800NXXXXXX

    Save and confirm you changes in FreePBX when you are satisfied with your changes.

    By using these calls rules, we can make sure that, all the typical call formats will make it across the trunk, as well as Toll free and 7 digit local numbers. (Remember, it’s the actual TRUNK definition that assures proper formatting of the outbound number for the TSP/carrier.)

    A2Billing for OutBound Calls from SLAVE1
    When these calls arrive at the MASTER PBX they will exit in the from-internal context. That means they will be subject to the same call handing rules, and will be processed by the outbound routes of the MASTER PBX. Because there is only one outbound route on that MASTER PBX, and that route goes into A2Billing, the calls will be billed IF you remember to put the users A2B account code (or responsible party account code) into the FreePBX extension ACCOUNT CODE field in the SALVE1 PBX.

    Remember: If the FreePBX extension does not have a valid A2Billing account number – outbound PSTN calls will fail.
    Step 3: Adding SLAVE1 Outbound Extension Dial Patterns

    Because we want each PBX’s users to be able to enjoy free extension to extension calling – we need to make some additions to the outbound route we created in step 2. Currently, that route has dialing rules that only pass PSTN style dial patterns through. We need to add patterns that will allow the extension numbers to be matched, and therefore passed to the MASTER PBX.

    If the extensions at each location fall into non-overlapping ranges, our task is a lot easier. Lets say that the MASTER site extension are all in the range 1010-1099, with three family ring groups as 600, 601, and 605. To include these calls in the trunk, add the following to the Main Outbound trunk on the SLAVE1 PBX.
    In FreePBX, Outbound Routes, Edit Trunk, and Select the Main Outbound trunk.

    Dial Patterns: 10ZX

    Explaining 10ZX
    With the extension range 1010-1099, we want to focus on the last to digits to make it easy. So anything that stats with 10 is good to go – so far.
    Next, in order to represent the rang of 1010-1099, the third digit might be any number from 1 to 9. The Z in pattern is evaluated as exactly that - any number from 1 to 9
    Finally, in order to represent the rang of 1010-1099, the fourth digit might be any number from 0 to 9. The X in pattern is evaluated as exactly that - any number from zero to 9

    Explaining 60[015]
    The Rings Groups are not contiguous – and we don’t know for sure what range any new ring groups might be put into, so for now we are just doing the three listed ring groups.
    Since they all start with 60, well just allow those two. Then [015] is interpreted as any of numbers between the [ ] are considered a match. So, we get 600, 601, and 605.
    If we were expecting more ring groups, and new that they would all fall into the range 600-699, we could easily have made this pattern 6XX.
    Outbound routing and billing should now be complete for the SLAVE1 PBX users. Pick up a phone on the SLAVE1 PBX and dial an extension on the MASTER PBX. When it rings, you have done it right. Then, try an outbound call to a PSTN number from the SLAVE1 PBX. Remember, you must have adequate credit in your associated A2B account for the call to succeed.

    See - The Further Adventures in A2Billing – PBX to PBX Trunks via IAX2 - Part 2
  10. tshif

    tshif Guru

    The Further Adventures in A2Billing – PBX to PBX Trunks via IAX2 - Part 2

    The Further Adventures in A2Billing – PBX to PBX Trunks via IAX2 - Part 2

    So far this configuration is one way – the folks at the SLAVE1 PBX by default will now dial out of the MASTER PBX. Calls placed to the extensions and ring groups in the MASTER will also be passed through. But what about the MASTER being able to reach the extensions at the SLAVE1 ? For that, we need to add some stuff to the Dial Patterns of the Trunk on the MASTER PBX.

    Step 4: Adding MASTER Outbound Extension Routes and Dial Patterns

    At the MASTER, we don’t want to route outbound calls through this trunk (they have no local PSTN access on SLAVE1 , right?), but we DO want to be able to reach the extensions on the PBX SLAVE1 . We are in luck; all the extensions at the SLAVE1 PBX are in ranges that do not overlap with the MASTER PBX extensions.
    The extension ranges in use at SLAVE1 are 1000-1009, and 1100-1150.
    They have one call queue at extension 500 and one ring group at extension 622.

    If the ranges overlapped, we could still achieve our goals, but not as elegantly.

    In the MASTER PBX , In FreePBX, Outbound Routes, Add Route. Create the Route with the Following Characteristics:
    Dial Patters: 100X

    Trunk Sequence: Select ONLY the MASTER-PEER. Select this one trunk only.
    When you are satisfied with your configurations, click Submit to save your changes.

    Next, using the Up and Down arrows, position this new route at the top of the route list. Now, any calls being placed on the MASTER PBX will be evaluated first for matching the patterns we entered in the MASTER-PEER route. If the dialed digts match, the route will be selected, and the calls will be sent to the SLAVE1 via the MASTER-PEER trunk.

    If the call doesn’t match, it will fall through to the next route and test for dial pattern matches. In this way the call will find its way to whatever route there is a valid Dial Patterns for.

    Submit, confirm, and complete your changes.
    Step 5: Adding DID’s to FreePBX on MASTER for Users on SLAVE1

    Now, well make it possible for the MASTER PBX to handle inbound DID’s that are destined for the SLAVE1 PBX.

    Remember, we want A2Billing to bill these calls also – and that means that when the DID’s calls arrive, they go immediately into A2Billing.

    After A2B has begun the rating process for the call, it will send the call back out to a specific FreePBX Custom Destination for delivery to the extension on SLAVE1 PBX. We must give A2B some information about these new destinations.

    Creating Custom “Forwarding” Contexts, Custom Destinations, and Misc Applications
    In order to handle the DIDs, for every DID we expect to route to SLAVE1 PBX, we need to have:
    • A custom context that knows how to get the call to the SLAVE1 PBX
    • A FreePBX Custom Destinations that references the custom context – which makes it available to FreePBX.
    • A FreePBX Misc Application that assigns a system dialable feature code to the Custom Destination
    • A FreePBX Inbound Route for each DID on the MASTER and SLAVE1 PBX.
    *Creating Custom ‘Forwarding” Contexts
    After A2B receives the inbound DID call, it sends it back to FreePBX for delivery. The custom “forwarding” contexts forward the call to the SLAVE1 PBX.

    In FreePBX config edit, open extensions_override_freepbx.conf. Create a new context for each DID that you wish to route to the SLAVE1 PBX. Make the context(s) look like this:

    exten => s,1,Dial(iax2/MASTER-peer/xxxyyyzzzz)
    exten => s,n,Hangup()

    Where xxxyyyzzzz = the 10 digit DID you are sending to the SLAVE1 PBX.

    Creating FreePBX Custom Destinations
    Before FreePBX can use the Custom “Forwarding” Contexts we just created, we must make a Custom Destination to reference the Custom “Forwarding” Contexts. This is what makes it possible for FreePBX to be aware of the custom context.

    In FreePBX, Tools, Custom Destinations, Select Add Custom Destination. Create the Custom Destination with the following characteristics for each DID you are routing to the SLAVE1 PBX:

    Custom Destination: did-xxxyyyxxxx,s,1
    Description: Route to xxxyyyzzzz
    And Submit Changes approve and apply.

    The Custom Destination did-xxxyyyxxxx part matches the custom “forwarding” contexts you created earlier.

    Creating FreePBX Misc Applications
    Before A2Billing can use the Custom Destinations we just created, we must make a FreePBX Misc Application to reference the Custom Destinations we made earlier. This is what makes it possible for A2Billing to forward the calls back to FreePBX for routing to the recipient. For each DID, Make a Misc Application similar in characteristics to this:

    Description: Route to xxxyyyzzzz
    Feature Code: the “extension” you want to assign in A2Billing for this destination
    Feature Status: Enabled
    Destination: Custom Destination: Route to xxxyyyzzzz

    Again, xxxyyyzzzz = the 10 digit DID you are sending to the SLAVE1 PBX.

    Note which feature codes you used for each DID – you will need them when we configure A2Billing.

    Creating FreePBX Inbound Route on MASTER PBX
    Like any other DID, the DID’s being received by MASTER PBX for forwarding to SLAVE1 PBX require an inbound route in FreePBX.
    In FreePBX, Select Setup, Inbound Routes, Add Incoming Route, or Select the Inbound DID that you wish to route to the SLAVE1 PBX. Give it the following characteristics:
    DID Number: The DID you are routing to the SLAVE1
    Signal Ringing= ENABLED / Checked
    Set Destination: Custom Destinations: A2B/DID

    Repeat this procedure for every DID you are forwarding to SLAVE1 PBX.

    Submit, confirm, and complete your changes.

    Creating FreePBX Inbound Route on SLAVE1
    Like any other DID, the DID’s being received by SLAVE1 PBX from MASTER PBX require an inbound route in FreePBX.
    For Each DID being received from MASTER PBX, in FreePBX, Select Setup, Inbound Routes, Add Incoming Route. Give it the following characteristics:
    DID Number: The DID you are receiving from MASTER PBX
    Signal Ringing= ENABLED / Checked
    Set Destination: the appropriate extension, ring group, or IVR

    Submit, confirm, and complete your changes.

    Step 5: Adding DID’s, Desinations and Rates to A2Billing

    Adding DID’s to A2Billing
    Before A2Billing can pass calls to destinations on SLAVE1, it needs to know that they exist, and how to bill for calls coming into them.

    Since we have created DID’s in A2B before, Ill just provide the configuration details:

    For every DID that we are newly adding to the system that is not yet listed in A2B, on MASTER PBX, from inside A2Billing Admin webui, under DID, select Add DID.

    DID: The 10 digit DID that we are adding for use at SLAVE1 PBX.
    Billing: Select the Billing Type that is appropriate for this particular DID
    DIDGROUP: Group 1 DIDs
    Country: Where this number is located (United States, Etc.)
    Activated: YES
    Monthly Rate: Your Monthly Sell price for this DID.

    And then Confirm Data.

    Adding / Changing DID Destinations in A2Billing
    Now that A2Billing has been informed that our DIDs exist, we need to tell A2B what to do with and inbound call when it arrives; In other words, we need to give them a destination in A2B.

    If the DID is new to A2B, then we will create a new Destination in A2B. If the DID was already configured in A2B, we will Edit the DID’s destination, and change it to the new one..

    From Inside A2B admin webui, under DID, select Add Destination. For each DID that we are forwarding to SLAVE1 PBX, create or modify the destination with the following characteristics:
    Destination: The feature code you assigned in Creating FreePBX Misc Applications, above.
    ID Card: The A2B account of the person financially responsible for inbound calls to this DID
    Activated: YES
    VoIP_Call: NO

    And Confirm Data to save your changes.

    See The Further Adventures in A2Billing – PBX to PBX Trunks via IAX2 - Part 3
  11. tshif

    tshif Guru

    The Further Adventures in A2Billing – PBX to PBX Trunks via IAX2 - Part 3

    The Further Adventures in A2Billing – PBX to PBX Trunks via IAX2 - Part 3

    Adding Rates to A2Billing

    Before A2B can pass a call, it must be able to locate a valid rate for the number. In the case of Inbound DID billing, the valid number its looking for is the Destination Extension, or The feature code you assigned in Creating FreePBX Misc Applications.

    To add the rate, in A2B admin webui, under RATECARD, select Add Rate.
    For each FreePBX Misc Application we created above, we will now create a Rate to that destination, with the following characteristics:
    RATECARD: Local Destination
    DAILPREFIX: The feature code you assigned in Creating FreePBX Misc Applications.
    DESTNATION: The DID your are configuring the rate for.

    For BUYINGRATE, BUYRATE MIN DURATION, BUYRATE BILLING CLOCK, SEELING RATE, SELL RATE MIN DURATION, AND SELL RATE BILLING BLOCK, use values you have previously determined and used for DIDs of this type from this vendor.

    That sure was a lot of details.
    You have now:
    ·Configured the SLAVE1 site PBX to place all outbound public calls through the SLAVE1-PEER trunk by default, and configured A2Billing to bill these calls.
    ·Enabled both sites to call the other site via extension numbers without requiring a trip through the PSTN. Free Calls always make people happy. ;)
    ·Configured MASTER PBX with special contexts and Destinations to provide A2B with ways to use and forward the DIDs for SLAVE1.
    ·Configured A2Billing to bill for inbound DID’s destined for SLAVE1 PBX.

    This exercise demonstrates how the Family PBX architecture we have kibbled together can scale to multiple PBX,s even while centralizing the Trunks, DIDs, and A2Billing activities on a single server. Hope you found this interesting – and useful to your projects. That’s all folks! Give it a try!

    Until next time -
  12. mspieker

    mspieker New Member

    Fantastic Stuff!!! I was wondering if any headway was made on the follow me front? I plan on using my server a little like googles grand central. But instead of everyone having their own did, I wanted people to call 1 central number, then enter an extension number that would call a ring group. I guess another way to look at it would be if you were a coach of a team, and you set up a single did that teammates could call into, and dial other players by name to ring their house and cell phones, but charge the person recieving the call for them. I thought the follow me might work for this. Anyways I'm rambling, thanks so much for all your efforts, they are greatly appreciated!!
  13. tshif

    tshif Guru

    Mark -
    Its always so nice to get positive feedback. Thanks so much for the kind words. I am delighted that your finding this stuff interesting. ( I use a print out of it at home when someone has insomnia.)

    The thing I like best about FollowMe is that the ARI interface lets the user manage it 24/7. I have been triple buried in projects, and the FollowMe updates Joe and I want to do are being worked on. Its just taking a little longer than we had hoped. It still seems doable, and I will keep this thread up to date on any progress we make. Thanks for asking - cause it has been a while. :crazy:

    I think the rest of your goals are already acheivable with whats already been covered. The ring groups work very well in conjunction with A2Billing as does the IVR. I suppose one way of moving forward right away would be for the participants to provide the pbx admin with any/all phones or extensions they want in the group, and modifications would require the pbx admin to complete.

    I beleive that calls placed to outside numbers as part of a ring group should still be rated by A2Billing, but I havent tested that to make sure. Since we only have one outbound route, which goes through A2B, the calls would get sent to A2B, but....

    For those who may be curious, the problem with FOllowMe and A2B is that calls placed through FollowMe do not assert the FreePBX Account Code when they dail, the way the rest of FreePBX does. Under those circumstances, A2B cant process the call, because it doesnt know who the financial responsibly party is. Our task to make Followme Work with A2B is to correct that issue.

    I think, but don't yet know for sure, that the ring groups DO assert the account code when they dial to outside numbers. If that is the case - then this might work for you untill we figure out FollowMe.

    I also noticed this was your first post to the PBXIAF forum. Welcome! This is a great community, and it always works best when everyone feels comfortable stepping up and getting involved. I'm glad to see your first post here.

    Good luck with your project.

  14. mspieker

    mspieker New Member


    Thanks for the fast reply Tony, I struggled for a while on if I should post or not, I'm afraid to look stupid I guess.
    Anyways thanks for the fast reply, and making a noob feel welcome. I'll give the ring groups a shot, one problem I ran into was in this section for the inbound rates, where it asks for extension number, I'm thinking of doing this on a large scale and there is no way to enter all the extension numbers. I tried putting in 1-99999999999999999999. Well as you probibly know (I didn't) A2Billing didn't like it.
  15. tshif

    tshif Guru

    Mark -
    Interesting that you have found a large scale application for Family Phone System. Thats one thing I really like - seeing what folks do with the stuff we talk about. How many users do you anticipate?

    Regarding inputting mass rates for the inbound billing - you should be able to import mass rates the same way we did for outbound rates. The difference would be that we use the users FreePBX extension number in the prefix fields, and the 10 digit DID in the destination Field.

    You could arrange in a spreadsheet the DID and extension data along with the inbound sell rates for the DIDs, export-dance them into semi colon ( ; ) delimited format. Then, import them using the bulk rate import tool in A2B, into the Local Destinations Rate card.

    Let me know if that didn't make sense -
  16. nsukho

    nsukho New Member


    Is there any way E911 feature can be added in this project?
    Thanks again in advance,
  17. tshif

    tshif Guru

    E911 is normally provided by your TSP, if they offer it. Sometimes special arrangements are needed in the PBX to support it, sometimes not. Can you tell me about which kind of E911 you are working with? Is it the service from voip.ms?
  18. tshif

    tshif Guru

    User: pbxinaflash671 - I received your PM's, but the forum says it cant find your account for me to reply. Please provide me with a valid way to reach you. I think the examples you sent are fascinating and would like to discuss them.

  19. sunish

    sunish New Member

    Really great article,something that was badly needed. I have a small issue, when I try to make a call, I get the IVR to enter pin, in spite of entering the the card no. as account code for the extension from which I try the outbound route configured for a2billing. Once I enter the card number, I'm again prompted to enter the destination number. I'm sure that's not the way its supposed to work. Can you please suggest where I could have gone wrong.
  20. jroper

    jroper Guru


    This should just work, if you've put the card number - no spaces - from a2billing, into the extension acountcode field.

    Watch the asterisk CLI as you are making the call and see what pin is delivered.

    Additionally, check A2Billing.conf to ensure that you have use_dnid=yes


Share This Page