Draft of ListenIn/VoiceMail Screening
This seems to work on my system (only took me 15 months to figure out!)
SUMMARY:
Caller dials in and hears ringing
CallFile generated and calls to Listener's number
If Listener does not answer after (Number of Rings), caller is sent to VoiceMail as usual
If Listener answers, there are three options:
-Listener enters "1" = Connect Listener and Caller to Meetme to start talking
-Listener enters "2" = Caller is sent to voicemail, Listener "screens" message (muted)
-Listener enters "9" = Caller is sent to voicemail, Listener hangs up
HOW IT WORKS:
1. Caller sent to Extension 510.
2. Caller hears simulated ringing.
3. Global Variable (VMS) will monitor whether CHANSPY is enabled, and if so, what to do. Default="0" CHANSPY not enabled.
4. Call file is created and calls out to Listener number.
5. If Listener answers, Listener is sent to Extension 556.
6. CHANSPY is set on channel (muted) with option "X" - Allowing exit on single digit. Listener starts to listen to Channel(Not sure if I should have used EXTENSPY)
7. If Single-digits "1", "2", or "3" are pressed, Listener sent to respective extension
8. Extension 1 : You want to talk to the caller. Points Listener to dynamic meetme room 565 as administrator; VMS set to "100" which will send Caller to meetme room 565 to begin talking.
9. Extension 2 : You want to screen the voicemail. VMS set to "20" which will send caller to Voicemail. CHANSPY listens to Caller (muted). Listener can enter "1" at anytime to exit CHANSPY to extension 1 and talk to caller (but voicemail is still recording--not sure how to exit voicemail)
10. Extension 9 : You don't wan't to talk to the caller. VMS set to "90" which will send caller to Voicemail. Listener is disconnected.
As written, I believe this will only work on 1.6 to make use of the "X" option in CHANSPY. This works on my system because I only use one DID at a time(not sure if I should have used EXTENSPY instead). I do not know the legality of "listening in" on a caller leaving you a message, but it seems similar to an anserwing machine or GrandCentral/Google Voice's "Listen In."
Any suggestions for improvement welcome!
;[from-internal-custom]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;510 -- ListenIn/VoiceMailScreening(VMS)
exten => 510,1,Answer
exten => 510,n,Set(GLOBAL(VMS)=0)
;Global Variable VMS determines CHANSPY status:
;VMS=0 CHANSPY not active, Caller continues to hear ringing then sent to voicemail (defaut)
;VMS=20 CHANSPY is active, send caller to VoiceMail and Listener continues listening to channel(muted)
;VMS=90 Exit CHANSPY, send Caller immediately to VoiceMail, Listener hangs up
;VMS=100 Exit CHANSPY, send Caller and Listener to Meetme to start talking
exten => 510,n,Set(OUTNUMB=12223334444) ; number to call out to enable Listener
exten => 510,n,Set(CIDN=${CALLERID(num)}) ;CID of original caller
;Create outgoing call file to Listener
exten => 510,n,System(echo channel: SIP/provider/${OUTNUMB} > /tmp/outfile.call); change to SIP provider
exten => 510,n,System(echo callerid: ${CIDN} >> /tmp/outfile.call) ; CallerID of Original Caller
exten => 510,n,System(echo MaxRetries: 0 >> /tmp/outfile.call)
exten => 510,n,System(echo context: from-internal-custom >> /tmp/outfile.call)
exten => 510,n,System(echo extension: 556 >> /tmp/outfile.call) ; extension 556 starts CHANSPY
exten => 510,n,System(echo priority: 1 >> /tmp/outfile.call)
exten => 510,n,System(echo WaitTime: 25) ; so it doesn't go to voicemail on Listener's phone
exten => 510,n,System(chmod 775 /outfile/fill.call})
exten => 510,n,System(mv /tmp/outfile.call /var/spool/asterisk/outgoing) ;outcall starts immediately
;play ringing to caller
;loop rings to allow evaluation of VMS
exten => 510,n,Set(i=1) ;counter
exten => 510,n,Set(RINGS=7); number of rings Caller hears before voicemail if Listener does not respond
exten => 510,n,While($[${i} < (${RINGS})]) ;Loop ringing
exten => 510,n,NoOp(i=${i})
exten => 510,n,NoOp(VMS=${VMS})
exten => 510,n,ringing ;Plays standard ringing to Caller
;Determine if Listener is Listening (set by CHANSPY eXit digit entered by Listener in ext 556)
exten => 510,n,GotoIf($[${VMS}=20]?vmail: ] ; Send to Voicemail - Listener is listening
exten => 510,n,GotoIf($[${VMS}=90]?vmail: ] ; Send to Voicemail - Listener hungup (no need to continue ringing)
exten => 510,n,GotoIf($[${VMS}=100]?561,1; ]; Send to Meetme to conference (ext 561) with Listener
;otherwise, VMS still = 0, Listener has not responded, continue ringing
exten => 510,n,Wait(6) ; six seconds of silence between rings
exten => 510,n,Set(i=$[${i} + 1]) ; add 1 to counter
exten => 510,n,EndWhile
;Counter completed number of RINGS
;Listener has not respnded
;Send Caller to Voicemail
exten => 510,n(vmail),Voicemail(1999@default); Caller enters VoiceMailBox XXXX
exten => 510,n,hangup
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;556-Start ListenIn
;Call File sent to this extension upon answering
;CHANSPY started to ListenIn to call on SIP (Listener is muted)
;X allows exit to single-digit extension:
;1:Transfer Caller and Listener to meetme to start conversation (VMS=100)
;2:Send caller to voicemail and continue listening
;9:Send caller to voicemail, Listener disconnected
exten => 556,1,NoOp()
exten => 556,n,ChanSpy(SIP,X,q)
exten => 556,n,hangup
;Single-digits entered by Listener to exit CHANSPY
;must be in same context as CHANSY??
;X=1: send Caller to Meetme and start talking -- VMS=100
exten => 1,1, NoOp()
exten => 1,n, SayDigits(1)
exten => 1,n,Set(GLOBAL(VMS)=100) ; VMS=100=meetme
exten => 1,n,Goto(560,1) ; Send to dynamic meetme (room 565)
exten => 1,n,Hangup
;X=2: Send Caller to voicemail and keep listening -- VMS=20
exten => 2,1,NoOp()
exten => 2,n, SayDigits(2)
exten => 2,n,Set(GLOBAL(VMS)=20) ; VMS=20=Send Caller to VoiceMail and keep listening (muted)
exten => 2,n,ChanSpy(SIP,X,q) ;Can still type another digit
exten => 2,n,Hangup
;X=9: Send Caller to voicemail and hangup -- VMS =90
exten => 9,1,NoOp()
exten => 9,n,SayDigits(9)
exten => 9,n,Set(GLOBAL(VMS)=90) ; VMS=90=Send Caller to VoicMmail, Hangup Listener
exten => 9,n,Hangup
;Start Meetme for Listener
;Listener entered "1" -- Listener Exits CHANSPY to start conversation in Meetme room 565 with Caller
exten => 560,1, MeetMe(565,AaxdX1) ; Listener is Admin
exten => 560,n, hangup
;Start Meetme for Caller -- Caller joins Listener to start conversation in Meetme room 565
exten => 561,1, MeetMe(565,Axd1q) ;caller does not hear meetme anouncement, caller is 'marked'
exten => 561,n, hangup
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;