The VoiceMail application
To record a message in a mailbox, the VoiceMail application is used. This application takes two parameters:
- the mailbox (or mailboxes) in which the message will be recorded.
- options (e.g. which greeting to play or whether to mark the message as urgent).
The mailbox in which the message will be recorded is specified in the mailbox@context format. For example, to send a call to voicemail when 444 is called, we would add the following code to our dialplan (note – add this code to the extensions.conf file, and not to the voicemail.conf file!):
exten => 444,1,NoOp() same => n,VoiceMail(444@default,u)
The code above will play the unavailable greeting message and than give the caller a chance to leave a message for the mailbox 444 in the default context.
Let’s make our voicemail more useful. We will change the code so that, if the receiver doesn’t answer the phone, the caller will be sent to voicemail:
exten => 444,1,NoOp() same => n,Dial(SIP/bob, 12) same => n,VoiceMail(444@default,u)
Now, if bob doesn’t answer the phone within 12 seconds, the caller will be able to leave him a message.
The default storage location for voice messages is the /var/spool/asterisk/voicemail/context/mailbox/INBOX directory. In our case, the messages will be stored in the /var/spool/asterisk/voicemail/default/444/INBOX directory:
ls -l /var/spool/asterisk/voicemail/default/444/INBOX total 64 -rw-rw-rw- 1 asteriskuser asteriskuser 280 Jan 22 01:03 msg0000.txt -rw-r--r-- 1 asteriskuser asteriskuser 51564 Jan 22 01:03 msg0000.wav -rw-r--r-- 1 asteriskuser asteriskuser 5260 Jan 22 01:03 msg0000.WAV