1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. If you had a PIAF Forum account in the vBulletin days, log in with your old credentials. Otherwise, sign up again and we'll get you back in business as soon as we can.
  3. A serious FreePBX vulnerability has been reported. Update your Framework Module immediately. Click here for details.

A2Billing - An Adventure in PBX Billing - Part 1

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

  1. tshif Guru

    Starting to tackle A2Billing – and not for the first time – brought out a few emotions. I mean – I like a good hard technical problem to sink my teeth into. Note that I said hard not impossible. But my first few dips into the cool waters of A2Billing just about froze my nu.., um, nasal cavities. I don’t know why I have found it so hard to get my brain around how A2Billing gets installed, and configured.

    Well this time, I’m motivated. I mean, I actually finally wrote a couple dial plans all by myself, and understood what I was doing – sorta. I must be ready to tackle billing, right?
    Well – I thought it might be helpful to document what works for anyone else with no experience and a definite mental block who might try to do this.

    So – here's the basic plan. The family is spread out, far and wide. Even more so this year. Since I have deployed a few traditional SMB type PBX’s to great effect – it might be a good way for us all to stay in touch. Besides that I found out my uncle’s monthly phone bill was $65.00 / month. Looking at his bill – his calling would result in maybe $8.00, including fees for a DID, in the VoIP world. How many more relatives are in the same boat?

    Nothing says commitment to a project like a $900 expense – so I acquired 4 GrandStream GXV 3000 telephones. Having used them in one other small company deployment, I felt the devil you know is better than the devil you don’t. They should arrive around the 20th.

    I have until Christmas to figure out how to be a phone company for our far flung family.

    So – here were the project goals for TFPS (The Family Phone System)
    1.Hosted Provider / PBXIAF
    To assure performance. No NAT issues, and a fat pipe to the net. (The last thing we need is network contention at the PBX to sink the boat before she sails.) We chose Lylix – for being just excellent providers all around with our other PBX’s.
    2.Video Support (Obviously)
    Otherwise the screens on the phones are expensive places to stick postit notes.
    3.Bells and Whistles – Features and Functions
    The Nerdvittles Add-ons have spoiled me forever – Ill never again be content sitting in front of a telephone that can not read me the weather in Orem, Utah or Walla Walla Washington at the touch of a few buttons. All the creature comforts, like free 411, CID lookup, and proper handling of 911 calls. Allison chirping away for my custom prompts via Cepstral, and the surf-reports all need to be available to the users of TFPS (The Family Phone System.)
    4.Conference Room(s)
    For those long winded family discussions, and special occasions like birthdays, nothing beats an all hand-on-deck conference call. I don’t think Asterisk conference rooms support video yet, but the audio will still be great to have.
    5.Voice Mail
    Obvious, but important. It would be nice if Follow me could work also -
    6.Web Access
    To Voice Mail (ARI), and the Follow Me controls inside, and the ability to change voice mail to email settings.
    7.Extension to extension calls free.
    Each family unit gets a Video Phone, and can call all other family units 24 / 7 without Fees.
    8.Web Based Account Management – Calls to and from the OutSide NOT Free
    They need to be able to log into their A2Billing user interface – and use all the cool tools inside. They need to be able to see their call records, and most importantly to Pay their bills in an automated way. (Have you ever tried to rate calls and make bills by hand? It’s TERRIBLE. ) This becomes more important as they add DID’s to the system, and begin using it as regular telephone as well.
    9.Apportioned Maintenance Fees
    The system should include in its automatic billing a way to charge a percentage (in this case 20%) of the hosting fees (5 families) – so everyone contributes equally to the monthly hosting fees. (At lylix, this will be about $7.00 per family per month)

    I secretly believe they will all begin asking about ways to use the system more, and I don’t want to be involved each time they pay their part of the phone bill. So the plan is to enable PayPal (I know, I know. I’m taking the easy way out here. At least I Hope I am.)

    The Setup
    I have hardware that is known good, and has run PBXIAF very nicely before. I don’t want to introduce any unknowns that I don’t have to. I’m sure there’s gonna be plenty of them to deal with anyways.

    The first steps was be to get a “pristine platform” prepared. So did an absolutely new and standard install of PBXIAF 1.3. Then installed and updated all modules. Lylix is still loading FreePBX 2.4, (everything else is pure PBXIAF 1.3), So I went through the Upgrade to 2.5.x as well. When this is done, all modules are up to date, and update-scripts, update-fixes has been run.

    The next step is to add the g729 codec if you have the license for it.
    I install my Cepstral licenses and voices at the same time. And Swift.
    Now is a good time to make that first full backup. By this time, you will have and hour or so – depending upon how fast your internet and CDROM drives are – into the project.

    The next time I work on this project – I will be installing all the goodies that make life pleasurable – Weather Reports and all. In Fact, every feature that I want TFPS (Remember the acronyms, kids, The Family Phone System) users to have access to should be installed, and tested as working normally before any A2Billing installation steps should be undertaken. (Makes it way easier to trouble shoot things.)
    Then it’s time for Trunks

    Till Next time -
  2. TheShniz Guru


    +1 for freezing my nasal cavities on A2Billing a couple times over the years. Was secretly hoping for Joe to train Ward, and in turn the rest of us in an NV article. You've got my attention :)
  3. tshif Guru

    A2Billing - An Adventure in PBX Billing - Part 2 – Ship Shape and Bristol Fashion

    A2Billing - An Adventure in PBX Billing - Part 2Ship Shape and Bristol Fashion
    (Why do all the cool people in VoIPland live on or party on Boats? Phillippe of FreePBX fame smiles out from his boat-based avatar at the FreePBX site. I hear Tom King Scubas, Joe Roper has a semi aquatic dog living with the family on a boat, Ward has all these cool island locations preloaded in his example for the Nerd Vittle XTide scripts – so you know where there’s an island, there’s Boats, right? I confess – Im a hopeless landlubber . I Need Dramamine when I *watch people* in boats from the shore. I hope that doesn’t effect this project…. J I have all those phones coming.)

    So when last we met, the fresh build of PBXIAF 1.3 had been made on our Hosted provider, Lylix. All modules and FreePBX itself updated to the latest and greatest. We also installed our Ceptral and g729 licenses at the same time.

    If your sensing a pattern, Im glad. The goal is to build this puppy from the ground up, good functional foundations, then the “workings”. In other words, get her ship shape and bristol fashion. Before we get on to the workings, take this time and make yourself a complete Back up of your system. I cant say that enough. In fact – lets take a couple minutes to make a few simple changes and get a lot more out of the FreePBX backup program.

    Backups – Quick – Dirty – and Offsite
    I didn’t know until fairly recently that the backup program we all have immediate access to in FreePBX has some hidden talents. For example, its easily modified to include additional folders in the backups beyond what we get by default. This proves to be important if you expect to get your music on hold files and a few other resources that don’t get picked up by the default backup configuration.

    Another trick that its capable of is sending your backup file to an offsite ftp server when its done. Its sorta weak – if it fails for any reason, it does so silently. But still – Ill take extra precautions for free when I can get them.

    So let’s look at how to make those two things happen when we make backups..

    Make Offsite FTP Backups
    My reference for this part of the project is material on the freepbx forums:

    First let’s Review the /etc/amportal.conf file and you will find a section identical to below:

      [FONT=Arial]#The following are used to optionally have the freepbx backup program optionally[/FONT]
      [FONT=Arial]# send the generated backup to an ftp server[/FONT]
      [FONT=Arial]# FTPBACKUP=YES to enable[/FONT]
      [FONT=Arial]# FTPSUBDIR is an optional subdirectory at the ftp server, it will cause ftp to do a cd[/FONT]
      [FONT=Arial]# There is no error checking so you should check to make sure these are set correctly. The[/FONT]
      [FONT=Arial]# ftp is saved after the backup, so it will not cause the local backup file to be effected[/FONT]
      [FONT=Arial]FTPSUBDIR=[I]mybackupfolder – optional if not root[/I][/FONT]
      [FONT=Arial]FTPSERVER=[I]ipadress only. No funny business with urls[/I][/FONT]
    You will notice we removed the hash marks `#` from the front of the lines to un-remark them, and added the information needed to locate, login to, navigate and drop your backup files there at the end of the regular back up process. I can’t say this loudly enough: there’s no error checking, if it fails, it fails without so much as a whimper. There is no substitute for verification. When your files make it to the FTP server, you have been successful.

    Add Your Special Folders to Backup
    A lot of PBXIAF operators like to run the t*f*t*p server – which they use to provide configuration files to each device as they restart. If you don’t do something like this, you will eventually be stuck having to walk someone through reprogramming their SIP phone when they somehow lose their hardware settings. We are not going to use the tfpt server or store anything it its folders yet for this project, but we might in the future. I’m going to add the folder to backups now so I don’t have to remember to do it later.

    Look for a section that has information in it like this:
      [FONT=Arial]# AMPPROVROOT=/var/ftp /tftpboot[/FONT]
      [FONT=Arial]# One or more directories where there are provisioning files that should be included in the backup. Currently[/FONT]
      [FONT=Arial]# these get backed up only, the FreePBX utility does not automatically restore them.[/FONT]
      [FONT=Arial]AMPPROVROOT=/var/ftp /tftpboot /var/lib/asterisk/bin /var/lib/asterisk/agi-bin /var/lib/asterisk/mohmp3/[/FONT]

    Space deliminated, this is a list of the top folders in each hierarchy that will be added to the backups when run. The FTP folders are for reasons mentioned above, the bin and agi-bin folder frequently get customized, and I *hate* remembering after the fact that I have to re upload all the music on hold files, and custom sound files. Basically, any area you know you have tweaked, and don’t want loose.

    Once that’s been changed, reread configs in config edit, and lets try a backup. Don’t forget to make sure the FTP server is ready for the attempted login. Do an amportal restart just for general health and safety.
    Navigate to the FreePBX backup module, and commence the backup. Don’t be surprised when the size of the backup is larger – especially if you have a lot of music on hold.

    After the backup is finished, the FreePBX module will attempt to ftp your file to the server. Check and see if it was successful. In my testing, it seems to fail for active style FTP transfers, but more testing would be a good thing. Keep at the settings, until you get it – it does work really well.

    Now we’ve got some work done, and even improved our backups a little, and then put them to use. Now we can get on with more details of the infrastructure.

    -- See Part 2A
  4. tshif Guru

    A2Billing - An Adventure in PBX Billing – Ship Shape and Bristol Fashion- Part 2A

    Now we can get on with more details of the infrastructure.

    Kennonsoft Updates
    Oh I like the new menus.! I can’t wait to take them apart and try adding things to them. The documentations exists – so well try it if we ever think of something to add that’s not already there after a pass through Tom’s script garden and Wards “AddOn Shoppe” at Nerd Vittles.

    For now, I want to present different information in the side bar area. We know we can change to url of the rss feed. Since I wont be changing this text very often, I’ve decided to put the rssfeed.xml right on the pbx. The easiest way to do that it turns out is to just a copy and paste away.

    Normally, the rss feed is pointed by default at the http://pbxinaflash.com/rssfeed.xml location.. Get into the Admin Menu and select menu configuration. Where is says RSS URL, put this instead: http://localhost/feed.xml.

    Now we need a copy of the xml file itself.. The easiest way to get that is to open it ina browser and copy the source code into your clipboard. Paste the http://pbxinaflash.com/rssfeed.xml url directly into a browser, and open it. Then right click on the resulting page and click show source. Use the Select All function and copy the entire contents into the paste buffer.

    Next I use winscp and navigate to /var/www/html/and create a new file called feed.xml. Paste the contents of your clipboard buffer (the contents of the XLM code screen) into the new file, and then save it.
    I changed file ownership to asterisk:asterisk, and marked it executable – but it may not be necessary.

    Now, any time you want to change the message on the sidebar text area, simply open that file, and using the xml format and existing data as a guide, modify it to say what you want it to say. When you have saved all your changes, refresh your browser view of the PBXIAF menu, and see the results.

    If your looking to nail it all down “pretty” there’s one more thing you can do easily in the Kennonsoft menu – it’s the PBXIAF version of branding. Back in /var/www/html/, find and make a backup of _branding.htm so if it gets mucked up to badly by an edit, you can recover. Then, open it in the winscp editor.

    This file deals with the message and graphic that appears under the Kennonsoft menus in the user and admin mode. To customize it, create a graphic of the correct size, and upload it to the location specified in the existing script .xml file. Make the necessary edits to the graphic referenced in the _branding.htm file, and you’ll have your own graphic showing “down below”. Spend a little time working with the rest of the edits to get the text, url links, and any popup messages you may want, edited to reflect your verbiage. There's a lot of example material to work with in the existing file. It’s a tiny little area, but a lot can be done with it.

    When your masterpiece is ready, save you changes, and refresh your menu screen – you should see your results right away. If it goes blank instead – hunt down and eliminate any special character in your file. One Illegal anything, and the file won’t display.

    Notice we leave the reference to the style sheet at pbxiaf. This way, your feed will look like its supposed to and match the rest of the menu.

    And while were working on menu things – its probably a good time to start adding things to it. Creature comforts – the underpinnings of functionality that we want to offer the users of TFPS. Time to pull out the Nerd Vilttles add ons!

    In spite of the fact that I just don’t think the phone system needs to be delivering email – the system users have spoken and spoken loudly. They DO think it should do things like that. It seems one man's creature comforts are another man's necessities of life. Alas, I’m addicted to the weather reports by phone – so I don’t have a lot of room to talk .

    Here’s some of add ons we are going to install. Some come from our (small) bag of tricks – others from Nerd Vittles, or heck, anywhere we could find them. From the Nerd Vittle collection, we have selected. weather report by zip code, voice reminders, awstats, and the callerid Superfecta (revisited) and a couple more. We’ll add a few dial plan fragments of our own.

    I’m not going to repeat stuff that’s already in the forums – Ill provide links when I can for you. You should decide now if you haven’t already done so what features you want to offer, and install and configure them during this phase of the project. If you pick other NerdVittle add-ons, now’s the time to do them while we do our selections. Also, gather your own favorites together and perform the installation of any complex dial plan phone apps – ala nerd vittles – during this phase of the project

    Some advice - First – takes a deep breath and don’t rush stuff. Most of the Nerd Vittles, and other specialized stuff needs little configuration things done to it. Pay attention and follow the instructions. So – Less coffee, or more??? Haha.

    Let’s do awstats first. Its fast, and (me) the brain-dead can do it thanks to wards scripts and tutorial on Nerd Vittles. Ill say right now that the icon for this program only shows up on the KenonSoft menu when its in the mood to do so. You can always get there with the long url, but it still weirds me out. I think it disappears when viewed on port 9080 or 443, but is there for port 80 viewers. But then I believe in the Easter bunny too, and could be wrong about both. Heres the link to the nerd vittles tutorial. Follow it exactly, and you will have success. (As I write this, I have a guy looking at his menu on his local network, and he sees the thing – im outside on 443 and 9080 – its just not there for me. Go figure.)

    Superfecta – revisted
    Next, we move on to the Superfecta revisited. Tongue in cheek, I say innocently, Have you noticed, there’s no caller ID with VoIP? If you look through the forums, between Titanous’s dearly departed version, and Wards surviving Superfecta, they have been the most read threads of all. Well – relax, as usual, Ward has made it easy. And, recently a forum user has helped update the script to include new lookup sources – so if you have had this little nugget installed for long, you should consider a redo. Forum user Klingon888 has the magic going with this post from the forums. First, do a normal Superfecta Install, and then update using this script of Kligon888. Pay attention when he talks about configuring the new services.

    Web Based Alternative – If Superfecta just wont Super for you
    If for some reason your setup can’t run the Superfecta, a reasonable alternative might be to look into http://www.voipcnam.com. We use them for one low volume client who is still stuck to Trix. Its super easy to integrate with FreePBX – and if you use FreePBX Phonebook caching, you only get charged for new lookups. (I have nothing to do with these folks, just find their service useful.)

    Weather by Zip and Voice Reminders
    Next weather report by zip code, and voice reminders 4.0.3 get the installation and configuration once-over. . Weather report by zip code is a walk in the park – Wards work again – easy as pie for you and me. Note: When I looked, the instructions on Nerdvilttles were older and contained more manual steps with databases. Make sure you follow the thread in the forum for installation, and use the Nerd Vittles article as a reference for configuration tweaking that is needed.

    It’s the same for voice reminders – although the thread is pretty darn hard to follow. You must install, then upgrade, and patch a dial plan. But its worth it when the system just works like its supposed to. Don’t forget the step about securing the Voice Reminders web page – or you could end up with some really unfortunate results. (This project could really use some script magic to get the installation better contained – but it works if you are careful and find and follow all the steps.)

    Because we want to be able to assess how much usage the KennonSoft Menu and A2Billing web portal get, we added munin, although I’m not sure that its returning any valid readings. maybe due to the way A2Billing interacts with the rest of the system. Time and experience should answer that for us. (Or maybe one of the Trio creators will chime in with some info? Jump in guys. )

    Now we delve into non-vittles projects, and we'll start with Hotel Style Wake Up Calls.

    See A2Billing - An Adventure in PBX Billing - Ship Shape and Bristol Fashion - Part 2B
  5. tshif Guru

    A2Billing - An Adventure in PBX Billing – Ship Shape and Bristol Fashion- Part 2B

    Hotel Style WakeUp Calls
    We all know what that means. Your in an uncomfortable bed, in a strange room, in a distant city, and we depend on the simple wakeup call to get up and moving in the morning. Well – simple “wake up call” type calls have proven to be a very popular point with our home users – and since this is a Family Phone System – were putting it in. That thread contains two styles of wakeup calls – one for internal use only, and a second add on dial plan that can be made to work with virtually any outside number. And this is no simple Simon wake up call – it’s Allison, and shell even let your snooze for 5, 10 or 15 minutes. Ahhhh, snooonze with Allison…..

    Streaming Telephone Music
    Another bizarrely popular ability is for people at their desks to listen to the radio through their really bad speakerphones at a really low bit rate. (I can’t help it, I’m sitting here listening to Christmas music on my crappy speakerphone.) This entry sports menus that you pre make into wav files with either flite or swift, so that your menus are key-stroke interruptible. Right – you get to jump right in and interrupt the menu and get into your favorite channel right away.

    VoiceMail Notification (This script has bugs - Do Not Deploy untill further notice 1/23/09 tshif)
    Under some circumstances, I really want to know when I have received a voicemail – even if its not appropriate for me to take the call live with Follow-Me. Attached to this article is a dial plan that adds a function that calls the number of your choice, and tells you when a voice mail has been received. It allows you the option of connecting to voice mail right then and there, or to leave it for later. There’s even a dial code to turn the function of and on. Ordinarily, I try hard to give credit for dial plans that I pick up along the road, but this one has been through a lot of different hands, and I’m not sure who to thank. I have left all the authors original notes and credits as I found them. My thanks to the smart folks who put this together. (If it’s you, and I just failed to give you proper credit – please send me a message soI can fix that! )

    Get the text file from the attachment, and add the contents of it to your dial plan, anywhere in the from-internal-custom context. The version is set to use the feature code 26. Change it in the first few lines of the dial plan to any unused extension and your good to go.

    This should be added to the FreePBX extension registry – but I haven’t had time to test it that way yet.

    Get your SIP Together
    A final assessment of the things that need to be done in sip_nat.conf, and sip_custom.conf. Remember we said VIDEO phones were being used, we need to add videosupport=yes as well as the codecs that our phones use. The GXVs only speak h263 and h264, and I’ve only been able to make them work with Asterisk using h263. I leave the others in case one day the sky should fall, and they become supported. Remember to remove g729 if you don't have the license.



    Because we are on a public address in a hosted location, the sip_nat entries are simpler than when you are behind a firewall. In sip_nat.conf, we use:

    Make sure it works
    In the next part of this write up, were actually begin working with A2Billing (Oh RIGHT, that’s what this thread is supposed to be about right?) Before we go there, its time to go back, and check our work. Make sure everything you have added to the system is working JUST the way you want it to. Theres no point moving forward – ‘cuase if it doesn’t work now, A2Billing will NOT improve the situation. J

    Next time we meet on this thread, well be adding trunks, and a one or two more important dial plan destinations – and begin the trek into the deep frigid waters of A2Billing. I have my nose plug ready, and with luck Tom can loan me a snorkel. But not to worry – I know when I don’t know enough about something. And that something in this case is A2billing. So – with Christmas rushing forward at tremendous speed – and $900 of Video Phones sitting on the desk next to me looking ominous - I made the tuff call and pried open my wallet a bit – and called in the big guns for advice and help.
    That’s right guys, Joe Roper is gonna sit in on our next installment and make us all geniuses at installing A2Billing. Well, ok, I might never make genius, but I’m sure its going to be a lot of fun and fascinating to finally understand – and accomplish – a working A2Biling platform. I can’t wait!

    So till next time – Happy Holidays

    Attached Files:

  6. jroper Guru


    So I've been co-opted to help out to install A2Billing for Tony. When he said he was going to blog what he was doing, I did not expect it to be so detailed, so I've a hard act to follow.

    The specification for A2Billing was to install it to work nicely with FreePBX, so that all the functionality of FreePBX remains as far as is possible, and calls to the PSTN were billed at the appropriate rate. So in effect, the way that we are going to build A2Billing is to just bill FreePBX extensions.

    So we have got to the point so far that we have installed FreePBX, and all the other bits and pieces, we have set up a trunk, (consider the PBX in a Flash / Fonicatec service) and we've set up some extensions.

    1. We have to run the A2Billing install script,however, because I've been lazy, I've not sent a new one to Tom to install the latest A2Billing, so a bit of hand editing is in order.

    So open /usr/local/sbin/install-a2billing

    and change the following:

    wget http://a2billing.net/downloads/A2Billing_1.3.3.tar.gz
    tar zxfv A2Billing_1.3.3.tar.gz

    wget http://a2billing.net/downloads/A2Billing_1.3.4.tar.gz
    tar zxfv A2Billing_1.3.4.tar.gz

    mysql mya2billing -u a2billinguser -pa2billing < a2billing-mysql-schema-MYSQL.5.X-v1.3.0.sql
    mysql mya2billing -u a2billinguser -pa2billing < UPDATE-a2billing-v1.3.0-to-v1.3.1-mysql.sql
    mysql mya2billing -u a2billinguser -pa2billing < UPDATE-a2billing-v1.3.2-to-v1.3.3-mysql.sql

    mysql mya2billing -u a2billinguser -pa2billing < a2billing-mysql-schema-MYSQL.5.X-v1.3.0.sql
    mysql mya2billing -u a2billinguser -pa2billing < UPDATE-a2billing-v1.3.0-to-v1.3.1-mysql.sql
    mysql mya2billing -u a2billinguser -pa2billing < UPDATE-a2billing-v1.3.2-to-v1.3.3-mysql.sql
    mysql mya2billing -u a2billinguser -pa2billing < UPDATE-a2billing-v1.3.3-to-v1.3.4-mysql.sql
    Save it, and we should be good to go.

    2. type install-a2billing

    You will be prompted for the root password of MySQL, in standard build, the password is passw0rd. if you have changed the MySQL root password you will know, and so you will have to type that in instead.

    Some stuff will happen on the screen.

    Then the script pauses for 10 seconds to read some instructions on the screen.

    This is the installation of cpan for the A2Billing callback Daemon, not really required in this impementation, but we will do it anyway.

    3. When prompted for manual configuration change the default "Yes" to a "no"

    4. When you get a prompt, type install Config::IniFiles it's case sensitive. press enter, and wait a while.

    5. Reload

    6. Quit

    and then A2Billing is installed and ready to go.

    One small cockup in the script as to be fixed, go to /etc/asterisk/iax_custom.conf, and put a carriage return in to move the #include... onto the next line, save and you are done.

    The next area is to start the configuration of A2Billing and freePBX so that it can interact with FreePBX nicely. To do this, we have to add a bit of custom code so that we can create an A2Billing from FreePBX to A2Billing.

    Open extensions_custom.conf and add the following code to the bottom of the file: -

    exten => s,1,GotoIf($["${OUT_${DIAL_TRUNK}:4:4}" = "A2B/"]?custom-freepbx-a2billing,${OUTNUM},1:2)
    exten => s,2,MacroExit
    exten => _X.,1,DeadAGI(a2billing.php|${OUT_${DIAL_TRUNK}:8})
    exten => _X.,n,Hangup()
    Now create a trunk in FreePBX over which we are going to pass billable calls.

    Add custom trunk, and in the dial string at the bottom type:-

    Submit and apply.

    This is the trunk you use to send calls out via A2Billing, just select it in outbound routes, and calls will go out via A2Billing. The /1 refers to which agi-conf is going to be used in /etc/asterisk/a2billing.conf, and Tony will explain what an agi-conf is and how you use it.

    There we have it. A2Billing 1.3.4 is now installed and ready for configuration.

    Tony will go into the configuration, because he will be much better at explaining stuff than me.

    In brief, Tony will explain how:-
    1. To add a trunk to A2Billing that we have previously configured and tested in FreePBX
    2. To add a call plan
    3. To Add a Rate Card
    4. To attach a Rate Card to a Call plan
    5. To Add rates for the destinations.
    6. Create first customer
    7. Add credit to the customer
    8. Show a payment from that customer for the credit you have added.
    9. Explain how to make extension in FreePBX authenticate to A2Billing seamlessly
    10. Edit agi-conf to react in the right way for this configuration.
    Over to Tony


  7. tshif Guru

    A2Billing - An Adventure in PBX Billing - Extra – Integrating the Video Phones

    A2Billing - An Adventure in PBX Billing - ExtraIntegrating the Video Phones
    “Captain, you have a signal on the com unit. “
    “Is it Starfleet Command?”
    “No sir, Its your Mother, and she looks annoyed”
    Ah – Starships. Now that’s MY kinda Boat J

    First Review and Assessment – The Grandstream GXV 3000
    It cant be avoided forever, and the stack of phones isn’t getting any smaller or less ominous. Best I get on with the task of getting them configured.

    I have to say these are just cool looking. We got the black version.
    They can be wall mounted, and have ugly little snap on feet to make them sit more upright on your desk. When wall-mounted, the screen folds back flat so it accommodates wall mounting very well. The buttons are round, to small, and mushy when you press them. Most of the buttons either have no discernible labeling of any kind, or one of the little tiny blob looking symbols that always looks like a little blob of melted ice cream. Ummmm. Ice Cream.... I hope its intuitive to use, or Ill be keeping a magnifying glass nearby to be able to see these things. The handset cord is about 6 inches long – note to self – go to Radio Shack for real curly cords.

    The camera is mounted on the top of the screen, and can tilt, the screen pans and tilts, so overall you get a lot of flexibility in the angle of the screen and camera. It has load of input and output jacks in the back for video and audio. This little puppy can be attached to any TV with RCA video and audio inputs. Same for the video camera. It has 2 USB ports. I wondered why, until I realized you can plug certain USB network devices into this and make it a wireless LAN client. I t does NOT support power over Ethernet. It has pass-through Ethernet ports, so you can chain another device through it. But its only 10/100.

    Ease of Setup? In a word, Yes.
    The unit got its address from the network dhcp server, and booted. In a quick moment I was in the web Configuration interface, and configuring away. I should point out that if we were doing this right, we would be deploying configuration files from a server so that all the configuration options are applied automatically, from a central location, each time the phone boots. Because we are only deploying 5 phones, and time is so short – I have opted to configure them manually.

    Ill cover some of the settings that I have found to be important to working with PBXIAF, but not anything that’s outside that scope. You will want to experiment and discover most of that on your own any way.

    Custom Screen Saver
    First though – were going to take the time to make a screen saver to replace the really ugly one that you get from Grandstream. To do that, your gonna need some digital photos, or other art, that you want to use, an art program capable of saving simple jpeg picture, at a very specific size. The good news is that even lowly MS Paint can do it, although it the most convoluted process you ever saw. If you have Macromedia Fireworks, or almost any other reasonable art type program, you’ll be able to do it.

    The phone requires its picture be provided in a binary (*.bin) file, and they give you the tool to make it with. Go here and download the screensaver generator tool. Open the zip file, and tread the 4 lines of instructions, and follow them. In brief, you need to make your picture fit inside 320 x 240 pixels, period. And they have to be save in simple jpeg. Once you have created as many pictures as you want in the series (the actual limits are noted in the readme file of the creator tool), load of the creator tool, and add them to the list. Click on the GO button, and you end up with a file called image.bin. It HAS to be called that, and only that.

    I made I series of images at various places on the screen to simulate a traditional screen saver, and added them to the list of the creator program in the order I thought I would like to see them displayed.

    I found an old image of a favorite symbol of mine. It’s being used privately in my families’ home.

    [IMG] [IMG] [IMG] [IMG] [IMG]

    When displayed, the images are displayed in this order. (This is the coolest visual I have ever seen. It looks really cool on these phones).

    Since all the phones are displaying the same image.bin file, I’m once again going to rely on the pbxiaf web server to deliver these files to the phones. Each time they boot up, the version will be checked, and if it has changed, the new one will be downloaded.

    Use winscp to copy the image.bin file to /var/www/html/.

    Controlling the Phone Firmware Version
    Point your web browser at the ip address displayed on the telephones screen. The default admin password is admin.

    There is no point in configuring the phone completely until the newest firmware has been uploaded, since some of the configuration option change from version to version. To do that, click on the Basic Information tab and find the firmware revision information. Then go here and see if there’s something newer. If there is Get it.

    Again, we will rely upon the pbx webserver. We are fortunate with Grandstream phones they will provision with http, not just t*f*t*p, so we don’t have to do anything magical and start up t*f*t*p. Instead, we head back to the /var/www/html/. Folder and make a new directory called gxv3000.

    Using winscp, copy the ENTIRE CONTENTS of the firmware zip file you got from Grandstream into /var/www/html/gxv3000.

    Getting our Firmware Update – and Getting our Slide Show on the Road.
    We have several changes to make to the config in these units, but not until they have the newest firmware, so well make just two changes before our first reboot.


    Here, the top area, place the path we made to the firmware files; yourpbxaddress.com/gxv3000

    In the bottom area, place the path we made to the screensaver imiage.bin files; yourpbxaddress.com

    You may choose to put the screensaver file in the same folder at the firmware, and make both paths the same. I don’t, because I don’t want to forget its there and crush it when I put the next firmware revision into that folder in the future.

    Before the next step, I need to say this. Don’t lose power, or find any other creative way of interrupting the next few reboots. The phone can be turned into a very expensive paperweight in one accidental kick of the power plug. I say, plug it all into a good UPS before you go on.

    Ok. Click UPDATE to save your changes, and then click Reboot.

    If all goes well, in bout 2 minutes, and possibly a few reboots, your phone will stop most of its activity, and show you a main screen. If you wait for the default 60 seconds, you’ll get to see the results of your screen saver upgrades. (Ah, Space, the final frontier…..)

    See A2Billing - An Adventure in PBX Billing - Extra – Integrating the Video Phones Part B
  8. tshif Guru

    An Adventure in PBX Billing - Extra – Integrating the Video Phones Part B

    Important Phone Configuration Points
    Time to get busy with the actual phone configurations. Lets start with the Status page. Verify that is says you are running the version of the firmware you think you just installed. If not, try try try again. If all is well, lets get busy.

    The Basic Setting Tab
    The Basic settings tab deals with the local network connection – which I will leave totally to you – and some other setting we want to talk about.
    Select the correct time zone for your location, and the type of calendar and clock options you prefer. I always get a 12 hour clock also. Don’t forget to enable daylight savings if you celebrate that where you live. J Click update and change to the Advanced Settings Tab

    The Advanced Settings Tab
    Silence suppression is a weird concept to me. Its already silent, what’s to suppress? Well it turns out the human ear is accustomed to a certain amount of background noise. When things get to quiet – well they think the call has been cut off. It makes them feel like nobody is listening to them – when your there all along. So, by adding back comfort noise, or suppressing silence, we make the calling experience better. Sounds more like an analog line to me, but it is strangely comforting. Bottom line, turn it on.

    In order to come anywhere near close to simulating full motion, don’t set your video frame rate for less than 15 frame/second. I like to give it a lot of bandwidth if its there, and specify 192kbps. I find it makes the video much sharper. If your users don’t have the bandwidth, and the calling experience is choppy, back this down a bit. The image gets more granular, but the overall experience may be viewed as smoother.

    Video frame skipping allows the video to skip a few frames if it gets behind the audio – so that image and video can stay more closely synchronized. I usually turn this on.

    Down near the bottom, there are two controls that deal with browser settings Start Browser on boot, and enable browser toolbar. Turn them both off. They act oddly, and invite questions I don’t want to answer from users.

    Click Update and go to the Account 1 tab
    Here’s where most of the issues usually crop up. Mark the account active. Add a friendly account name. For this Phone, it’s called Smith Household. For SIP Server, and Outbound Proxy, place your pbx address. For SIP User, and Authenticate ID, place the exact extension number you will be assigning to this phone. For Name, place an individuals Friend name (I.E; John Smith).

    If you tell the phone to use DNS server, it might not work even to call other local extension if you loose your DNS server. On the other hand, if you don’t, sometimes the phone may have trouble registering with the PBX. Your mileage mar vary. ID is phone number NO, SIP registration YES, Unregistration YES.

    The Nat traversal STUN settings should be set based on your own experience. Check out the thread in the forums about STUN servers for the latest group hug on the topic of their use.

    Voice Mail User id should be set to 97, not *97. Due to a quirk in the GXV 3000, it can not send a leading asterisk as a dial string character. Because of this, we will be changing all the *codes to non * codes in FreePBX later.
    For DTMF, I strongly suggest trying ONLY DTMF. It really generally works the best.
    You MUST turn OFF early dial, and you MUST select NO for Enable Call Features.

    I’ve decided to leave the paging function active in the PBX with auto answer. I’m thinking it could lead to some interesting surprise video exchanges. Shhhh! Don’t tell the family yet. Hahahahha. For the AutoAnswer selection, Enable Paging/ intercom. ;)

    One last setting to make sure the end users don’t struggle to get the video to work. Find the setting near the bottom for ENABLE Video, and set it for YES. Now, the phones default condition will be to place and receive calls with the video active (when present at both ends).

    During the configuration process you'll have a chance to set the video codes. It important the h233 is available as one of the three choices you get to specific. If its not, the current version of PBXIAF will not see or process Video - since it only recognizes h233. I suggest an ordering of .h233, .h233+, and .h234.

    Enable the use of RFC5168 support for upwards compatibility.

    Select Update. Then reboot. That’s it kids! Its ready to go, with full video support – even in voice mails! )If you didn’t put videosupport=yes into your sip config files when we said to earlier, NOW would be a good time, or NO video for you.

    Make your extension in FreePBX
    Even though we are jumping ahead a bit, its wont hurt anything with our A2Billing Adventure for us to get into FreePBX and create the extension for the phone we just configured as we normally would.

    Once that’s done, you can call yourself, and leave a Video Voicemail as a test.

    The next time we meet, well be right back into the Adventure in A2Billing Tthe Maestro himself, Joe Roper.has already posted the entire installation process to this thread. Awesome!

    See ya there
  9. tshif Guru

    A2Billing - An Adventure in PBX Billing - Part 3 – Batten Down the Hatches - Part A

    (More Boat talk. Can I get a glass Of Water please? I Am very fond of lobster…)

    Welcome back – to our discussion and deployment of our multiple Family Video Telephone System. That’s whole multi family thing is pretty important – because this entire topic really is about A2Billing. The only way this could work is with every household contributing their fair share and usage to the project each month – with bare-minimal human intervention. A2Billing is perfect for that role – and the only way we could proceed.

    Setup your phones
    So – on with the project. First, if you haven’t yet configured your telephones to work with the pbx, do it now, Using whatever means and methods you normally use.

    Anyone who is following along and using the GXP video phones (in the last post to this thread in the GPX3000 review), can and should now get any/all of your phones configured and ready for use.

    I found I had missed one important configuration item in the thread about the GXP 3000 – concerning the need to specify a Video Codec. Yikes, that’s not so minor. If you were follow along that thread, go find the new video codec setting and be sure to add that to your list of things to configure on the phone.

    While you are configuring your telephones, go ahead and create the extension in FreePBX for each of them as well. It doesn’t really matter when we create them – as long as they are in place before we try to use them with A2billing later.

    When creating extensions in FreePBX, remember, (1) Don’t enable or use FollowMe for any of the extension you create. FollowMe is not fully compatible with A2Billing at this time. (2) Don’t use VMX Locator for the same reasons. Ok, that being said, work-a rounds for the FollowMe situation ARE possible and we may look at adding some of them later. But for now we will stick with an unmodified FreePBX installation. Use Voice Mail the same as always.

    A few loose edges
    The last thing well do is put into place a few utility dial plans that we will make available to our users, and the system itself. Some are in the category of creature comfort, others in the category of common sense and CYA.

    You can cut and paste these all together, into the same place: extensions_override_freepbx.conf.
    I consider these “quick and dirty” in that they can be used even when not registered with the FreePBX extension registry, and therefore could create conflicts if you inadvertently reuse any of these extensions elsewhere in FreePBX.

    You should register each of them in Custom Extensions. In the custom Extension Box, enter the extension number you have assigned in the dial plan. The description is for your own benefit – use it as you see fit.

    In some of these, you will see technology/trunkname. One we have trunks installed on the PBX, all the technology/trunkname entries will be replaced with entries that reflect the technology, and the trunk name, that you want them to use to dial out on. (Such as “SIP/trunk123”)

      [FONT=Arial];This routes 411 calls to Google free 411 services. If we decide to use the pbx 411 function, well assign it a different number later. This is a  Standard phone call to an 800 number – it would be cool to find a way for it to exit the system ENUM, since most VoIP providers charge for 800 calls.[/FONT]
      [FONT=Arial]exten => 411,1,Answer[/FONT]
      [FONT=Arial]exten => 411,n,Playback(pls-wait-connect-call&digits/2&directory-assistance)[/FONT]
      [FONT=Arial]exten => 411,n,Wait(1)[/FONT]
      [FONT=Arial]exten => 411,n,Dial([I]technology/trunkname[/I]/18004664411,,r)[/FONT]
      [FONT=Arial]exten => 411,n,Hangup()[/FONT]
      [FONT=Arial]; The routes a VoIP call to the TellMe menu service.  More entertaining that informative, it’s an example of voice menus gone to extreme, to little important effect.  But, its something users like to play with.  Note, the service is off line much of the time. The 180 is the amount of time to let the call ring and the m means play the “default” music on hold Chanel instead of ringing.[/FONT]
      [FONT=Arial]exten => 436,1,Dial(SIP/radio@didx.net,180,m)[/FONT]
      [FONT=Arial]exten => 436,t,Hangup[/FONT]
      [FONT=Arial]; Dials via standard800 number an ad based free 411 service.  When I tested this it wasn’t working, but it may just be offline temporarily. Maybe for good – if you have any alternatives – let me know.[/FONT]
      [FONT=Arial]exten => 511,1,Answer[/FONT]
      [FONT=Arial]exten => 511,n,Wait(1)[/FONT]
      [FONT=Arial]exten => 511,n,Playback(wait-moment)[/FONT]
      [FONT=Arial]exten => 511,n,Swift("1 800 Free 4 1 1 services")[/FONT]
      [FONT=Arial]exten => 511,n,Wait(1)[/FONT]
      [FONT=Arial]exten => 511,n,Dial([I]technology/trunkname[/I]/18003733411)[/FONT]
      [FONT=Arial]exten => 511,n,Hangup()[/FONT]
      [FONT=Arial]exten => 511,t,Congestion()[/FONT]
      [FONT=Arial]; Connects to free service Traffic Information. Our Users go nuts for this one.  Note, if you don’t send valid Caller ID, this system wont let you in.[/FONT]
      [FONT=Arial]exten => 872,1,Answer[/FONT]
      [FONT=Arial]exten => 872,n,Wait(1)[/FONT]
      [FONT=Arial]exten => 872,n,Playback(pls-wait-connect-call&digits/2&traffic&information)[/FONT]
      [FONT=Arial]exten => 872,n,Playback(pbx-transfer)[/FONT]
      [FONT=Arial]exten => 872,n,Dial([I]technology/trunkname[/I]/18666987232)[/FONT]
      [FONT=Arial]exten => 872,n,Hangup()[/FONT]
      [FONT=Arial]exten => 872,t,Congestion()[/FONT]
      [FONT=Arial]; This is wht I call the NO 911 Response. It states in clear terms that NO 911 Service is available on this line, and can relate the address for the caller in case they need to call emergency services but don’t know the address.  Those lines should be commented out for multi location deployments.[/FONT]
      [FONT=Arial]exten => 911,1,Answer[/FONT]
      [FONT=Arial]exten => 911,n,Wait(1)[/FONT]
      [FONT=Arial]exten => 911,n,Zapateller()[/FONT]
      [FONT=Arial]exten => 911,n,Wait(1)[/FONT]
      [FONT=Arial]exten => 911,n,Playback(no-911-1)[/FONT]
      [FONT=Arial]exten => 911,n,Wait(1)[/FONT]
      [FONT=Arial]; This line should be commented out for multi location deployments.[/FONT]
      [FONT=Arial]exten => 911,n,Swift("The address at this location is - twenty to fifty-one Main Street   Hoffenburg california -- 92555")[/FONT]
      [FONT=Arial]exten => 911,n,Wait(2)[/FONT]
      [FONT=Arial]exten => 911,n,Zapateller()[/FONT]
      [FONT=Arial]exten => 911,n,Wait(1)[/FONT]
      [FONT=Arial]exten => 911,n,Playback(no-911-2)[/FONT]
      [FONT=Arial]exten => 911,n,Wait(1)[/FONT]
      [FONT=Arial]; This line should be commented out for multi location deployments.[/FONT]
      [FONT=Arial]exten => 911,n,Swift("The address at this location is - twenty   to fifty-one Main Street   Hoffenburg california -- 92555")[/FONT]
      [FONT=Arial]exten => 911,n,Wait(1)[/FONT]
      [FONT=Arial]exten => 911,n,Zapateller()[/FONT]
      [FONT=Arial]exten => 911,n,Congestion()[/FONT]
      [FONT=Arial]exten => 911,t,Hangup()[/FONT]
      [FONT=Arial]; extension designed to be used as a custom trunk to trap and prevent international calls technically, this isn’t used by A2Billing – it has other ways of doing the same thing, but I add it hear because is usable in many other deployments.[/FONT]
      [FONT=Arial]exten => 912,1,Answer[/FONT]
      [FONT=Arial]exten => 912,n,Wait(1)[/FONT]
      [FONT=Arial]exten => 912,n,Zapateller()[/FONT]
      [FONT=Arial]exten => 912,n,Playback(im-sorry)[/FONT]
      [FONT=Arial]exten => 912,n,Playback(international-call&has-been&disabled)[/FONT]
      [FONT=Arial]exten => 912,n,Wait(.5)[/FONT]
      [FONT=Arial];exten => 912,n,Playback(no-911-1)[/FONT]
      [FONT=Arial]exten => 912,n,Wait(0.5)[/FONT]
      [FONT=Arial]xten => 912,t,Hangup()[/FONT]

    Trunks – Dialing for (Less) Dollars

    Although this is being “sold” to the family as a Video Intercom system, we all now its much more than that. My uncle has already said he wants to use it for him home phone service, se we need an outbound trunk provider for sure.

    I have intended to try out Fonicatec – and this seems like as good a time as any. I know I don’t want service interruptions and poor line quality to end this excitement that seems to be building up in the family.

    One you create your account with Fonicatec at http://usasignup.pbxinaflash.net/A2Billing_UI/signup/ , its time to login and add some $ to your account so outbound calls can be made. The cool part is, the Fonicatec interface is the A2Billing customer interface. You'll get to see a little bit of how your user's web experience will be.

    Paypal is accepted – and the payment experience is really very nice. If you have ever paid with Paypay before, you will recognize this experience.

    Side Note
    In order for this to work for your PBX, you are login to need a PayPal business account. I have been told that only the business accounts can receive online payments in this fashion – although since we already had one – I didn’t test out if it is actually truly required. Creating one is Free – and once you have it, you’re ready to begin receiving payments from your users. I just copied this link from our website – it makes it easy for you to get started.

    See A2Billing - An Adventure in PBX Billing - Part 3B
  10. tshif Guru

    A2Billing - An Adventure in PBX Billing - Part 3B

    Continued -

    Finish the Payment at Fonicatec
    Continue to click through the paypal screens and when you are done – you will be returned to the Account info screen at Fonicatec. Fonicatec is now ready to allow us to dial out. But first, we must make the trunk in FreePBX. There is a link to the Trunk configuration settings in your welcome email which arrives right after you sign up with sign up Fonicatec . The trunk info is clear and concise; You wont have to hunt far and wide to figure out how to make this service work.

    Install Fonicatec Trunk
    Make sure the only acceptable dialing patterns is: 1+NXXNXXXXXX
    This assures that we only deliver properly formatted calls (with the leading 1, so your users don’t have to dial it)

    Create Outbound Route to Fonicatec trunk
    Now that we have our trunks installed, we should test the outbound call ability so that we know the trunk is working before moving to use it under A2Billing.

    Get into FreePBX, OutBound routes, and create one for the Fonicatec trunk. Remember, Fonicatec is IAX2 ONLY. (IN the USA, the pronunciation seems to be EEKS where as in the UK, it is more reasonably pronounced as EYE-AXE.) Believe me, you're better off. IAX2 simply has no NAT problems to worry about – so the connection between your PBX and your outbound trunk provider will always be able to find each other. Unfortunately, the examples are not cut-and-past able, so be careful when entering them. All though the screen say that your username is your account name, which it really seems to mean is termed as your "Card Number" inside the Fonicatec A2Billing user interface, with secret is your PW or PIN.

    We must send all calls out including the area code. Because the family is geographically spread out, we can’t readily code the system to know each callers home area code; They will have to include it when they dial. The following dial patterns should work for these requirements for any call to USA, Mexico, or Canada..
      [FONT=Arial]If you plan on supporting international dialing, add this also:[/FONT]
    In the trunk sequence select only the Fonicatec trunk. Many of us might want to include an ENUM trunk as the first option, but adding that here would create a situation where a Call might come into the PBX (once DID’s are assigned), and get forwarded to an OUTSIDE number by ENUM – and A2Billing would not have a record of the call being made.

    I’ll say that a little differently – A2Billing will only have records of calls placed through the A2B/x trunk(s) , of which ENUM is not one. If not having a record of a call that was placed, but was free doesn’t upset your apple cart – then go ahead and add ENUM – but Id wait until the system works before complicating it in this way.

    Another thing to note is that A2Billing rates (or Bills) inbound calls and outbound calls in separate procedures. Well talk more about that later on.

    It doesn’t matter at this moment if you have installed A2Billing as per Joes earlier post or not. Remember, we are just about to test to make sure that a call can be placed to outside the system from a regular normal FreePBX perspective.

    Save your changes to active the outbound Route and Fonicatec trunk.

    Be sure and follow the instructions when you sign up with Fonicatec to validate your account with them. This validation will remove the one-call-at-a-time restriction from your account, and allow you to deliver caller ID’s to the destinations. Without this, only one family member gets to make a call, from any location in the system, at a time.

    I don’t know about you, but I have dealt with too many VOip providers who don’t seem to have a clue in the world how to configure Asterisk or FreePBX for their services. It is a genuine pleasure to run into a provider like Fonicatec who’s setup instructions actually work right the first time, without any VooDoo dances required.

    Fixing the Dial Plans
    In the section above called a few loose edges, we installed some dial plans that included the temporary text "technology/trunkname". Now that we have an outbound trunk, we need to edit those occurrences to reflect the real information from our Fonicatec trunk. For Technology, use IAX2, for trunkname, use the Trunk name you used when you created the trunk. Once you save those changes, and reread configs, those special dial plans should work.

    Do Test My Friend!
    Now, pick up a phone registered on this pbx, and try an outbound call. Make sure to dial in the format NXXXNXXXXXX. You should be able to dial out just as you normally would through your pbx at this phase. If you can’t – Fix this first. A2Billing will be using this trunk for outbound calling – if it doesn’t work, A2Billing cant work. You can also use the special extentions to test. Try dialing 872, or 411. Both of these also use an outbound trunk.

    Notice that your caller ID will be wrong until you validate your account with Fonicatec, and begin sending your own proper caller ID.

    If there’s anything not working so far – go back and fix it. We are going to want to know that the foundation pbx works as we begin configuring A2Billing – as the very next thing we do.

    Until next time -
  11. tshif Guru

    An Adventure in PBX Billing - Part 4A – Damn the Torpedoes, Full Steam Ahead

    A2Billing - An Adventure in PBX Billing - Part 4A – Damn the Torpedoes, Full Steam Ahead
    We all know everything up to this point has been under the heading of “get the foundation ready”. Since we’ve done everything but the kitchen sink – it must be time to Get our waders on and take to the cool waters in the stream of A2Billing.

    A2Billing - Concepts
    A2Billing is a complete billing solution for many applications, and is very well suited for a purpose such as this project. It has an Admin and User portal – and will let your users manage their own accounts, and pay online with paypal (and via other means if you desire it), and get records of their calls.

    A2Billing also does a good job of preventing your prepaid phone plans from becoming post-paid collection problems. (Ever tried getting money from relatives after the fact?? Hahaha) Each time a call is made, A2Billing assesses the number being dialed, and the account balance for the calling party – and tells asterisk to limit the calls duration to only what the account balance will pay for.

    Its also inherently very good at taking its own special “calling card”s and behaving like those more expensive dial-around services. If configured with an outside DID – you may dial into it, use your Account code as a PIN, and dial outbound calls using your PBX. Sort of like DISA, with billing. Pretty cool, isn’t it?

    If you haven’t yet followed Joes excellent and concise tutorial earlier in this thread, do it now.

    In order for A2Billing to get into the act, it must be installed, and configured to work the way you expect it to. There is one major area of configuration required in the etc/asterisk/A2Billing.conf file, editable from within the FreePBX config editor. Well dive right in to it now.

    Inside the A2billing.conf file, you’ll see several sections. I strongly suggest, as does the The Maestro himself Joe Roper, that you pint out and read the a2billing conf file. It will answer a lot of questions for you – that you didn’t even know you were going to ask. It’s also plain to me that the very same read through will pose as many new questions that you will want answered. I suggest you post those questions here. I sure will be.

    Its easy to mess a2billing up by over-stimulating it here with too many changes. If we don’t talk about it during this project – you probably shouldn’t change it from the defaults – certainly without making copies of working originals. Many of the defaults of the A2Billing install are perfectly adequate for this project – and you need not make some of these adjustments to be successful with A2Billing. Any that are mandatory should be fairly obvious by the nature of the comments embedded in the conf file.

    For our Family use, we have chosen to configure some of the options in the ways described below. If its not mentioned, we didn’t change it. Enable or disabling access to various screens in the end user WEBUI is up to personal taste, and common sense about what is appropriate for this project and your specific deployment

    Global Section
    len_aliasnumber controls the length of the alias’s created for the customers use when their ids are created in A2Billing. Since we don’t expect millions of users, we could change this to a smaller number to avoid user complaints about typing this in.

    base_currency, for us, we enter USD for US dollars.

    Admin_email should be used for whoever is ultimately managing this installation. If your reading this and following along for the project – that’s probably your email address. K

    Webcustomerui Section
    If you want the general public to be able to reach your signup pages,
    Signup_page_url = http://yourserveraddress /A2Billing_UI/signup/index.php

    For the application of the Family Telephone Server – I do not recommend that you leave it open to the General Public. Instead, secure the sign up page using the same methods we do for the rest of PBXIAF – via password credentials managed in /etc/pbx/httpdconf/pbx.conf. This way, when a new Family member wants to get involved and get service, we can send them an email with the login screen id/password, and they create their own accounts on the system.

    We still have to validate them and activate them in A2B – but this step gets them used to working within the web interface – where they will have to pay their bills each month.

    Securing the Sign Up Screen
    If you don’t secure it right away, – leave the value for ‘Signup_page_url = ‘ completely blank. The link to the sign up screen disappears off the webui login screen. Note that if you know the url, you can STILL Get to it by typing the entire path, unless you secure it.
    Using your favorite editor and open /etc/pbx/httpdconf/pbx.conf. Paste the following to the bottom of the file:

      [FONT=&quot]#Password protect /var/www/html/a2billing_UI/signup[/FONT]
      [FONT=&quot]<Directory /var/www/html/A2Billing_UI/signup>[/FONT]
      [FONT=&quot]AuthType Basic[/FONT]
      [FONT=&quot]AuthName "Restricted Area"[/FONT]
      [FONT=&quot]AuthUserFile /usr/local/apache/passwd/wwwpasswd[/FONT]
      [FONT=&quot]Require user wwwadmin maint meetme[/FONT]

    Then do a service httpd restart.

    This protects the A2B signup screen with the password that would have been used for MeetMe (as well as making the wwwadmin and maint id/password combos valid for the A2B signup screen). Since we aren’t going to use MeetMe – we’ll just use the meetme credentials for access to the A2B signup screen.

    The side effect of this is that running passwd-meetme will actually change the password used by the A2B signup screen.

    To keep the end user webui clean of clutter, if you only plan to enable a single pay method, I.E.;, Paypal, set this value to no
    paymentmethod = no

    We do want them to be able to change their personal information details, and we definitely want them to be able to pay their bills online, so set both of these to yes.

    ;Enable or disable the page which allow customer to modify its personal information
    personalinfo = yes

    ; Enable display of the payment interface - yes or no
    customerinfo = yes

    ; Enable display of the sip/iax info - yes or no
    sipiaxinfo = no
    In a more traditional configuration of A2B, these settings determine certain parts of the information that is given to the end user if they navigate to the SIP/IAX info screens in the A2Biulling user webui.
    This information would be used by an end user who will be configuring their own equipment.

    For the way we have integrated A2B for the Family Phone System, the end users are not connecting their equipment to A2B as such, they are connecting their equipment to FreePBX. So displaying this, especially since it wont display usable info, would be confusing for the users.

    ; Enable the voucher screen - yes or no
    voucher = yes
    We set this to yes. Vouchers are like gift cards or prepaid calling cards. By enabling them, well be able to give free calling time on the system to users just by emailing them a voucher id. They just go to the user interface, and enter the voucher.

    Vouchers may make NO sense in your Family Phone System deployment, but quirky as it may seem – I plan on using these to provide a small number of free minutes to each family so they can experience outside telephone calls through the system. I think it will help encouraging more use of the system. Plus, there’s going to be a generation going to college soon in one family – and I think at least one will take a family VOip phone with them. I could provide these free minutes in other more direct ways – but again – this will encourage them to become familiar and comfortable with the web interface.

    Show rate card and simulator settings determine how much info the users can get for themselves about what the system usage rates are. Again – in some Family systems, this might not be important, or even prove confusing to your users. In our family, there will be a benefit to being able to display the cost of using the system in a favorable light compared to their existing phone arrangements. That being the case, we turn both of these on.

    Caller_id should be left set to NO for this project – as FreePBX is still in the mix, it will handle the Caller ID assignments as it always does. If we dotn set this to NO, the users will be presented with confusiong information, that doesnt work anyway (in this configuration). Therefor, this is considered an important if not mandatory setting.

    Error_email should be set to the pbx responsible party.

    See A2Billing - An Adventure in PBX Billing - Part 4B – Damn the Torpedoes, Full Steam Ahead
  12. tshif Guru

    Adventures in PBX Billing - Part 4B - Damn the torpedoes full steam ahead!

    Adventures in PBX Billing - Part 4B - Damn the torpedoes full steam ahead! (continued)
    (This continues the initial configuration of a2billing.conf)

    Epayment_method Section

    If you want the users to be able to pay online, you must enable this. (enable = yes).

    ; eg, http://localhost - should not be empty for productive servers
    http_server = "http://your FQDN "

    ; eg, https://localhost - Enter here your Secure Server Address, should not be empty for productive servers.
    https_server = “https://your FQDN

    If you have an SSL certificate installed (we don’t), this entry should be set to you FQDN, formatted like this: “https://fqdn” including the quote marks.
    If you don’t have SSL, make this entry the same as used in the first entry, above.

    ; Enter your server Domain Name or IP Address, eg,
    http_cookie_domain = domain123.us - (Your domain name) or
    http_cookie_domain = (Your IP goes here)

    ; Enter your Secure server Domain Name or IP Address, eg,
    https_cookie_domain = domain123.us - (Your domain name) or
    https_cookie_domain = (Your IP goes here)

    DO NOT ALTER the remaining paths in the Epayment method section.

    Make changes in these two entries that are appropriate for your pbx address. These setting are required.

    http_domain= your FQDN

    dir_ws_http:"/var/www/html/A2BCustomer_UI/" ;(including quotes)

    currency_code = USD ; for US based installs. You can leave it blank

    This next one change determines what organization name will appear inside the Paypal Interface as the Payee.

    ;paypal store name to show in the paypal site when customer will go to pay
    store_name = Family Telephone Services

    DO NOT CHANGE the transaction key.

    Signup Section
    This entire section need only be dealt with if you have enabled the user sign up screen. We did, so we will be covering it in more detail later in this project. You have probably already noticed that the information being requested roughly corresponds with the same information you are asked to provide when you create a New A2Billing user in the Admin interface.

    Agi-conf1 Section
    I call this the “Call Flow Personality Module” of A2Billing. This area controls the behavior of A2Billing while the call is in progress,

    For this project, we are going to put in a default set of values that are suitable for our application. Other applications such as Call through services will require another agi-conf configuration. In fact,
    one of the coolest parts of this section of A2Billing, is that we may easily create multiple agi-confx sections, each one with its own values. This allows you to provide different call flow experiences, as may be needed. Well explore that flexibility in a future write-up – maybe by adding a DISA like function.

    ; play the goodbye message when the user has finished.
    say_goodbye = NO
    Determines if A2Billing says goodbye when a call placed through the system has completed. The goodbye plays only to calling party, not the called party.

    A2Billing voice language selections.
    play_menulanguage = NO
    force_language =

    Its important to leave force_language to blank. The force language option can only safely be used when the FreePBX multi language extensions are properly deployed.

    ; Introduction prompt : to specify an additional prompt to play at the beginning of the application
    intro_prompt =
    If you wanted a recording saying something like “Welcome to the Family Phone System” Or “Opening Sub Space Communications Chanel”, you could create those recording as custom system recording, and then call them into use here. While this is probably not helpful in 99%of the home PBX’s – I expect to be doing a little `family marketing`, including using this capability Leave it blank until you have uploaded the audio file that it will refer to.

    ; this is the minimum duration in seconds of a call in order to be billed
    ; any call with a length less than min_duration_2bill will have a 0 cost
    ; useful not to charge callers for system errors when a call was answered but it actually didn't connect

    min_duration_2bill =

    This setting is usually only required to compensate for providers who have problems with false answers, or when using a GSM gateway. Under these rare circumstances, this setting is used to compensate for false billings caused by these false answers. In these cases, the typical value set would be 20 seconds.

    ; if YES it will use the DNID and try to dial out, without asking for the phone number to call
    ; value : YES, NO
    use_dnid = YES
    This NO by default – but make sure it is YES. This is a required change. If this was set to no, A2Billing would prompt you for the number to call right after you got done dialing it already.

    ; number of times the user can dial different number
    number_try = 1
    This is set to 3 by default and needs to be set to 1. This is important.

    The remaining settings should be set according to their descriptions, and how you want the call flow to proceed. You can change these often and easily to see the results you get.

    ; Play the balance to the user after the authentication (values : yes - no)
    say_balance_after_auth = NO

    ; Play the balance to the user after the call (values : yes - no)
    say_balance_after_call = YES

    I think its convenient in a prepay environment to be kept abreast of your account credit status, but we like it after the call is finished.

    ; Play the initial cost of the route (values : yes - no)
    say_rateinitial = no
    Just another way to remind your users they are SAVING MONEY with this service. AT&T wouldn’t quote their rate to you – but J.P. Morgan once said when asked how much his yacht was worth, “If you have to ask, you can’t afford one.” You decide -

    ; Play the amount of time that the user can call (values : yes - no)
    say_timetocall = yes
    This is a real time calculation, based on the cost of route to be used for the number being called, and the balance of the users prepay account. If the time is very short, the user might decide to go off and recharge their account amount before completing the call. Some people think its to much info to insert in every call. You decide.

    ; Send a reminder email to the user when they are under min_credit_2call
    send_reminder = NO
    If you want to send an email when the users account falls below the threshold you established to make calls, set this to YES. This could be a real convenience – or a real pain in the rear – it all depends on your users and what they think of as convenient.

    Now that we have a moment – lets make another backup of the system, just in case. It would be a shame to loose all our work, wouldn’t it?

    Whew! That’s a lot to get done in one sitting, but now the Install of A2Billing can actually be considered complete. Our very next tasks is to continue preparing A2Billing by adding call plans, rate cards, rates, and finally, even users.

    Until next time –
  13. blakekrone Guru

    Wow - great job so far! I'm awaiting your a2billing configuration. I've done the same thing with some of my family by sending them the GXV-3000 seen as we are expecting our first child and the grandparents are in other states.

    One quick note, feature codes *xx will work by using this dialplan string on the GXV-3000:
    [*]x+ | x+}
  14. tshif Guru

    blakekrone -

    Thanks for the kind words! And thanks for providing the dial plan for including * codes. I looked all over for that info and couldn't find it in any Grandstream docs.

  15. tshif Guru

    A2Billing - An Adventure in PBX Billing - Part 5A – Yo Ho Ho and a Bottle of Rum

    A2Billing - An Adventure in PBX Billing - Part 5Yo Ho Ho and a Bottle of Rum
    (It looks like I had a little to much rum! There is a section missing from this article - and you cant be successful without it. Before proceeding with this article, GO HERE and perform these steps. I'm sorry for not catching this sooner. 1/6/09 tshif)

    Its time to begin the actual administrative setup of the system for final use. That means getting a handle on, and creating in A2B, trunks, Calling Plans, Rate Cards, Rates, and of course, end user extensions.

    Tell FreePBX to route outbound calls through A2B.
    Before we begin working inside A2B admin webui, we need to make one change to the FreePBX Outbound route we created several articles ago – when we tested out user extensions on the Fonicatec Trunk. In FreePBX, navigate to outbound routes, and locate our outbound route. As we left it configured for initial testing, it was using the IAX/Fonicatec trunk directly. Now, its time to tell FreePBX to route its outbound calls through A2B. To do that, change the Trunk sequence from the IAX2/Fonicatec trunk to the trunk identified as A2B/1. (That trunk was created way back when we did the Joe Roper Provided install steps earlier in this series of articles.) Only the A2B/1 trunk should now be listed in the trunk sequence area.

    Navigate to the A2Billing Admin screens
    Job One: Change your A2Billing administrator ID and password. This is done under ADMINISTRATOR in the A2Billing admin interface. Use a safe, complex Password – this is the door to your empire, after all. ;) Heres a hint: User and administrators can log in using their email address instead of the 300 character card ID.

    Now lets consider the current scope of our task.
    • Calls coming into and going out of the PBX must be routed through A2B – for it to have awareness that the call has been made, and rate it. (Bill it). Facilities to do this were provided by Joe’s install write up earlier in this thread. The section [macro-dialout-trunk-predial-hook] and [custom-freepbx-a2billing], and the custom trunk you have made called A2B/1 will be used for this purpose.
    • A2Billing has to know about the trunks that are available to it. The tools used inside A2Billing to create, group, and manage trunks – and their providers – are located in the TRUNK menu of A2Billing Admin interface.
    • A2Billing has to know about the rates associated with the trunks. This is done by making rate cards with the tools found in RATECARD in the A2Billing Admin interface. Rate cards are accessed by A2Billing via the Call Plan. Call plans are also managed using the tools found in RATECARD in the A2Billing Admin interface.
    • A2Billing and FreePBX must cooperate in the information they know, and share about the users on the platform. To accomplish this, the CARD NUMBER from the CUSTOMERS section in the A2Billing Admin interface is entered in the ACCOUNT CODE field of the individual extension definition of FreePBX.
    • A2Billing must know about recurring billings that are not related to minutes usage. These are billing events against a users prepaid account that occur at regular intervals. This type of behavior is available to some extent in both recurring charges, and subscriptions. We will use subscriptions to bill each family their portion of the hosting fees (around $7.00) per month.
    Adding Trunks to A2Billing
    We already set up our Fonicatec trunk and tested it, so we will add it to A2B’s world view.
    Navigate to the A2B Admin screen, under TRUNK, select Create provider. In provider name enter Fonicatec, and confirm Data.

    Under TRUNK, Select Add Trunk,

    Select Fonicatec as the Provider,
    In Label, Enter Fonicatec-trunk.
    In Provider tech, enter IAX2
    In provider IP, enter the exact name of the trunk as you specified it in FreePBX. We called it simply Fonicatec, so that’s what we enter here.
    Confirm Data. It a good idea to delete the example trunk labeled DEFAULT at this time. We wont be using it.
    Rate Cards Calling Plans, and Rates
    Rate Cards and rates are the backbone of the rating engine. From them, calls are routed and billed.

    Adding a rate card for Fonicatec
    Under RATECARD, select Create New RateCard.
    In Tarrif Name, enter Standard - Fonicatec
    In trunk, select Fonicatec-trunk
    Confirm Data

    Adding a Calling Plan
    Under RATECARD, select Create Call Plan.
    For Name, enter Standard Family Plan
    For LC type, Select LCR: According to Buyer price
    For Remove Inter Prefix, select YES.
    Now, Edit the Newly created RateCard.
    For Add a New RateCard, Select and add the Standard-Fonicatec RateCard.

    The LC type selection determines what goals the rate engine works towards, when a called destination can be reached by multiple rates.

    The available types are LCR and LCD. When set for LCR (Least Cost Routing), A2Billing favors the route for the call that is cheapest for you.
    When set for LCD (Least Cost Dialing), A2Billing favors the route for the call that is the cheapest for the customer.

    Adding a user to A2B
    If you’ve been following along, some time ago in this exciting adventure in A2Billing, we created our telephone extensions in FreePBX. (If you haven’t, go Make your Extensions in FreePBX, then come back here.)

    Before A2B can accept and process calls from your users, we have to actually make the user accounts in A2B. Once created in A2B, we then tell FreePBX what the account code (aka Card Number) for each user extension.

    Lets start by creating a new A2B user the way an administrator would – inside the A2B admin screens. (Well go through the process of creating a user in the sign up screens, and then activating them a little later.)

    From inside the A2b Admin interface, select CUSTOMERS, Create Customers.

    The card number, or Account Number is system generated and can not be changed. The shortest length possible is 10 digits. The card alias can be changed, but should be left as a complex number. It is part of the Id/Password challenge to get into the user web interface, and as such should be protected via strength (long-ness, in other words.) The WebUI or end user interface, password is probably going to be user changeable.

    The length of the account number can be changed in a2billing.conf. However, this number is used to authenticate when using DISA / Dial through so don’t weaken your security to much with a weak (short) account number.

    Remember, You can use either the card alias or the email address to log onto the Customer_UI. The webUI password can be changed in the customer_ui.

    You must enter a balance; we will enter 0.00, to start out with zero cash in their account.

    For Call Plan, select the Family Call Plan we created earlier.

    For Activated and Signup Confirmation, select YES. This makes this user ID active from the time we create it.

    Simultaneous access setting controls how many active calls may be going on at the same time, your choices are Individual Access (One), or Simultaneous Access (Many). This setting should be set to Simultaneous Access to allow more than one call to be ongoing at any given time for this user ID. (For example, without this, the user would be unable to conference two callers).

    But – be careful. With individual access, only one call may be placed at a time. Should a bad guy manage to gain access to a user’s credentials, at least he would only be able to make one nefarious call at a time. With this set to simultaneous, with even modest PBX hardware, the bad guy could make upwards of 200 calls at a time – or more. This is another very good reason to be prepay ONLY. If you are set to postpay, and a bad guy gains access, and you have Simultaneous access enabled – they would potentially be able to do 200 times (or more) the amount of calling – all on your bill. Very very very bad.

    CARD TYPE determines whether this user must prepay for services, or if they are allowed to use services, and then be billed after the fact. We are PREPAY ALL THE WAY, so set accordingly. (Although A2B can do monthly bills, we are configured as prepay, so we wont be covering setting up monthly billing in this series of articles.)

    The bottom of the form is all about the user them selves. Name, address phone and fax numbers, can all be filled in to your satisfaction. Most of us wont be in Afghanistan, for example.

    Make a note of the CARD NUMBER at the top of the New User Form, and click CONFIRM DATA to save your new user.

    See A2Billing - An Adventure in PBX Billing - Part 5B – Yo Ho Ho and a Bottle of Rum
  16. tshif Guru

    A2Billing - An Adventure in PBX Billing - Part 5B – Yo Ho Ho and a Bottle of Rum

    A2Billing - An Adventure in PBX Billing - Part 5B – Yo Ho Ho and a Bottle of Rum (continued)

    Cooperation: FreePBX and A2Billing
    In order for FreePBX and A2B to cooperate, we need to paste the CARD NUMBER for the A2B user we just created into the same users extension definition inside FreePBX.

    Open the FreePBX administration tool, and go to EXTENSIONS., Select the extension for the user you just created in A2B, and past the CARD NUMBER into the field called ACCOUNT CODE. SUBMIT and accept your changes. We do this because A2Billing can authenticate users and calls on the basis of account code. Once done, FreePBX and A2B may live in harmony, and share this user.

    Repeat these same steps to add users to A2B every user you have in FreePBX, and supply them with their A2B CARD NUMBER.

    Another cool ability is to have multiple FreePBX extensions all billed against a single A2B account. To do that, just use the same account code in FreePBX for multiple users. Each one so assigned will decrement the same A2B Account.

    With these configurations added to A2B, we have created a path for inbound and outbound calls to be billed. However, A2B will only route calls to destinations for which rates exist – and since we haven’t yet created any rates, we aren’t yet ready to make any calls.

    I’m a big fan of before and after examples, so let’s take a quick look into one of the rate cards we have created, and verify that there are no rates yet. In the A2B admin interface, under RATECARD, select BROWSE RATES. Select Standard – Fonicatec in the drop down box, and click SEARCH. You should be greeted by the response NO RATES HAVE BEEN CREATED. We’ll perform the same test after we import our rates to see that they arrived intact and as expected.

    It is possible to create rates by hand – but you couldn’t pay me enough to sit through the process for long. Under RATECARD, select ADD RATE. Well review some of the more common fields to use.

    As you can see by the very first dropdown box on the New rate Form, each Rate is attached to a Ratecard via selection in the drop down.

    The Dial Prefix is mandatory – and the way that A2B determines when a particular rate is valid for a call being placed.

    Since were talking about the relationships and meaning of all the fields, let’s look at the two Golden Rules used by A2B for Rate and Trunk Selection.

    The rule about rate selection is :

    The rule about trunk selection is:

    This is best illustrated by jumping down to the bottom of the Add New Rate form we are looking at to see the dropdown box for TRUNK. A trunk is usually (always, in the case of this project) specified here, in the rate specification. This makes sense, since in order to get a specific rate, we need to use the trunk of the vendor offering it. So – if we were creating a rate by hand we would select our Fonicatec-trunk in this form.

    The next piece of data after Dial Prefix is DESTINATION. This should be a brief plain English description of where the prefix is geographically. For example, afghanistan cellular .

    The next three lines deal with your purchase price for voip service. The 3 fields have excellent descriptions. In case you haven’t experienced it yet, the BUYRATE MIN DURATION refers to the way voip services are often times sold. Once a call is connected, you may be billed a certain minimum, in many cases 30 seconds, for the call even if it lasts less than 30 seconds. This field allows you to properly account for that type of billing. The BUYRATE BILLING BLOCK is the increment at which you purchase talk time. For Example, 6 second increments are common. Another way of saying this is that you are billed for services, rounded up to the next full 6 second period.

    The next three lines after that are exactly the same, and have the same meaning - but list the rates and increments at which you will be Selling the services to your service subscribers.

    The blocks for Connect Charge and Disconnect charge are per call, and rarely used in the united states or the UK. Well leave them unused for this PBX.

    You will only see the next block of fields if you enabled advanced RateTables in A2Billing.conf. They deal with the ability to meter your services at tiered rates. For example, the first two minutes of the call will be billed at $0.025/minute, and time thereafter on the same call billed at $0.05 per minute. We wont be using anything that complex for this PBX, but its pretty amazing to have the flexibility to do it.

    The last block of fields contains start and stop dates and times that allow you to control when this rate is active. The default dates and times are designed to essentially be “starting NOW, and ending Never” reflect you desire to begin using the rate immediately.

    Its important to assign the rate to the correct trunk, so this drop down box should always have something selected.

    CID group is only effective when A2B is handling Caller ID, in our case, that’s FreePBX’s domain, so we ignore this setting in A2B.

    The Music on hold functions are handled by FreePBX in our system configuration. Ignore these configuration settings.

    Now that we have some familiarity with the fields involved in setting up a rate, let’s learn how to do it for a whole bunch of them at once, with very little work on our part. Sound good? It did to me.

    Under RATECARD, select Import RateCard. And don’t be afraid. :) This form may look daunting, but it’s really not so bad. This page allows us to import many rates at once from a CSV file. So – now we need to get a rate list from our trunk provider that covers all the rates to destinations they support.

    Since we are using Fonicatec for outbound calls, we need to add rates to the Fonicatec RateCard we created earlier.

    Most VoIP providers either have links to, or can supply via email, their current rates tables, formatted in CSV; But, sometimes, you have to cut and paste which is a total pain in the rear.

    In the file we are preparing to import into A2B, we will need to include the buy price information, initial block and increment data we get from the VoIP vendor, but also our own sell price, sell minimum block and sell increment data.

    That means that you will start with the buy prices you get from your vendor, and add information about your sell prices.

    This is best done using a spreadsheet program – I use MS Excel, and it’s not the prettiest experience I have ever had. Excel it seems is good at most of what we need to do – but cant export a CSV file using either the “;” or the “:” characters – the only two A2B will recognize. This situation requires a little two-step dance to overcome.

    Joe Roper has a really slick looking way of doing this that is totally different than what I’ll describe. Here is his explanation:
    I think it’s just to late to teach this old dog that new trick. If it works for you, it looks faster than my way.

    Ok, to do it my way, get the Excel spreadsheet located here. It is in spreadsheet (binary) format – and not ready for importing into A2B.

    When you open it in Excel, you will see 8 columns. They are from left to right:
    • Prefix Code (The First part of the dial string on which A2B performs matching to select the rate)
    • Destination Description
    • Sell Rate (Price per minute you charge to your users)
    • Initial Increment (Minimum buy Block, in seconds)
    • Subsequent Increment size (billing size, in seconds.)
    • Buy Rate (Purchase price per minute to this destination)
    • Initial Increment (The minimum billed call duration, in seconds)
    • Subsequent Increment size (your billing size to your end users, in seconds.)
    Columns 3 and 4 (C & D) are the only columns which have formulas in them.
    For column C, this formula is to mark up the minutes by a common factor across the board. We will be marking up the minutes used very slightly – in order to give them back to the users as “free calling time bonus” later on.

    See A2Billing - An Adventure in PBX Billing - Part 5C – Yo Ho Ho and a Bottle of Rum
  17. tshif Guru

    A2Billing - An Adventure in PBX Billing - Part 5C – Yo Ho Ho and a Bottle of Rum

    A2Billing - An Adventure in PBX Billing - Part 5C – Yo Ho Ho and a Bottle of Rum (Continued)

    Another thing we want to remember; This PBX is being hosted at Lylix. To have a few extra $ in the account from profit on minute sales might help cover a phone bill in the event any family or participant is late paying their share of the monthly hosting fees.

    Of course, You may prefer to buy and sell at the exact same price – and forgo my gimmick of “Free Bonus Minutes”. To do that, you may either edit the formula from =SUM(Fy*1.4) to =SUM(Fy*1.0), (where y is the ROW number) or simply copy the contents of column F (the buy rate) into Colum C, (The sell rate).

    For Column D, the story is a little more interesting. Most VoIP vendors arrange their services so that you must buy a certain number of seconds to begin the call – what A2B calls the buyrateinitblock. Fonicatec however instead has arranged their plan so that instead of buying a minimum number of seconds, each call has a minimum billing of $0.01. That means that to derive the actual buyrateinitblock (which is no longer a fixed number of seconds), we use the formula: (0.01 / <buyrate>) * 60.

    Another way of saying this is that for most vendors, column D will be a fixed number for each rate. For Fonicate, we have to get that value via formula. The spreadsheet attached to this article already has this formula in place for column D. Don’t edit this column if your using Fonicate USA Rates – its just the way you want it.

    In any event, the columns 1, 2, 4, 5, and 6 come direct from Fonicatec data, and should not be changed. The data in columns 3, 7 and 8 can and should be changed to reflect how you want to run your system. Adjust them as you see fit.

    Once you are satisfied with your rates, we will save this file from excel in a special way. And then the two-step dance I talked about.

    In excel, choose File Save. When the SAVE dialog box pops up, we want to save the file 2 different ways.

    First, save it as file type .wks. This keeps the formulas intact – and allows you to come back here and rework the spreadsheet in the event you need to massage some of the numbers.

    Second, save it as a file type .CSV. In excel, choose File Save. When the SAVE dialog box pops up, change the file type - set if for:
    CSV (Comma delimited)(*.CSV)
    And then save the file. Usually Excel will put a warning dialog about file formats and features. Just keep smiling and clicking and say YES, you’re sure you want the CSV format.

    When that’s done, the next step is to open that CSV file in WORDPAD. (Sometimes the CSV file is too large for notepad, and notepad is SLOW at performing the search and replace in the next step).

    Once inside WORDPAD, select EDIT, REPLACE. In the top line called Find What, place a single comma (“,”) character. In the bottom line called replace with, place a single semi-colon (“;”) character. Then click REPLACE ALL. Then, relax for a few seconds – while WordPad goes off and replaces all the delimitating commas with semi-colons that A2B can deal with upon importing the rates.

    When it finishes, save the results in a new filename with a TXT extension. It is this file we will import into A2B.

    Performing the Bulk Rate Import to A2B
    In the A2B interface, from RATECARD, Select Import RateCard.

    Once inside, choose the RateCard to import: Standard – Fonicatec
    Choose the trunk to use: Fonicatec-trunk

    The first three required fields are dialprefix, destination, and rate initial. This matches the first three fields in our bulk rate sheet, and in the correct order.

    Using the A2B web interface controls, add (in this order) buyrateinitblock, buyrateincrement, buyrate, initblock, and billingblock, to correspond to the remaining columns in our bulk rate file.

    Select currency import as Unit, and then browse to the file we saved from WORDPAD.

    Select IMPORT RATECARD, in a moment or two, A2B will show you an example of how your import is being parsed. Do a reality check here and make sure the columns are importing into the correct fields, and you are getting what you expect before proceeding.

    If all looks dandy, select Continue to Import the RateCard. In about 5 seconds, you should be greeting with the message Success, 4870 new rates have been imported.

    Now – we have all the elements in place for A2B to rate and route a call for us to the outside world. Let’s look at how that works.

    A2B Relationships
    You can follow these relationships by looking in the A2B admin webui, and considering the work we have just completed while reviewing the rules.


    For example, lets say you had two rates with similar dial prefix.
    One rate has a dial prefix of 9376, and one has a dial prefix of 937.
    If you were to Dial a call to 9377555555, A2B would select the second rate (937), while dialing 9376555555 would result in A2B selecting the first rate.(9376)

    This rule also lends itself to the ability to create number that can be reached free of charge. If you were to add a rate for say, 17605551212, and gave it a cost of zero, then calls to that number would be free of charge to the end user making the call..

    The rule about trunk selection is:

    In simpler terms, each User is assigned to a call plan. That call plans determines what rate cards are available for that users’ calls. The rate card holds rates to various locations.

    If more than one Rate Card has a valid rate to the called destination, then Rule 1 comes into play. “The rate is selected on the basis of longest match to dialed digits, and where the length is equal, cheapest rate. “

    Once the Rate has been selected, A2B uses the trunk defined in the selected rate to place the call (see Rule 2).

    See A2Billing - An Adventure in PBX Billing - Part 5D – Yo Ho Ho and a Bottle of Rum

  18. tshif Guru

    A2Billing - An Adventure in PBX Billing - Part 5D – Yo Ho Ho and a Bottle of Rum

    A2Billing - An Adventure in PBX Billing - Part 5D – Yo Ho Ho and a Bottle of Rum (Continued)

    We have one last task to perform before we can make our first test call out of A2B. We have to add some credit to one of the A2B user accounts.

    Navigate to the A2B admi webui – CUSTOMERS, List Customers. Select the user you want to use as your test case, and select EDIT. In the Balance Field, enter 5.00, and CONFIRM DATA to save your changes.

    Ok - You are ready to make your first outbound call through A2Billing.

    Pick up the extension you applied the $5.00 credit to and and try dialing an outbound number. You should be able to dial in the format NXXNXXXXXX, since we add the 1+ part in the outbound route of FreePBX. When done, A2B should have a rated record of the call. J You can verify this by logging into the A2B User interface as the test case user (whose telephone you used to place the test call), and look under Invoice, or Call record to see the results.

    This has been a LOT of work to accomplish in one sitting, so we will end here for this installment of Adventures in PBX billing. When next we take up the project, we will move into our next areas of configuration, configuring A2B to rate INBOUND calls.

    Inbound calls (which of course come from DID’s) are not too different from outbound calls, but they often carry little extras that have to be configured for. For example, we will be using a DID provider that includes a fixed amount of free minutes with each moths service, after which minutes are billed separately. So we have to have a way to account for the “free period”.

    We also need to prepare A2B to bill each family unit about $7.00/month to cover their portion of the hosting fees.

    We are also working a little extra surprise… We said in a previous article that we can’t use FollowMe with A2B. The reason is because the account code is not added in the FollowMe dial plan. Because A2B won’t know which account to bill, the call will fail – or prompt for an account number.

    That’s a real shame since FollowMe is such a cool feature – especially since the user can make changes from inside ARI. The FollowMe function cant readily be reproduced in A2B – so, Joe Roper and I will take a stab at patching the FreePBX FollowMe code so that we can use it with A2B – pretty cool, huh?

    For right now, let’s stay in the good habit of making system backups when we have made significant changes to our system.

    Go ahead and use the FreePBX backup program (as we modified it earlier in this series) to get all our FreePBX changes saved to backups.

    When you done with that – come on back to the A2B Admin webui, and select ADMINSTRATOR, Database Backup. Give your backup a meaningful name (I like to include the date), and Confirm Data. Now we’ll have a backup of our A2B in the event of catastrophic failure. I would be a lot happier if the backup also went off site – so, next time, maybe well look at including the path to the A2Billing backups in the FreePBX backups (the way we added other special folders).

    Until Next time - Merry Christmas to Everyone. Peace and Prosperity to you all.
  19. wardmundy Nerd Uno

    Fantastic articles! Thanks. :santab:
  20. jrglass Guru

    I am trying to test this on PBX with out A2 Billing and a soft video phone. I am not a public address. What should the sip_nat.conf be?



Share This Page