Number manipulation

Hi All

I have setup a new FreePBX system which is working well except when dialing numbers from our address book.
There are two issues that I am experiencing.
The first is that the numbers are stored with the spaces between the numbers, ie 089 123 1234, when calling this number the calls fail.
Secondly, some numbers have the full international number +27 89 123 1234, which also fails.

Does anyone have some basic instructions for a FreePBX noob to firstly remove the spaces and secondly change the +27 to a 0?

Any help would be greatly appreciated.

The second part (converting +whatever to something else) should be easily handled in your outbound route and trunk.

Removing spaces is more problematic. The easiest solution for this is to not store spaces in your address books (data should be pristine in a database). If that isnā€™t a good choice for you, there should be a custom context that you can modify/add on your way out that will scan the number and remove all spaces. Iā€™m not sure which context that would be, but it should be relatively easy to find.

To figure out which contexts you are using, place a call that works and watch the /var/log/asterisk/full file (you can use ā€œtail -F /var/log/asterisk/fullā€). The contexts you are executing are the pieces that look like ā€˜from-internalā€™.

There are a bunch of things that happen when you place a call - one of these contexts should be modifiable to adjust your outbound number. Look for the code that is setting the outbound Caller ID and get smart from there.

Hi Dave

Thanks for your prompt feedback. Removing the +27 should be fairly straightforward from what I have researched. I will give it a go later.
The spaces issue is a little more complicated as you say, the numbers are stored in Active Directory, I have asked my manager if its necessary to keep the spaces or if we can remove them. In the interim I will give your suggestions a go.

Thanks again.

Hello,

Add this to your extensions_custom.conf file:

[macro-dialout-trunk-predial-hook]
;Remove spaces or dashes or + from outbound number when calling
exten => s,1,Set(OUTNUM=${FILTER(0123456789*#,${OUTNUM})})
exten => s,n,MacroExit()

After saving it in your extensions_custom.conf file, run the following command from the linux console:

rasterisk -x'dialplan reload'

Thank you,

Daniel Friedman
Trixton LTD.

1 Like

Daniel you are a genius! It works perfectly. Thanks a million.
I hope you have a very happy new year!

Kind regards
Robert

Hello,

You are welcome, happy new year to you too.

Daniel Friedman
Trixton LTD.