Asterisk VoiceMail & MWI


Jump to: navigation, search

After having a PBX with calls between extensions, calls to/from a sip provider and moving all configurations to asterisk realtime (mysql), we will now add voicemail functionality to exten 1000 and 2000:

first we should add the new mailboxes to the voicemail.conf file. add the following at the end of the voicemail.conf file with the following format: box_num => voicemail_pass,user_name,user_email,user_pager_email,user_options

 [from-sip]                            ; your context 
 1000 => 1234,UserA,  
 2000 => 1234,UserB,

now we should change the dial-plan so:

  • 1. when dialing *0 you will get to your voicemail in order to retrieve your messages (VoiceMailMain line ID 254 below)
  • 2. when inbound call fails (no answer, not available...) call will be sent to leave a message (VoiceMail line ID 252 below)

The extensions table will look as follow: File:voicemail_extentions.GIF dial from 2000 to 1000 and leave a message. Dial *0 from 1000 to retrieve the message (password 1234)

MWI - Message Waiting Indicator

configure each mailbox to the relevant sip user by changing the "mailbox" field in the sip_buddies table. when the user will have new message, asterisk will dens SIP NOTIFY message to the user to inform of the new message. below is the mysql, sip_buddies table. note the change at the mailbox field: File:sip_buddies_mwi.GIF The message indicator notification will display a small envelope in x-lite as follow: File:X-lite_MWI.GIF

all messages will be saved at:


The message information (duration, Date & time ...) will be saved as text file in addition to the voice message in the diffrent codecs:

 msg0000.gsm  msg0000.wav  msg0000.WAV  msg0000.txt

important voicemail configurations :

 format=wav49|gsm|wav         ; Formats for writing Voicemail
 attach=yes                   ; Should the email contain the voicemail as an attachment
 maxsecs=180                  ; Maximum length of a voicemail message in seconds
 externnotify=/usr/bin/myapp  ; run application everytime a message left.

change email subject and body:

 emailsubject=[PBX]: New message ${VM_MSGNUM} in mailbox ${VM_MAILBOX}
 emailbody=Dear ${VM_NAME}:\n\n\tjust wanted to let you know you were just left a ${VM_DUR} long message (number ${VM_MSGNUM})\nin mailbox ${VM_MAILBOX} from ${VM_CALLERID}, on ${VM_DATE}, so you might\nwant to check it when you get a chance.  Thanks!

all configurations description can be found at the voicemail.conf file.

cli command ("asterisk -r"):

 voicemail show users for from-sip

Voicemail command options:

 core show application VoiceMail
 -= Info about application 'VoiceMail' =- 
 VoiceMail(mailbox[@context][&mailbox[@context]][...][,options]): This
 application allows the calling party to leave a message for the specified
 list of mailboxes. When multiple mailboxes are specified, the greeting will
 be taken from the first mailbox specified. Dialplan execution will stop if the
 specified mailbox does not exist.
 The Voicemail application will exit if any of the following DTMF digits are
   0 - Jump to the 'o' extension in the current dialplan context.
   * - Jump to the 'a' extension in the current dialplan context.
 This application will set the following channel variable upon completion:
 VMSTATUS - This indicates the status of the execution of the VoiceMail
              application. The possible values are:
   b    - Play the 'busy' greeting to the calling party.
   d([c]) - Accept digits for a new extension in context c, if played during
            the greeting.  Context defaults to the current context.
   g(#) - Use the specified amount of gain when recording the voicemail
          message. The units are whole-number decibels (dB).
          Only works on supported technologies, which is DAHDI only.
   s    - Skip the playback of instructions for leaving a message to the
          calling party.
   u    - Play the 'unavailable' greeting.
   U    - Mark message as Urgent.
   P    - Mark message as PRIORITY.
Personal tools