Я делаю так, в очереде, при поднятии трубки вызываем макрос.
context macro-nav-taxi {
s => {
Set(CALLERIDNUM=${TELNO});
AGEN=${CHANNEL:4:4};
Set(CALLFILENAME=${STRFTIME(${EPOCH},,20%y-%m-%d_%H-%M-%S)}__${CALLERIDNUM}__${AGEN});
System(/var/www/scripts/checkdir.sh);
Set(monopt=nice -n 19 /usr/local/bin/lame -b 16 --silent "/var/spool/asterisk/monitor/${CALLFILENAME}.wav" "/usr/local/recorder/records/${STRFTIME(${EPOCH},,20%y-%m-%d)}/${CALLFILENAME}.mp3" && rm -f "/var/spool/asterisk/monitor/${CALLFILENAME}.wav");
MixMonitor(${CALLFILENAME}.wav,b,${monopt});
Set(CDR(accountcode)=taxi);
Set(CDR(userfield)=${CALLFILENAME});
NoOp(${AGEN});
AGENTIP=${DB(${AGEN}/ip)};
NoOp(AGENT IP=${AGENTIP});
PORT=6001;
NoOp(${MACRO_EXTEN});
Set(CDR(operator)=${AGEN});
System(echo -e "Message: ActivateCard. Operator: ${AGEN}. CallerID: ${TELNO} \n\n" | nc ${AGENTIP} ${PORT} );
};
};