13.100. VoiceMail (dialplan application)     ( Back to Tutorials Page )

1. VoiceMail - this application allows you to leave a voicemail message.

NOTE: This application is valid for Asterisk version 1.0.9 and above.

 


Syntax:

VoiceMail([options]vm-extension1[@vm-context1][&vm-extension2][@vm-context2][...])

 


List with the possible options

s - without this option a message will be played. The message by default is: "Please leave your message after the tone. When done, hang up, or press the pound key." If you set this option, the message won’t be played.
u - If you set this option, an unavailable message will be played. The message by default is: "The person at extension <dialled extension> is unavailable". Also you will hear and the instructions: "Please leave your message after the tone. When done, hang up, or press the pound key."
b - If you set this option, a busy message will be played. The message by default is: "The person at extension <dialled extension> is on the phone." Also you will hear and the instructions: "Please leave your message after the tone. When done, hang up, or press the pound key."
su - You will hear the unavailable message: "The person at extension <dialled extension> is unavailable". The instruction message will be skipped.
sb - You will hear the busy message: "The person at extension <dialled extension> is on the phone". The instruction message will be skipped.

 


Purpose and usage

As you can conclude from the name of the application, it is used for a voice messages.

You can use the Voicemail application for making and leaving voice messages. The messages are stored in a special folder with the name of the context created in voicemail.conf and the name(or number) of the called user. In this folder, a subdirectory with the name INBOX will be created. The location of the special folder by default is in the /var/spool/asterisk/voicemail directory.
Example:

/var/spool/asterisk/voicemail/voicemail-context/username/INBOX


Let’s say that somebody tries to call you, but you are not available at the moment or perhaps you have already a call and you are busy. This is the ideal situation to use the voiceMail application.

Below we will show you in details how to configure your system to do this.

 


Prerequisites

To use this application you need a working Asterisk PBX with registered users in iax.conf, sip.conf or mgcp.conf(It depends on which protocol you would like to use) and made extensions. Also you have to create a mailbox in the voicemail.conf file

To see how the application works we recommend to use our IAX softphone Idefisk. You can download it from here. Please also read our tutorial to learn how to configure it to work with Asterisk PBX.

 


Asterisk PBX configurations

NOTE: This is only an example of what for you can use this application. Of course you can use it and for other things.


iax.conf Configurations

We need three registered users in iax.conf file. This is because we are going to use the IAX2 protocol. If you want to use other protocol such as SIP or MGCP, you have to do the configurations below respectively in sip.conf or mgcp.conf.

iaxthreeusers1.jpg

So, we have registered the users user1, anatoliy and ivan.

Type=friend means that this user can make and receive calls. Host=dynamic means that the IP is not static but dynamic through a DHCP server. Allow=all means that the line which this user will use, could support all audio codecs. Context=test - this shows that this user is working with the extensions in this context of the configuration file extensions.conf.


voicemail.conf Configurations

We have to create the mailboxes in the voicemail.conf file. Below we will show you a screenshot from our voicemail.conf file.

voicemailc.jpg

We will create a context named [testmail]. In this context we will define three mailboxes. The way of creating a mailbox is the following:

First you write the mailbox number. It is not necessary to be a number it could be also a name. In our case it would be a name. It is followed by the => character. After this character, the first argument is the desired password for the mailbox. The password is followed by the name and family name of the user and then his/her e-mail address. You can add and some other options, but we do not need them now. You can learn more about this options in our voicemail.conf tutorial.

In our example we will create three mailboxes. One for the user anatoliy, one for the user user1 and one for the user ivan. This mailboxes will be in the context [testmail]

We are ready with our voicemail boxes. Now, lets take a look at the extensions.conf file.


extensions.conf Configurations

extvoicemail.jpg

On the picture above you can see our extensions.conf file.

In our example when somebody dials 5454, the call will be answered by the Answer application. The next executed extension will be the one which contains the Dial application. It will try to connect the user anatoliy through the IAX2 channel.

We will use the GoToIf application to determine the dial status of the call. For the purpose we need also the variable ${DIALSTATUS}. The first extension after the one with Dial application, will check whether the called person is available.

