Change the MONITOR_FILENAME for queues

Hi all, im really new on this wonderful forum, my problem is that im having problems changing the MONITOR_FILENAME for all my queues, im trying to modify this line (MONITOR_FILENAME=/var/spool/asterisk/monitor/q${EXTEN}-${STRFTIME(${EPOCH},%Y%m%d-%H%M%S)}-${UNIQUEID}) where i need to put the phone number of the costumer that arrives on the queue. i try everything i know, im really stuck here.

exten => 778,1,Macro(user-callerid,)
exten => 778,n,Answer
exten => 778,n,Set(__BLKVM_OVERRIDE=BLKVM/${EXTEN}/${CHANNEL})
exten => 778,n,Set(__BLKVM_BASE=${EXTEN})
exten => 778,n,Set(DB(${BLKVM_OVERRIDE})=TRUE)
exten => 778,n,Set(_DIAL_OPTIONS=${DIAL_OPTIONS}M(auto-blkvm))
exten => 778,n,Set(__NODEST=${EXTEN})
exten => 778,n,Set(MONITOR_FILENAME=/var/spool/asterisk/monitor/q${EXTEN}-${STRFTIME(${EPOCH},%Y%m%d-%H%M%S)}-${UNIQUEID})
exten => 778,n,Set(__MOHCLASS=default)
exten => 778,n,Queue(778,t,)
exten => 778,n,dbDel(${BLKVM_OVERRIDE})
exten => 778,n,Set(__NODEST=)
exten => 778,n,Goto(from-did-direct,9999,1)
exten => 778*,1,Macro(agent-add,778,)
exten => 778**,1,Macro(agent-del,778,778)

The wav files are created like q778-20080820-232016-1219296453.1189902.wav and im not interested on the UNIQUEID. how do i replace the UNIQUEID for the phone number of the costumer?


an indirect answer (not what you are asking for) is to reference the uniqueid in the CDR database which gets you all the available information about the call, including that. (That is why the unique id is used).

the CDR database is not giving me all the information i want, i try that too and if i do a search for the phone number of the costumer it found nothing. must be a way to put the number on the wav file for inbounds calls because i did it for outbound calls.

When searching for phone numbers you many times need to select contains instead of exact (for either source or destination). A leading or trailing space can get included in the number if it is not trimmed properly will cause a search issue. use the source for incoming calls from a number and Destination for calls to a number.

If you know you have called a customer or gotten a call from a customer at a given time and the caller ID info is not there in the records then they might have call caller ID blocked or something else is wrong. As we have it working along with many thousands of others.

Also for many companies who own blocks of numbers they will have the caller ID set to the main number of the company and not a direct line number for a particular person. (Dell for example is one).

${exten} in this case IS 778 so thats pretty much correct. Try replacing extend with CALLED(num)


While what you have proposed will work you have now also caused several BIG issues going forward. Since you changed the permissions on the files so that they can’t be over written by the system when it needs to you will now not be able to update the system with changes (Add new extensions, add a IVR, etc).

This is clearly not the proper way to do things. That is why at the top of the files they say:
; do not edit this file, this is an auto-generated file by freepbx
; all modifications must be done from the web gui
as they get replaced all the time for very valid reasons. Doing this basically means that anybody who follows this set of directions will next be complaining about changes being made that do not work when they apply and reload them.

Instead the proper thing to do would be to place your changes in the include files that do not get over written (files that end in *_custom.conf). By default when a system is new these files will not exist or be blank depending on which version of asterisk you have loaded (newer versions require files to exist if called while earlier versions do not have that restriction).

To override a existing macro in the extensions.conf file create/edit the file extensions_override_freepbx.conf and place it there. Asterisk will use the first occurrence of a macro or context and ignore any repeat occurrences so the extensions_override_freepbx.conf allows for you to do this properly when you need to modify a existing routine inside extensions.conf.

I had research this and … sucessfull !

  1. By default the extensions_additional.conf file do not edit by hand, because freePBX will auto reload default format (you can show this notice at first line of this file)

  2. All of first you have to change the permission of file is 464 (not write)

  3. After that , we have files need interested :
    _ extensions.conf (/etc/asterisk/)
    _ extensions_additional.conf (/etc/asterisk/)
    _ recordingcheck (/var/www/html/admin/modules/core/agi-bin)

  4. Let begin configure : add new lines to these context.
    :::: extensions.conf :::::
    include => macro-dialout-trunk

