System information
much time to respond. However, if we set the response long enough to make it
comfortable for the user to send a response, we cause unnecessary delay in calling a
device or sending to voicemail.
We can skirt around this issue by using a Local channel. This allows us to execute two
sections of dialplan simultaneously, sending a call to the device at the same time we’re
waiting for a response from JABBER_RECEIVE(). If we get a response from JAB
BER_RECEIVE() and we need to do something, we can Answer() the line and cause that
section of dialplan to continue. If the device answers the phone, our dialplan with
JABBER_RECEIVE() will just be hung up. Let’s take a look at a modified dialplan that
implements the Local channel:
exten => 106,1,Verbose(2,Example using the Local channel)
same => n,Dial(Local/jabber@${CONTEXT}/n&Local/dial@${CONTEXT}/n)
exten => jabber,1,Verbose(2,Send an XMPP message and expect a response)
; *** This line should not have any line breaks
same => n,JabberSend(asterisk,leif.madsen@gmail.com,Incoming call from
${CALLERID(all)}. Press 2 to send to voicemail.)
same => n,Set(JabberResponse=${JABBER_RECEIVE(asterisk,leif@shifteight.org,6)})
same => n,GotoIf($["${JabberResponse}" = "2"]?voicemail,1)
same => n,Hangup()
exten => dial,1,Verbose(2,Calling our desk)
same => n,Dial(SIP/0000FFFF0002,15)
same => n,Goto(voicemail,1)
exten => voicemail,1,Verbose(2,VoiceMail)
same => n,Answer()
; *** This line should not have any line breaks
same => n,Set(VoiceMailStatus=${IF($[${ISNULL(${DIALSTATUS})}
| "${DIALSTATUS}" = "BUSY"]?b:u)})
same => n,Playback(silence/1)
same => n,VoiceMail(100@lmentinc,${VoiceMailStatus})
same => n,Hangup()
By adding a Dial() statement at the beginning and shifting our Jabber send and receive
functionality into a new extension called jabber, we ensure that we can simultaneously
call the dial extension and the jabber extension.
Notice that we removed the Answer() application from the first line of the example. The
reason for this is because we want to Answer() the line only after a device has answered
(which causes the jabber extension to be hung up); otherwise, we want the voicemail
extension to Answer() the line. If the voicemail extension has answered the line, that
means either the jabber extension has received a response and was told to Goto() the
voicemail extension, or the Dial() to our device timed out, causing the voicemail ex-
tension to be executed, thereby causing the line to be Answer()ed.
424 | Chapter 18: External Services
Downloa d f r o m W o w ! e B o o k < w w w.woweb o o k . c o m >