Removing characters before dialing anything

My users are using mainly soft phones, and they have the phone numbers in their contacts using the whole number including the international prefix (+1 XXX YYY YYYY) for example.

I already have a outbound routes that handle different prefixes (+1 and +54) and route those numbers to the appropriate trunk based on the country prefix.

My problem, however, is that when the users dial from their soft phones, I’d get numbers with spaces or parens. For example, if a user is calling +1 800 692 7753 (Apple’s toll free number), I’d get something like +1 (800) 692 7753. When this happens, I get an error that says:

Call (TLS:redacted IP) to extension '+1 (800) 692 7753' rejected because extension not found in context 'from-internal'.

I’ve already set macros to filter the numbers when they leave FreePBX (as seen here in another post and suggested by user @danielf ), using macro-dialout-trunk-predial-hook.

This works great, but only when the number has matched an outbound route. I can work around it by adding more rules to the outbound routes, but it seems cumbersome (I need to account for many combinations, white spaces, parens, etc.).

Is there a way I can filter out some characters (spaces, parens) before any additional processing is done? I think from-internal-custom would be the place, but I’ve failed when trying to implement it there.

Bonus points: is there a way to convert letters to numbers, in the same transformation? So a call to +1 (800) MY APPLE would get through?

Most commercial soft phones have a built in number cleanup tool. (I know Bria sure has it, not sure about other brands)

Edit: Sample cleanup: Jolt-Select-Dial-PBX/call.php at master · Jolt1/Jolt-Select-Dial-PBX · GitHub

that’s correct. I’m using GSWave Lite and it has the option. However, for some reason it doesn’t work… So I’m guessing I can’t rely on client filtering and want to ensure the server can properly handle that.

an outbound dial hook with

https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Function_FILTER

?

1 Like

Yes, but you want it before the Outbound Routes, so put it in from-internal-custom

1 Like

I tried that… but it ended in an infinite loop…
My rule in from-internal-custom matched (because it started with a +), I changed it to filter those special chars and then continue in from-internal… But then, since it started with a +, it matched again, and ended up in a infinite loop…

Post your code exactly for peer review

[from-internal-custom]
exten => _+.,1,Goto(from-internal,${FILTER(0123456789*#+,${EXTEN})},1)

Yep that’s re-entrant , try removing the + from the FILTER()

If I remove the +, it won’t match my outgoing routes.

This seems to work fine, although I’m not sure why:
exten => _+.,1,Goto(from-internal,${FILTER(0123456789*#+,${EXTEN})},2)

(notice the 2 at the end, instead of a 1). Any idea why?

Refactor your outbound routes. add the + back there.

Sorry missed your second part from a shell

rasterisk -x "dialplan show  18005551212@"|less

before and after your changes ( use any phone number)

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