Moving from 3 digit to 4 digit extensions

I’m quickly running out of 3 digit extensions and am planning on moving everyone to 4 digit extensions and I’m trying to figure out how to do this with out breaking an outside callers ability to reach someone. I’m planning on recording our IVR message to include something like “we changed to 4 digit extensions, please put a 3 infront of the old extension” but I’m also hoping there is a way to direct the old 3 digit extensions to the new 4 digit extensions for a short time or if someone dials a 3 digit extension it will play a message saying the extensions have changed and are all now in the 3000 range.

Has anyone out there done a 3 digit to 4 digit switch? how did you deal with telling outside callers of the change?

I’m running Freepbx on Asterisk

Something like this should do the trick:

mysql> update users set sipname=concat('3',extension) where extension like '___';

This adds 3 in front of all 3 digit extensions and sets this as the SIP alias.

Or if you already have 4 digit extensions, this removes the leading 3 for the SIP alias:

mysql> update users set sipname=RIGHT(extension,3) where extension like '3___';

I would use the bulk extension tool to generate the new extensions.


I’ve used the bulk extension and bulk DID tool to update the extensions and scripted updating the mailboxes in /var/spool/asterisk/voicemail

I’m wondering if there is a way to redirect the old 3 digit extension to the new 4 digit? lets say my extension changed from 536 to 3536, if someone called from the outside and punched in 536 could it route to 3536?

I can’t think of a simple way to do that.

It is actually trivial and there is more than one way of doing it. The easiest one is to use the “SIP Alias” field and put the old extension number there.

Set up two IAX trunks to form a looparound using host=localhost. One of these is an outgoing trunk and the other incoming. Make the context of the incoming trunk from-internal. Then setup an outbound route to the outgoing trunk with XXX as the pattern to match and a prepend of the digit you are adding to the front end of your extension number. Make this outbound route the first in the list of outbound routes so it is looked at first. Calls will be routed round the loop and come back in as four digit numbers and be dealt with as if they had been dialled that way by the from-internal context.

Have used this method and it works perfectly, you just set it up once and no adjustments are required to individual extensions.

Guys, neither of these will accomplish his goal of being able to still enter the 3 digit extensions from the Phonebook or Directory Pro.

Thanks for the tip I’ll see if that will work.

This sounds much more complicated than I’m looking for, I think I can just tell my users “you’re SOL tell your vendors to put a 3 in front of your extension”

I am sure they will love you for that :wink:

I would think its possible to write a simple dialplan manipulation using [from-internal-custom] and there get all the 3 digits calls and add the new first of fourth digit and send it back to from-internal…

Yes Scott, was only thinking of internal calls. You can make a separate IVR item for each extension making the digits pressed the three digit extension number and directing the IVR output to the four digit extension number. Thats fine for a few extensions but for many would be a very tedious process.

if I could script this it might not be too bad, but if I had to manually do it through the GUI that would take forever (I’d have to do this for about 400 extensions)