Call a spier when an extension pickups the phone


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.

Sorry for my English.

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:


exten => s,1,NoOp()
	same => n,Originate(Local/spy@default,exten,default,spier,1)
	same => n,Return()

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()

in my case, I made a deamon service using ami.

so, when special extension is make a call,
the ami catch that and make a call for spying!

but dial-plan is better!

1 Like

A few years a go I made something similar to spy calls when dialing to especial 911 number

Asterisk 911 spy


exten=>_911,1,Noop( ${CALLERID(num)} calling to 911)


;exten=>_100,1,System(/usr/sbin/asterisk -x "channel originate SIP/100 extension s@spy1)

exten => s,1,Answer
exten =>s,n,ChanSpy(${num},B)

@kharwell, Thank you for reply. I will try this later.

@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 :slightly_smiling_face: anyway - thank you

@ambiorixg12, Thank you for reply. I will try it later.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.