Removing + from Incoming calls

We currently have two phone service providers that we use with our FreePBX system. One of them send us the CallerID number with a plus in front of the number, for example when we get a call into out system it appears as +13334445555, its ok and everything works, but on our phones it records the number just like that in it’s history and when we go to dial it from the phone’s history it says bad number and our FreePBS system rejects the call. Is there a way we can strip the plus off the front of the number or allow calls to include a plus coming in from our phones? And by the way most of the phones we use are Grandstreams.


instead of sending the call to from-pstn, send it to a custom context you create. That custom context can strip off the + from the CID (and from the DID if you want) and then send the call on to from-pstn.

When you said “instead of sending the call to from-pstn, send it to a custom context you create” where do I go to make those changes, I have looked in FreePBX and couldn’t find any options in incoming, outgoing, extensions, and trunks.


Check out this page:

You are wanting to strip rather than add a digit, but this should give you about 90% of the information you need. If you study the page on Asterisk variables at (and especially the section on substrings) you can probably figure the rest out.

Thanks for your help, these pages have been very helpful and I was able to create 2 custom contextes:

exten => _X.,1,Set(CALLERID(num)=${CALLERID(num):2})
exten => _X.,n,Goto(from-trunk,${EXTEN},1)

exten => _X.,1,Set(CALLERID(num)=${CALLERID(num):2:12})
exten => _X.,n,Goto(from-trunk,${EXTEN},1)

Supposedly both of these should strip the first 2 characters off the callerid, so I went into the trunk of the first provider (Voxitas) and remembered the trouble we had setting it up. In the trunk we had to name it our username and fill in the outgoing peer settings and leave the incoming user context and user detailed blank. I entered in the incoming user details context=from-trunk-0-custom and context=from-trunk-1-custom and also tried setting soming in the user context and then broke our connection. So I restored it back to the way I had it and then I went to our other provider’s trunk (Teliax) which had information in incoming and outgoing settings and I changed the context to point to the first custom context and then the other and it didn’t strip the first 2 digits off 2223334444 so it should have came through as 23334444 showing it worked right?

Thanks again for helping me

Any suggestions on what I might be doing wrong or how I could get this working?


You have X. but “X” matches 0-9, it does not match ‘+’ which is how your number is coming in. Try "+1X." since that is probably how your dids are coming in.

1 Like