FreePBX voicemail hacks


This is an edited version of a post that originally appeared on a blog called The Michigan Telephone Blog, which was written by a friend before he decided to stop blogging. It is reposted with his permission. Comments dated before the year 2013 were originally posted to his blog.

This article was originally posted in January, 2011 and may contain outdated information.

Motel Phone
Image by Andreas_MB via Flickr

A few things you should know about FreePBX voicemail:

• If you are not receiving voicemail notifications (stutter dial tone, message waiting indication on certain phones, etc.) there are two things to check.  One is to go into /etc/asterisk/ and see if there is a line of the form ;pollmailboxes=yes — if it is commented out (semicolon in front), uncomment it by removing the semicolon.  The other is to go to the /var/spool/asterisk/voicemail directory and make sure that you have directories there called default and device, and that one is symlinked to the other (generally default is the “real” directory and device is the symlink). If the device directory is missing, make sure you’re in the voicemail directory and do this:  ln -s default device

• If you have users in different time zones, you can have the voicemail “envelope” information say the correct time by creating a [zonemessages] context at the end of /etc/asterisk/ (in later versions of FreePBX you can also enter these in the Timezone Definitions section of the Voicemail Admin module) — here’s a simple one showing the four major time zones in the continental United States (I know this is not complete, it’s just an example):

[zonemessages] eastern=America/New_York|'vm-received' Q 'digits/at' IMp
central=America/Chicago|'vm-received' Q 'digits/at' IMp
mountain=America/Denver|'vm-received' Q 'digits/at' IMp
pacific=America/Los_Angeles|'vm-received' Q 'digits/at' IMp

Then, on each extension setup page in FreePBX, find the Voicemail & Directory section, and under that the VM Options.  In the VM Options add a tz= option for each user (for example, tz=eastern), using one of the zones you defined under [zonemessages] in /etc/asterisk/  Note that multiple options in VM Options must be separated by the | (vertical bar) character (not that you’re likely to have multiple options, but I mention it just in case).

• If your system is not used in a large office, or some other location where not all users can be trusted, you can disable the requirement to enter a PIN when using *97 to pickup voicemail for your own extension.  To do that, add the following context to /etc/asterisk/extensions_custom.conf:

NOTE: This is the original code for older versions of FreePBX:

[custom-voicemail-retrieve] exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Macro(user-callerid,)
exten => s,n,Macro(get-vmcontext,${CALLERID(num)})
exten => s,n,VoiceMailMain(${CALLERID(num)}@${VMCONTEXT},s)
exten => s,n,Macro(hangupcall,)
exten => h,1,Macro(hangupcall,)

In newer versions of FreePBX (probably 2.9 and later) use this instead:

[custom-voicemail-retrieve] exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Macro(user-callerid,)
exten => s,n,Macro(get-vmcontext,${AMPUSER})
exten => s,n,GotoIf($["${VMBOXEXISTSSTATUS}" = "SUCCESS"]?mbexist)
exten => s,n,VoiceMailMain()
exten => s,n,GotoIf($["${IVR_RETVM}" = "RETURN" & "${IVR_CONTEXT}" != ""]?playret)
exten => s,n,Macro(hangupcall,)
exten => s,check+101(mbexist),VoiceMailMain(${AMPUSER}@${VMCONTEXT},s)
exten => s,n,GotoIf($["${IVR_RETVM}" = "RETURN" & "${IVR_CONTEXT}" != ""]?playret)
exten => s,n,Macro(hangupcall,)
exten => s,n(playret),Playback(beep&you-will-be-transfered-menu&silence/1)
exten => s,n,Goto(${IVR_CONTEXT},return,1)
exten => h,1,Macro(hangupcall,)

Then do the following in FreePBX’s GUI (do these steps in the order shown):

Go to Feature Codes and under Voicemail, disable “My Voicemail” (*97) using the dropdown, then Submit Changes.

Go to Custom Destinations (under the Tools tab) and create a new Custom Destination:  custom-voicemail-retrieve,s,1 — then Submit Changes.

Go to Misc. Applications and add a new Misc. Application. Make the feature code *97 and the destination the Custom Destination you created in the previous step, then Submit Changes.

Finally do an “orange bar reload” in FreePBX. Now when your users dial *97, it will assume they are authorized to pick up the voicemail for the extension they’re calling from. Obviously, this is probably not a good idea in any kind of office setting.