exten => s,1,GotoIf($[${LEN(${BLINDTRANSFER})} > 0]?2:4)
exten => s,2,ResetCDR(w)
exten => s,3,StopMonitor()
exten => s,4,AGI(recordingcheck,${STRFTIME(${EPOCH},%Y%m%d-%H%M%S)},${UNIQUEID})
exten => s,5,Noop(${CALLERID(number)})
exten => s,7,Noop(No recording needed)

; Add new lines
;############ for incoming call record #############

exten => s,998,Set(CALLFILENAME=${CALLFILENAME}-${CALLERID(number)}) // chú ý ph?n priority
exten => s,n,Noop(${CALLERID(number)})
exten => s,n,Noop(${CALLERID(name)})
exten => s,n,MixMonitor(${CALLFILENAME}.wav)

;############ for outgoing call record #############

exten => s,800,Set(CALLFILENAME=${CALLFILENAME}) // chú ý ph?n priority

exten => s,n,Noop(OUTNUM=${OUTNUM})
exten => s,n,Noop(DIAL_NUMBER=${DIAL_NUMBER})
; End of new lines

:::: extensions_additional.conf ::::
include => macro-dialout-trunk-custom
exten => s,1,Set(DIAL_TRUNK=${ARG1})
exten => s,n,ExecIf($[$["${ARG3}" != “”] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != “NOPASSWD”]],Authenticate,${ARG3})
exten => s,n,GotoIf($[“x${OUTDISABLE_${DIAL_TRUNK}}” = “xon”]?disabletrunk,1)
exten => s,n,Set(DIAL_NUMBER=${ARG2})
exten => s,n,Set(GROUP()=OUT_${DIAL_TRUNK})
exten => s,n,GotoIf($["${OUTMAXCHANS_${DIAL_TRUNK}}foo" = “foo”]?nomax)
exten => s,n,GotoIf($[ ${GROUP_COUNT(OUT_${DIAL_TRUNK})} > ${OUTMAXCHANS_${DIAL_TRUNK}} ]?chanfull)
exten => s,n(nomax),GotoIf($["${INTRACOMPANYROUTE}" = “YES”]?skipoutcid)
exten => s,n,Macro(outbound-callerid,${DIAL_TRUNK})
exten => s,n(skipoutcid),AGI(fixlocalprefix)
exten => s,n,Set(custom=${CUT(OUT_${DIAL_TRUNK},:,1)})

; Add new lines
exten => s,n,Noop(OUTNUM=${OUTNUM})
exten => s,n,Noop(DIAL_NUMBER=${DIAL_NUMBER})
exten => s,n,MixMonitor(${CALLFILENAME}.wav)
; End of new lines

:::: recordingcheck ::::::
case “Group”:


case “OUT”:


case “IN”:


  1. Everything OK … you have go to Asterisk CLI > reload
  2. At this solution have a disavandtage is :

When you want to configure system from Web GUI … at first you have to change the permission of extensions_additional.conf to 664.

After configuration finished you have only add the new lines in extensions_additional.conf again as below. Then change the permission of extensions_additional.conf to 464 again.

  1. The format of record file name as follow :

=> Mean Extension 1001 make call to 0988428477
=> Mean the call from No. 7717786 to Extension 1002

I hope this information helping for all ! This solution i has been test and … sucessfull !

====== Contact info ==========
Name : Lam The Nhan (Steven)
E-mail : [email protected] |
Mobile phone No. : +84 918633646
Home phone No. : +84 9402331

Hi fskrotzki,

Yeah, this is also a new idea. I hope we can find the perfect solution for this by anyway !

Thank for reply !


====== Contact info ==========
Name : Lam The Nhan (Steven)
E-mail : [email protected] |
Mobile phone No. : +84 918633646
Home phone No. : +84 9402331

Hi all,

i did everything and im still in the same hole :frowning:

But thanks for your help!!

I know this is an old post, but for anyone stumbling onto this, I posted the solution here:

Hi there,

I searched the internet for 2 days and i couldn’t find an explained solution. i’m using the latest freePBX distro with asterisk 1.8.*

I built an external application that connects to the CDR table and extracts all the info. My problem was that some file names were having 1 second delay compared to the time in the CDR. So … the solution for me was to change the file name like “OUT--<>.wav” so that i can identify the recording. i kept the date parameter for the ease of moving all files from certain date to a specific folder with my bash script.

so i had to edit the /etc/asterisk/extensions_additional.conf at the [macro-record-enable] section the options with CALLFILENAME=OUT…

now it works fine for my needs.