Asterisk Bounty record call queues with detailed filename

All completed via the use of a an AGI script on hangup that uses a combination of the Asterisk DB and queue_log to get the requried information to rename the file.

HINT - The channel which answered the call is listed in queue_log - e.g.

We're interested in the second (${UNIQUEID} and fourth fields, so.....
tail -1000 queue_log | grep -e '.*asterisk-1203-1154624243.111.*CONNECT.*' | sort -r | tail -1 | sed -e 's/.*SIP.\([0-9]\{3\}\).*/\1/'

will give us the SIP handset which answered the queue for the first queue this call was answered from (tweak the number of lines returned from the tail if need be and get rid of the sort if you want the last). OK, OK, there must be more elegant ways of doing it, but I only just learned this much about regular expressions this evening!
Beware that in a busy call centre with long call durations, the CONNECT line may be waaaaaaaaay back up the log file, so either the 'tail -1000' could be changed to include more lines. It's not a good idea to search the whole file though! Alternatively, you could search for COMPLETECALLER and COMPLETEAGENT (and possibly TRANSFER) which should be very close to the bottom of the file, but beware that this could be a different extension than the one which answered the call.

Once you've got the device which answered the call, you should be able to tie this back to the agent. Unless somebody can tell me a nicer way to work out the device which answered the call.

It would be much better, though, if app_queue returned the device which answered the call as a variable. Ho hum.


Picture this: an inbound call centre using a few different queues. All calls need to be recorded for later verification. All queue members are dynamic members logged in via the AddQueueMember command. The filenames of the call recordings need to show who picked up the call. It is easy enough to SetVar(MONITOR_FILENAME...) to have the caller ID, the time, etc - but because this variable is set PRIOR to the call being picked up, I can't see a way to put the name of the channel that answers the call into that variable.

When using Agents it is possible through agents.conf to have the agent number in the filename, but this needs to be done with dynamic queue members, NOT agents.


Basically, I would like the filename to be something like:

where ${AGENT} ends up being something like 6000 if the person at SIP/6000 ends up being the one taking the call. Ideally, I would actually like to do something like:

and then set the filename to:

though I'm guessing this can only be done AFTER the call has been taken by an agent, else how do we know which agent will take the call!

Bounty & Conditions

Value of this bounty is USD50. If it is already possible to do what I want to do, but I'm just too stupid to figure it out, then the bounty is USD25 for explaining it to me.


Please contact Kevin at asterisk _AT_ for more information or to claim bounty.


Sarkpbx saves its queue recordings this way. Documentation can be found here...

Created by: ozvoip, Last modification: Mon 04 of Jun, 2012 (07:48 UTC) by admin
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+