Asterisk: execute shell command on server when call is accepted on SIP extension

asterisksip

I'm trying to configure asterisk to execute shell command for incoming calls – but only when the call is accepted. I've managed to setup extensions.conf so that command is executed when new call comes in.

exten => 999999999,1,NoOp("----------mygroup---------------")
exten => 999999999,2,System(echo "1:${EXTEN} -  ${DATETIME} - ${CALLERID} - ${CHANNEL}" >> /var/log/asterisk/calls)
exten => 999999999,3,Dial(SIP/7001,20)

Is it possible to change it so that command is executed when operator connected to a SIP extension picks up the call. I need to know ID of the active operator and caller's number to execute the command.

Best Answer

Take a look at the "M" option for the Dial command. Have the macro you trigger do whatever look-up you need to determine the the Operator info, and then run the System command from within the macro.

Further Reading: