Our Asterisk-based PBX (FreePBX "Tango" distro) does not require any prefix for outgoing calls. The system is able to recognise external numbers and route them appropriately.

Some of our users who are accustomed to older PBXes habitually dial a 9 'for an outside line'. This doesn't work, the system gives them an unintelligible error message and they raise a support ticket saying 'The phones are not working'.

What I would like to happen is that the users receive a recorded announcement, informing them that they need to 'hang up and redial without the prefix'. I can record the announcement, set it up as an announcement on the system, but then I run up against a brick wall. Outbound routes only let me route to trunks. How can I route misdialled numbers to my custom announcement?


  • The solution must be completely realized within the FreePBX GUI, we don;t allow direct modification of any config files.
  • A 'misdialled number' is defined as matching the dial pattern: 9[046-9]XXX.
  • The call should be routed to the selected announcement, then hang up.

Any help would be appreciated.

  • 2
    Is there a reason not to just handle 9+whatever in your outbound routes? edit - in either your trunks or routes, you should be able to match numbers with a 9, then remove it. – tsz Feb 21 '12 at 0:12
  • @lorsungcu - I did consider that option but without going into the details, there are a number of operational reasons why I'd prefer not to. I'm holding this in reserve as my 'plan B'. I'd rather be able to educate the user not to dial a prefix by playing an announcement. – Tim Long Feb 21 '12 at 1:18
  • I can't think of a reason to not just handle this for users; can you explain? – tsz Feb 23 '12 at 6:14

Alright, a different approach:

  • Create an announcement.
  • Add extension (virtual)
  • Give it a number, make it so its no answer destination is your announcement.
  • Go to trunks
  • Add custom
  • Destination: "Local/{ext}" (replace {ext} with extension number, ex: Local/1000)
  • Add an outbound route, see dial patterns below, first route (so it catches all calls), destination is the trunk you just made.
  • Dial Patterns:
  • 9xxxxxxxxxx
  • 91xxxxxxxxxx

This should provide that functionality.

Works fine on my VM PBX that I get to play with when experimenting with weird deployments like this.

You may be able to look into custom dialing the announcement directly, but I'm not sure you can do this (as far as I know, you cannot play an announcement with the dial() command).

  • 1
    Simpler method would be to just create an IVR, send calls matching your pattern to it. Most SIP phones allow some sort of dialplan rewrite, just rewrite it there as the extension of the IVR. You could also handle it through outbound routes, as StrangeWill suggests, and cover all your bases. – tsz Feb 23 '12 at 6:13
  • Oh yeah, and if you're using FreePBX for configs, phone dialplan rewrites are pretty straight forward to deploy and wont nearly make people scratch their head as much as my setup probably would. – StrangeWill Feb 23 '12 at 20:45

Write a simple module that modifies the config files to replace the message played? It's all PHP so it should be fairly trivial if you have any programmers available.

  • Thanks for the suggestion. It's a thought, but unfortunately, I don't have programmers available. The solution needs to work with the existing FreePBX framework. If a module were available, that would be OK, but we don't have the means to make one and even if we did, it would be 'unsupported' (by FreePBX). – Tim Long Feb 21 '12 at 21:49

You can also accomplish this with a Misc Application, custom Trunk and Outgoing Route.

Create your System Recording and Misc Application (noting the feature code) then do the following to configure your custom Trunk and Route.

  1. Add Custom Trunk
  2. Give it an Outbound CID (useful for filtering CDR reports) such as out-misdialled
  3. Under custom Settings set the Custom Dial String as Local/*XXX@from-internal replacing XXX with your Misc Application Feature Code
  4. Create new Outbound Route selecting your newly created Custom Trunk under Trunk Sequence for Matched Routes
  5. Setup Dial Patterns
  6. Drag this new Outbound Route above your other routes

You should be setup at this point!

We use this technique to block and warn users of premium rate numbers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.