If the person is unavailable, then the execution will continue with the extension with priority 7. This extension contains the VoiceMail application. In its brackets we have set the following: uanatoliy@testmail. The first letter - u means that a message for an unavailable condition has to be played. The message by default is: The person at extension is unavailable". The word anatoliy is for the mailbox which we have set in the voicemail.conf. The last part is @testmail. This shows the context in voicemail.conf, in which the mailbox anatoliy is configured.

So, the caller will hear a message and he/she will be allowed to record a message and to store it in the mailbox of anatoliy. The message will be stored in the directory /var/spool/asterisk/voicemail/testmail/anatoliy/INBOX. In order to send the message in the mailbox, the caller has to hang up the line or to press the pound key(#), when he/she finishes with the recording of the message.

If the GoToIf check show that the user is available, then the next application with priority 4 will be executed. This one will check, whether the line is busy or not.

If the line is busy, then the execution will continue with the extension with priority 9. This extension contains again the VoiceMail application. In its brackets we have set the following: banatoliy@testmail. The first letter - b means that a message for busy condition has to be played. The message by default is: The person at extension is on the phone. The word anatoliy is for the mailbox which we have set in the voicemail.conf. The last part is @testmail. This shows the context in voicemail.conf, in which the mailbox anatoliy is configured.

The caller will hear the message, that the called person is busy and he/she will be allowed to record a message and to store it in the mailbox of anatoliy. The message will be stored in the directory /var/spool/asterisk/voicemail/testmail/anatoliy/INBOX. In order to send the message in the mailbox, the caller has to hang up the line or to press the pound key(#), when he/she finishes with the recording of the message.

Now, if the user is available and the line is free and the called person does not answer within 5 seconds, the next executed extension will be the one with priority 5. This one contains another copy of the VoiceMail application.

As arguments in its brackets we have set the following: anatoliy@testmail. There is no first letter which means that a message with instructions has to be played. The message by default is: Please leave your message after the tone. When done, hang up, or press the pound key. The word anatoliy is for the mailbox which we have set in the voicemail.conf. The last part is @testmail. This shows the context in voicemail.conf, in which the mailbox anatoliy is configured.

Again the user will be allowed to record a message after the signal. The message will be stored in the directory /var/spool/asterisk/voicemail/testmail/anatoliy/INBOX. In order to send the message in the mailbox, the caller has to hang up the line or to press the pound key(#), when he/she finishes with the recording of the message.

NOTE: Please, pay attention that between the option flags and the voicemail number there is no separator. That is why the voicemails cannot start with "s", "u", "b" or any combination of these three letters.

Maybe you have noticed that between the extensions with priority 5, 7 and 9, we have extensions with the GoTo application. It cause the jumping to the last extension with priority 10 which has the Hangup application. Thanks to it the line will be hung up. This is necessary, because otherwise the three VoiceMail application will be executed subsequently. In this way the effect from the GoToIf applications will be lost.

 


2. Screenshots of what you can see on the CLI of the Asterisk PBX

1) Screenshot for available user, which do not answer
clivoice.jpg

2) Screenshots for unavailable user
clivoice1.jpg


 


3. Additional information

For more information about extensions.conf you can check here.
For more information about iax.conf you can check here.

This application is tested with our IAX softphone Idefisk. You can download it from here. For more information about this softphone please read our tutorial.

If you would like to test this application with the SIP channel you can read our tutorials about the SIP Softphones to learn how to configure them to work with Asterisk PBX

 


4. Similar dial plan applications

 

User Comments

Lacho <support at asteriskguru dot com>
12 October 2005 12:51:17
Yes, 7NSA. Unfortunately the voicemails cannot start with "s", "u", "b" or any combination of these three letters.
7NSA <asteriskguru dot com at knoppix dot ca>
11 October 2005 07:11:47
Since there is no seperator in between flags and boxnumber@context, names should not start with 's', 'u', or 'b' ???

Any comments on this?

Add Comment

Name:
Email:
Comment:
 

contact us at: support@asteriskguru.com - asterisKGuru.com © all rights reserved   |   *asterisk is registered trademark of © Digium™