FreePBX 12 – Configure inbound calling

Configuring inbound calling can be one of the trickiest things to get working in FreePBX. Here we are going to configure the inbound number we purchased with Localphone.

One of the most important points is that you must match the inbound phone number exactly as the call provider are sending it to you. This can vary by provider so check with them what you should do. If you still can’t get it working open a support ticket and we’ll check it out.

1 – Select Connectivity / Inbound Routes from the main menu

FreePBX 12 Connectivity Inbound Routes

2 – Enter Inbound Route details Continue reading

FreePBX 12 – Configure outbound calling

For outbound calling we need to tell FreePBX what trunk (call provider) we should use when we dial a number that’s not an extension number or a special internal number.

We need to specify 2 things at least – the number pattern to match and the trunk to send the call via. The number pattern can be anything from “all numbers” to say numbers starting with “447540”. We can use this to send different types of calls via different providers. Maybe we want to use one provider for landline calls and another for mobile calls.

1 – Select Connectivity / Outbound Routes from the main menu

FreePBX 12 Outbound Routes

2 – Enter the Outbound Route details Continue reading

FreePBX 12 – Configure a trunk

A trunk is our connection to the outside world. We use it to tell FreePBX about any call providers we use for inbound and outbound calls. You can set up as many trunks as you want.

Configuring a trunk with different providers will be similar but can vary in the exact settings used. If you’re unsure how to configure FreePBX with your provider ask them for information about configuring their service for use with Asterisk (and specifically FreePBX). If you still can’t get it to work open a support ticket and we’ll check it out.

Here I’m going to use the Localphone account we configured here

1 – Select Connectivity / Trunks from the main menu

FreePBX 12 add a trunk

2 – Specify that you will create a SIP trunk Continue reading

FreePBX 12 – Choose a call provider

There are literally hundreds of different call providers to choose from (sometimes called ITSPs) and choosing one can seem daunting. The good news is that any provider that supports SIP should work with Asterisk.

The only difficulty is some providers don’t publish details on using their service with Asterisk. If you’re thinking of using a provider ask if they have details for using their service with Asterisk – it’s also a good opportunity to test out their support!

Here I’m going to use Localphone but the process is usually similar with other providers. You sign up for an account, deposit some pre-paid balance, configure FreePBX then start making calls. This is for outbound calls.

Continue reading

FreePBX 12 – Configure an extension

Creating an “extension” in FreePBX sets up the account details that we will use in our actual extension to connect to the system. Our extension could be a physical VOIP extension (like the Yealink T22P), a softphone for your computer (like Linphone) or an app for your mobile phone (like Zoiper). Whichever it is we create the extension in FreePBX the same way.

1 – Log in to FreePBX and select Applications / Extensions from the menu bar at the top

FreePBX 12 Applications Extensions

2 – Ensure “Generic CHAN SIP Device” is selected and click submit Continue reading

Monitoring your Peers (Asterisk extensions) and Trunks

As an admin for a telephone system, possibly one of the most useful things you can do is monitoring your peers and trunks. There are 2 great reasons you should do so:

1. You can respond to and resolve issues with your system before your users know about it, and you can be in the know if someone reports “none of the phones are working” when in fact only 1 or 2 are not working

2. You can actually know when there is a problem with the system – where you otherwise might not know there is a problem until someone calls on your mobile to say your office number is not working

 

I have 2 scripts running every 15 minutes to email me with the details of any down extensions and trunks. This is done in Crontab with the line:

*/15 8-18 * * Mon-Fri /usr/Peermonitor.sh

and similar for Trunkmonitor.sh. This line says to run every 15 minutes between 08:00 and 18:00 every Monday-Friday

Continue reading

Posting Asterisk/FreePBX calls to Toggl

Toggl is a hosted time tracking system, used to keep track of time spent of different projects.

If you use Asterisk/FreePBX and spend time on the phone to clients that should be assigned to a project you can automatically create time entries in Toggl using their API. To do this we can make a curl call from Asterisk when a call ends.

To be able to do this you’ll need to ensure you have curl compiled in to Asterisk. You can check this with “core show function CURL”.

I tested this on Asterisk 11 and FreePBX v2.11, but it should work the same on other versions.

First we need to add a little dial plan code to Asterisk to tell it to run our script when a call ends. We going to do this by adding the following lines to – /etc/asterisk/extensions_custom.conf

