Is it possible to make a call to a spier (supervisor) when the spying extension picks up the phone. And then send him to the dialplan where ChanSpy command is?
The aim is: spier (Supervisor) does not want to watch and wait when specified extension calls somewhere or pickups up inbound call. He needs a call to his phone when the specified extension starts a conversation (inboud, outbound). Supervisor pickups the phone and the asterisk sends him to the dialplan where ChanSpy work with this specified extension.
Check out the “U” option on the Dial application. That allows you to execute an action before the call is connected. From there you should be able to use some combination of Originate, and local channels along with ChanSpy.
Here’s a crude, not well tested example when dialing extension 101:
[globals]
TECH=PJSIP
[my_gosub_routine]
exten => s,1,NoOp()
same => n,Originate(Local/spy@default,exten,default,spier,1)
same => n,Return()
[default]
exten => 101,1,NoOp()
same => n,Dial(${TECH}/${EXTEN},30,U(my_gosub_routine))
same => n,Hangup()
exten => spier,1,NoOp()
same => n,Dial(${TECH}/${EXTEN},30)
same => n,Hangup()
exten => spy,1,NoOp()
same => n,ChanSpy(PJSIP,qS)
same => n,Hangup()
@hsunryou, Thank you for reply. Yes I know how to use the AMI protocol, but in this case indeed, it would be better to achieve it using a dialplan anyway - thank you