text
stringlengths
0
152
exten => 102,1,Dial(${UserB_DeskPhone},10)
same => n,Voicemail(${EXTEN}@default,u))
same => n,Hangup()
We can do more if we wish, and change it so that if the user is busy (on another call),
the caller will hear a busy message. To do this, we will make use of the ${DIALSTATUS}
variable, which contains one of several status values (type core show application
Dial at the Asterisk console for a listing of all the possible values):
140
|
Chapter 8: Voicemail
exten => 102,1,Dial(${UserA_SoftPhone})
same => n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
same => n(unavail),VoiceMail(101@default,u)
same => n,Hangup()
same => n(busy),VoiceMail(101@default,b)
same => n,Hangup()
Now callers will get voicemail (with the appropriate greeting) if the user is either busy
or unavailable. An alternative syntax is to use the IF() function to define which of the
unavailable or busy messages to use:3
exten => 103,1,Dial(${UserB_SoftPhone})
same => n,Voicemail(${EXTEN}@default,${IF($["${DIALSTATUS}" = "BUSY"]?b:u)})
same => n,Hangup()
A slight problem remains, however, in that our users have no way of retrieving their
messages, nor setting their greetings or any other voicemail options. We will remedy
that in the next section.
The VoiceMailMain() Dialplan Application
Users can retrieve their voicemail messages, change their voicemail options, and
record their voicemail greetings using the VoiceMailMain() application. VoiceMail
Main() accepts two arguments: the mailbox number (and context if necessary), plus a
few options. Both arguments are optional.
The structure of the VoiceMailMain() application looks like this:
VoiceMailMain([mailbox][@context][,options])
If you do not pass any arguments to VoiceMailMain(), it will play a prompt asking
the caller to provide their mailbox number. The options that can be supplied are lis‐
ted in Table 8-6.
Table 8-6. VoiceMailMain() optional arguments
Argument
p
g(#)
s
Purpose
Allows you to treat the mailbox parameter as a prefix to the mailbox number.
Increases the gain by # decibels when playing back messages.
Skips the password check.
3 We’ll dive into functions like IF() in Chapter 10.
Voicemail Dialplan Integration
|
141
Argument
a(folder) Starts the session in one of the following voicemail folders (defaults to 0):
Purpose
• 0 - INBOX
• 1 - Old
• 2 - Work
• 3 - Family
• 4 - Friends
• 5 - Cust1
• 6 - Cust2
• 7 - Cust3
• 8 - Cust4
• 9 - Cust5
To allow users to dial an extension to check their voicemail, you could add an exten‐
sion to the dialplan like this: