Is there a way to strip formatting like hyphens from a phone number?

sometimes if i copy paste a number into my soft phone it has formatting in it like (xxx) yyy-yyyy and it will pass that formatting to freepbx and i will get an all circuits are busy message unless i manually remove it. Is there a way to sanitize the number with freepbx?

Or am i overthinking this and if i just created dialing rules with the - and () would it pass them on my trunks without those characters?

Yes, you can remove any special characters by adding the following dial plan to the extensions_custom.conf.

[macro-dialout-trunk-predial-hook]
exten => s,1,Set(OUTNUM=${FILTER(0123456789*#+,${OUTNUM})})
exten => s,n,MacroExit
1 Like

Thank you, that worked for hyphens, it doesn’t seem to work for a number with parenthesis though. the issue is someone copying and pasting a number into the dialer. We’re using tsip for now until a bug with feature code blf monitoring is fixed in the samgoma desktop dialer.

This is weird. The function FILTER(0123456789*#+,${OUTNUM} removes every character except 0123456789*#+. So parentheses are also removed.
What is the output of the command tail -f /var/log/asterisk/full | grep OUTNUM when you are calling a number with parentheses?

[2023-10-12 22:59:46] NOTICE[2385] res_pjsip_session.c: 200: Call (TLS::50655) to extension ‘(555)555-5555’ rejected because extension not found in context ‘from-internal’.

Looks like the predial hook isn’t even applied. Is there any output in the terminal when you enter this tail -f /var/log/asterisk/full | grep macro-dialout-trunk-predial-hook and doing a call?
Which version of FreePBX you are using?

I ultimatly gave up on tsip, I had another issue with it where conference calls were awful call quality, but fine with other dialer. And one of my employees had an issue with tsip where the remote end would hear an echo, but every other dialer we tested was fine.

no the macro is not getting touched at all with () in the phone number, but with hypens it does hit. However other dialers are stripping the hypens before sending it to asterisk.

PBX Version:16.0.40.7

PBX Distro:12.7.8-2306-1.sng7

Asterisk Version:18.19.0

What is ‘tsip’ ?

It’s a fairly powerful open source dialer that has it’s own scripting language. One of the things i like about it is i was able to write a script that would play a boilerplate precorded legal disclaimer to folks so we don’t have to waste our breath every time. However the 2 most recent quirks have it made it a poor choice for us.

Asterisk’s FILTER() command would need to be called before you ever send your call to a third party app/context, (I can however assure you that it works though, been using it for many years :slight_smile: )

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.