Asterisk DTMF Routing

I’m attempting to use Asterisk as a replacement voicemail server for an old Comdial PBX. I’m using Sangoma U100 USB fxo modules to interfaces with the PBX. The PBX has an FXS card that is connected to the modules, and when it transfers someone to voicemail, it rings the extension, waits for it to pick up, then sends the DTMF digits of the extension. The challenge I’m having is that I need to create some sort of extension/dialplan that answers the call on one of the six fxo modules, waits for the DTMF digits, then transfers the call to the correct extension.

I’m using Trixbox (FreePBX), so I’m guessing either a custom application or a dialplan injection is what I need to use, but I’m not familiar enough with Asterisk dialplan programming to know how to handle this. Could someone help me out? The extensions are four digits. I’ve already enabled DTMF debugging, and I can see the DTMF digits being sent, so I know this much is working. Just need to create the rules to route it correctly!


So, I got this partially working, but need to add some complexity to it. Here’s what I have in my dialplan injection right now:


So, I added a Zap channel DID for each of the analog lines that points it to the extension for this dialplan injection. The injection then does the steps above - reads a four digit number, passes that number off to the vm macro, then returns. However, I need to add some conditional steps in this particular dialplan. The PBX that I’m working with does several things depending on how the voicemail extensions are dialed:

  • If DTMF is 9+, then the user has pressed the VMAIL button on their phone and expects to get a password prompt (logon).
  • If DTMF is 8+, then user has pressed the MWI button on their phone, has messages waiting, and should get the password prompt and the messages should start playing.

Can someone help me rework the dialplan to support this sort of conditional formatting? I know I need to change the 4 to a 5 on the read line, but I need some help with how to handle the conditions, where to send each condition, etc.


And one more question…what’s the easiest way to get Asterisk to hang up when it sees the DTMF digit “A” (or a)?