Our Auto Dialer Solution has been Multi-tenant from the beginning but one feature we were often asked to build was call billing. A lot of our customers want to build an Auto Dialer SaaS platform and for this they need way to charging their customers.

The great news, we’ve done exactly that, and finally added SMS & VoIP Billing into Newfies-Dialer.

Auto Dialer Software with Billing

auto dialer billing

FreeSWITCH Billing

We wanted a very simple billing solution in Newfies-Dialer which will allow Newfies-Dialer admin to define for each customer how much they pay per minute, irrespective of destination, and set a billing increment to round the call duration up per call. We looked around for ideas and for a while we considered building our own as we have a lot of experience with VoIP billing.

We finally decided to use Nibblebill as it did everything we needed for this project and works in near real-time. (https://freeswitch.org/confluence/display/FREESWITCH/mod_nibblebill),

Nibblebill is relatively easy to setup, you simply configure it to use the database, table and fields to use to identify the customer and which field to decrement the balance as each call is made.

Config file `nibblebill.conf.xml`:

    !-- Information for connecting to your database --
    param name="odbc-dsn" value="odbc://newfiesdialer:DB_USERNAME:DB_PASSWORD"
    !-- The database table where your CASH column is located --
    param name="db_table" value="user_profile"
    !-- The column name where we store the value of the account --
    param name="db_column_cash" value="balance"
    !-- The column name for the unique ID identifying the account --
    param name="db_column_account" value="user_id"

Once Nibblebill is enabled and configured properly, the next step is to pass the billing rules for each call. As we are building an auto dialer software, we need to set the parameters on each outbound call, this is done by setting channel variables on the call.

When you originate the call just add the Nibblebill account, rate and increment variables:

originate {ignore_early_media=true,originate_timeout=2,nibble_account=XYZ,nibble_increment=6,nibble_rate=0.02}sofia/gateway/123456789

The VoIP billing settings are straightforward:

  • nibble_account: This is the unique ID identifying the account to bill
  • nibble_increment: The billing increment for the calls, eg 6
  • nibble_rate: Amount of money to debit from the account after each increment elapses

The documentation to use Nibblebill for FreeSWITCH Billing is at [https://freeswitch.org/confluence/display/FREESWITCH/mod_nibblebill]

Finally, we need to retrieve the total call cost and insert this in the CDRs, Nibblebill helps again by providing a channel variable named `nibble_total_billed` which contains the total amount to charge for the call.


FreeSWITCH Billing is quite easy with the Nibblebill module. It calculates the cost per call and provides all the basic billing features to cover most cases. Integrating nibblebill on our auto dialer software was straightforward.

Nibblebill runs a lot of database calls so it is necessary to ensure that the database has sufficient capacity to deal with the extra load.

Cgrates (https://github.com/cgrates/cgrates) maybe a good alternative, certainly for more complicated rating and billing so our next step is to give it a try and see if there are advantages to using this as a base for our Auto dialer billing.

We hope that you enjoyed this introduction on how to do Billing on FreeSWITCH.