[macro-dialout-trunk-predial-hook]    ; check to ensure this context doesn't already exist before adding
exten => s,1,Set(CHANNEL(hangup_handler_push)=hangup-handler,s,1)

[hangup-handler]
exten => s,1,Noop( capsule crm intergration ${CALLERID(all)})
exten => s,n,Set(foo=${CURL(http://127.0.0.1/toggl.php?strSrc="${CDR(src)}"&strDst=${CDR(dst)}&strDuration="${CDR(duration)}")})
exten => s,n,Noop(${foo})
exten => s,n,Return()

Continue reading

Posting Asterisk/FreePBX CDRs as a task in Capsule CRM

I was recently talking to someone that was looking at running Capsule CRM.

In Capsule you can create a “Task” which is something that has happened or will happen. These “Tasks” can then be assigned to a customer or contact.

Capsule has an API that allows automating posting of these tasks and we can use CURL in Asterisk to post the call details.This guide was written using Asterisk 11. If this doesn’t work for you ensure you have curl compiled in to Asterisk with “core show function CURL”.

First we need to tell Asterisk to run a command when a call ends. We are going to do it at the end so that we can get the length of the call. FreePBX allows for this using a hangup-handler.

We are going to add the following lines to – /etc/asterisk/extensions_custom.conf

[macro-dialout-trunk-predial-hook]    ; check to ensure this context doesn't already exist before adding
exten => s,1,Set(CHANNEL(hangup_handler_push)=hangup-handler,s,1)

[hangup-handler]
exten => s,1,Noop( capsule crm intergration ${CALLERID(all)})
exten => s,n,Set(foo=${CURL(http://127.0.0.1/capsule.php?strCallid="${CALLERID(num)}"&strDuration="${CDR(duration)}")})
exten => s,n,Noop(${foo})
exten => s,n,Return()

Continue reading

A2Billing advanced troubleshooting

This is intended for advanced users – please see here for general A2Billing troubleshooting tips – https://sysadminman.net/blog/2015/troubleshooting-common-a2billing-problems-6451

Sometimes it can be really useful to figure out what’s going on behind the scenes in A2Billing. This is useful for tracking down bugs.

It’s very unlikely you’d want to do this unless you have a good understanding of editing Linux files, PHP and MySQL.

To find out what queries A2Billing is running when we look at things in the GUI we can turn on “PHP Quick Profiler”

On a SysAdminMan VPS you turn this on by editing the file –

/var/www/a2billing/admin/lib/admin.defines.php

Continue reading

Troubleshooting common A2Billing problems

I see customers having the same issues with A2Billing so thought I’d do a list of the most common ones. This list must account for at least 90% of the issues I see. This list applies where A2Billing is installed correctly, but you’re having issues making calls.

Does the call work in the simulator?

The first thing to check is whether the call works OK in the A2Billing call simulator. You can find out how to do this here – https://sysadminman.net/blog/2011/a2billing-troubleshooting-ratecard-simulator-2407

If the call does work OK in the simulator then it’s likely your customers and rate cards are setup correctly and the issue is with your trunk. If the call works OK in the simulator then check your outbound trunk is setup correctly and that you have call credit with your call provider.

If the call doesn’t work in the simulator then check out this list of potential problems …

Is the number in the correct format?

When your customers dial the number they want to call they could do it in a variety of formats. For example when calling a number in London where the country code is 44 and the city code is 20 they might dial –

  • 00 44 20 XXXX XXXX  – international format when calling form the UK
  • 011 44 20 XXXX XXXX  – international format when calling from the US
  • 44 20 XXXX XXXX  – international format with no international access code
  • 020 XXXX XXXX  – local dialling from within the UK

So there are lots of ways the number could be dialled, but the number will be in your A2Billing rate cards in a particular format. You need to ensure when the number is matched against the rate card it is in the correct format. It’s easy to confirm if this is the issue by entering the number in the simulator in the same format it is in your rate cards.

It does depend a little on your circumstances but I normally recommend customers have their rate cards formatted as number 3 in the list above, just starting with the country code, not an international access code.

The international access code can be removed from the number called by …

Setting Yes to “Remove International Prefix” on the rate card –

remove international prefix

Setting the numbers that should be removed on the agi-conf being used –

international prefixes
Continue reading