Got any other FreePBX voicemail hacks you like?

9 thoughts on “FreePBX voicemail hacks

  1. Pingback: Tweets that mention FreePBX voicemail hacks « The Michigan Telephone blog --
  2. I saw on the forum that someone was promoting a transcription engine that runs on the Asterisk server and transcribes voicemail for you. Unfortunately the recognition rate is abysmal. I was thinking about how to modify the standard Asterisk voicemail scheme so that instead of e-mailing with the recording, it replays the recording to Tropo (which has a good transcription system) which then e-mails back the recording in MP3 format, along with a transcript.

    The clunky part of course is going through the steps to play the already-recorded wav file to Tropo. Maybe it’s better to just send all VM to Google Voice and be done with it. Or build a whole (customized) voicemail system in Tropo and redirect all the unanswered calls there, turning off Asterisk Mail completely. None of these projects appeal to me that much because I find it hard to get excited about voicemail. 🙂

  3. Thank you for posting this, I’ve been using this for quite a while on my home PBX system. I’ve come across and issue where by the latest release of voicemail breaks this functionality. Is there another macro that should be called?

    1. Steve, I fixed this on our system a long time ago but totally forgot that I had written this, so thanks for bringing it to my attention. I’ve included the code I’m using now in the article, which I think is actually necessary for any FreePBX 2.9+ install. This appears to still be working with voicemail, at least on our system. Knowing how the FreePBX developers (and the Asterisk developers) love to break existing functionality, I wouldn’t be too surprised if this happens again someday.

  4. Thank you! Works beautifully. The upgrade also breaks the voicemail if you are in deviceanduser mode. I’ll have to dig in to this one next weekend, but for now, thanks so much!

  5. I am using a OBi202 with FreePBX Will these instructions work for this as well? I’m currently unable to get voicemail by dialing *97. It does allow me to check my google voicemail however.

    1. These should work in 2.9 — just use the second [custom-voicemail-retrieve] context shown above. The way I handle conflicts between star codes on the PBX and OBi device star codes is to insert this line into the already-existing [from-internal-custom] in extensions_custom.conf:

      exten => _11XX,1,Goto(from-internal,*${EXTEN:2},1)

      This way, *xx codes control the Obihai and 11xx codes get translated to *xx at the PBX. So instead of dialing *97 or *98 to check voicemail, you’d use 1197 0r 1198. Note if you do that you’ll have to add a rule to your OutboundCallRoute to force 11xx calls to go to the proper service provider. You should be able to get *97 calls to go through now by dialing **x*97 (where x is replaced by the proper service provider number, and you may want to hit the # key at the end to shorten the delay) but if that doesn’t work it’s because the phone port OutboundCallRoute(s) need modification (you can change that using the Expert Configuration mode of the OBiTALK portal). For example, here is an adaptation of something I have between two commas in my outbound call routes:


      This means that all of the following calls should be sent to sp3:

      [2-9]11 (all n11 service calls including 911 – note this implies that I replaced an existing rule covering 911)
      [2-9]xx (calls to 3 digit extensions starting with 2-9)
      11xx (this is what you’d need to pass 11xx substitutes for *xx codes to the PBX)
      18(00|88|77|66|55|44|33|22)xxxxxxx (11 digit dialed USA/Canada toll free calls)
      8(00|88|77|66|55|44|33|22)xxxxxxx (10 digit dialed USA/Canada toll free calls – may not work if you have 7 digit dialing enabled)
      011xx. (international calls dialed using 011)
      *[2-9]x (*xx codes that do NOT conflict with OBi device *xx codes – should pass *97)

      Note that for all the above to work, you might also need to make additions to the phone port DigitMap(s) (each new rule between vertical bar | characters). For example, here are a couple that I specifically add:

      [2-9]11 (replaces 911 rule, allows immediate dialing of all n11 service calls)
      [2-9]xxS4 (allows dialing to 3 digit extensions starting with 2-9 with only a four second post-dial delay if you don’t press # at the end. The delay is to see if you are going to dial additional digits)

      I don’t need to add new DigitMap entries for everything in the OutboundCallRoute because some of what I’ve added there is already covered by existing DigitMap rules.

  6. NOTICE: All comments above this one were imported from the original Michigan Telephone Blog and may or may not be relevant to the edited article above.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

Recent Comments




GiottoPress by Enrique Chavez