How to rewrite incoming number

I am using RasPBX and I am receiving incoming calls from USB modem. Now, the incoming numbers are in international format, +38641123456.

However, on my mobile phone I am using Zoiper and in contact list I have numbers in format: 041123456.

So, if I receive a call from +38641123456, my phone will not show the name of the contact (e.g. “Friend 1”). So I am wondering, is it possible that FreePBX would automatically remove the “international” part (“+386”) from the number (and add “0” - so the final result would be “041123456”), but only if the number has +386 prefix?

Additonaly, I have a rue, that I can call outside numbers only in this local format, e.g. “041123456”. So the option would be, that I could have phone numbers in my contact list in a format +38641123456, but when I would try to call outside, FreePBX would strip “+386” and add “0” (again only for +386 prefix).

Any idea how to achieve this?

Custom dialplan:

[custom-strip]
exten => _+XXXXXXXXXXX,1,Goto(from-trunk,0${EXTEN:4},1)
exten => h,1,Macro(hangupcall,)

Thank you for this, however I am a newbie and don’t know in which file should I put that?

see

OK, I will try to rephrase my question.

I am using RasPBX with “chan dongle” and I have a rule, that local extensions can call outside (through trunk) only non-commercial numbers inside my country. Basically, my dial pattern is:

  • no international calls
  • calling only to local phone networks from 01 to 08
  • 090 network is not allowed (because 090 numbers in my country are so called commercial numbers).

But I would like that call is executed if I call +38640123456 or 040123456.

So this is my dial plan for outgoing calls:

Basically, the first rule allows me calling numbers like 040123456. The second rule allows calling to free numbers (in my country they are starting with 080).

Now, the third rule should allow calling to +38640123456… but it does not work. My idea was that it should remove 386 and add 0 at the beginning of the number. And the final number should not start with 09 (because these are commercial numbers).

What am I doing wrong?

If you are actually dialing a number that starts with ‘+’ your prefix on the route pattern should be +386. If you just dial 38640123456, your pattern should work. You also need to consider if your outbound vendor requires a ‘+’ in the dial string as most do not.

I found this:

I guess they do not require + sign (and it is actually the replacement for 00), but the point is that I am using Zoiper app on my mobile phone, and phone numbers in my contact list are in a +386... form.

So, basically I just need to put +386 in prefix, match pattern remains the same and prepend stays 0? Is that correct?

Outbound Routes Module User Guide - PBX GUI - Documentation (freepbx.org)

Prepend

The prepend will be added to the beginning of a successful match. If the dialed number matches the patterns specified by the subsequent columns, then this will be prepended to the sequence before sending it to the trunks.

Prefix

Prefix to remove upon a successful match. The dialed number is compared to this and the subsequent columns for a match (prefix + match pattern). Upon a match, this prefix is removed (stripped) from the dialed number before sending the sequence to the trunks.

Match Pattern

The dialed number will be compared against the prefix + this match pattern. Upon a match, the match pattern portion of the dialed number will be sent to the trunks.

Yes. That is correct.

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