VoIP Cookbook: Voicemail in Asterisk

From OnnoWiki
Jump to navigation Jump to search

Voicemail is used in Asterisk to leave a message, when there is no one to receive the incoming call. Voicemail configuration for Asterisk is available in voicemail.conf file available in /etc/asterisk/. We can create a mailbox within the default mailbox context, either use the one already available or create another in different context. It is important to understand that the context in voicemail mailbox is not related to the context in extensions.conf

The command to create a voicemail mailbox is approximately as follows

mailbox_number => password, name, e-mail 

mailbox_number is the number used in extension.conf for VoiceMail() command and for registering a user to sip.conf or iax.conf. Password is the password used to register a user to sip.conf or iax.conf. Name is the name associated with a mailbox, and email is the email used to inform if there is an incoming voicemail.

Sample of voicemail.conf content is as the following:

[mb_tutorial] 
777 => 1212, ivan, ivan@voiprakyat.or.id 

Here the mailbox context is created using the name mb_tutorial context, mailbox number 777 with password 1212, which is owned by ivan whose e-mail is ivan@voiprakyat.or.id. For a user who calls Ivan at extension 1234 to be able to leave a message in Ivan's mailbox, the following command can be used:

Voicemail (mailbox_number@context) 

In extensions.conf file, the content is as the following:

exten => 1234.1, Dial (SIP/ivan, 30) 
exten => 1234.2, VoiceMail (777@mb_tutorial) 
exten => 1234.3, PlayBack(vm-goodbye) 
exten => 1234.4, HangUp () 

In the example above, Asterisk will attempt to call SIP user ivan for extension 1234 and wait for 30 seconds. If nobody answers the phone, Asterisk will carry out the next priority, that is, Asterisk will open mailbox 777 in mb_tutorial context. Once the caller has left a message, Asterisk will carry out playback (rewind the message) and hang up the call. Playback (vm-goodbye) will execute vm-goodbye file that should be available in /var/lib/asterisk/sounds/.

The Voicemail message is recorded in

/var/spool/asterisk/voicemail/<context>/<mailbox>/INBOX/ 

Therefore the full path to Ivan is

/var/spool/asterisk/voicemail/mb_tutorial/777/INBOX/. 

To listen to the message stored in the mailbox, we can place a call by using VoiceMailMain command in Asterisk. The command is as follows:

VoiceMailMain(mailbox@context) 

In the default configuration of Asterisk, if the sample configuration remains as what is, VoiceMailMain can be contacted using the number 8500.

The configuration sample of extensions.conf for accessing VoiceMailMain is:

exten => 9999.1, VoiceMailMain (777@mb_tutorial) 

By dialing 9999, we will be able to go into mailbox 777, of course after we entered the correct password for this mailbox, which is 1212.

Various options are available when accessing mailboxes using VoiceMailMain:

0 Mailbox options 
	1 Record unavailable message 
	2 Record busy message 
	3 Record our name 
	4 Change our password 
	* Back to main menu 
1 Listen to old messages 
2 Change folders 
3 Advanced options 
	1 Send reply 
	2 Call back 
	3 Envelope 
	4 Outgoing call 
	5 Leave message 
	* Back to main menu 
4 Play previous message 
5 Repeat message 
6 Play next message 
7 Delete this message 
8 Forward message to another mailbox 
9 Save message in a folder 
* Help; during message playback: Rewind 
# Exit; during message playback: FastForward 

When we listen to a voicemail message recording, we can use the following buttons to navigate, ie,

* to rewind (going back) 
# to FastForward (forward) 

Note: the '#' and '*' buttons work only when the message is in the process of playback.


See Also