System Recording - hacked to use temp files to allow time for review

First off, LOVE the new feature code idea for updating system recordings. Before upgrading to 2.5.1 we had to implement a hack to do this.

However, with the new feature code method of updating a recording, it seems that once the recording is made…it is live! Which means there is a potential chance that a customer calling in could get blasted by a sneeze, or hear someone in the background swearing about something before a new recording can be made.

We use the old hacked method to allow “Network Status Messages” to be recorded by whomever is on duty in the event of a network issue. They dial, for example, 8989 to enter the IVR and when the current status message plays, they hit 99 and then a password, at which time they are prompted to record the new message.

The code looks something like this:

exten => s,1,NoOp(IVR recording test)
exten => s,2,Answer()
exten => s,3,Authenticate(463825)
exten => s,4,Background(say-temp-msg-prs-pound)
exten => s,5,Record(/var/lib/asterisk/sounds/custom/tempcustommessage.gsm)
exten => s,6,Background(to-listen-to-it&press-1)
exten => s,7,Background(to-accept-recording&press-2)
exten => s,8,Background(to-rerecord-announce&digits/3)
exten => s,9,Wait(6)
exten => 1,1,Playback(/var/lib/asterisk/sounds/custom/tempcustommessage)
exten => 1,2,Goto(s,6)
exten => 2,1,System(cp /var/lib/asterisk/sounds/custom/tempcustommessage.gsm /var/lib/asterisk/sounds/custom/Network-Status.gsm)
exten => 2,2,Playback(auth-thankyou)
exten => 2,3,Goto(IVR-6,s,1)
exten => 3,1,Goto(s,4)

We have to manually find “IVR-6” for the IVR that the message is to be attached to, and create a Custom Destination, and a few other things that I can’t remember off the top of my head.

But, after recording, the user is given the option to review the message, accept the message, or re-record the message. The nice part is, during this time, the current message is still being used. If there’s some background noise or other sort of blooper, no big deal. Unless you actually accept the recording, the new one will never be used.

I’ve modified the macro to use temporary files during the recording and review process. I put my version of macro-systemrecording in extensions_override_freepbx.conf. I tried putting [macro-systemrecording-custom] in extensions_custom.conf, but the system didn’t seem to recognize it. Overriding it entirely seems to work.

Here is my modified version. It’s a bit clunky, but it seems to work for creating system recording through the web interface, and updating system recordings using the new feature code method. Haven’t fully tested it in production yet, but my demo box hasn’t complained yet.

exten => s,1,NoOp( "Enter macro-systemrecording override ARG1: ${ARG1} ARG2: ${ARG2} ARG3: ${ARG3} MYRECFILE: ${MYRECFILE}" )
exten => s,n,ExecIf($["${ARG3}" != ""],Authenticate,${ARG3})
exten => s,n,Set(MYRECFILE=${IF($["${ARG2}" = ""]?/tmp/${AMPUSER}-ivrrecording:${ASTVARLIBDIR}/sounds/${ARG2})})
exten => s,n,Set(MYTMPRECFILE=${IF($["${ARG2}" = ""]?/tmp/${AMPUSER}-ivrrecording-tmp:${ASTVARLIBDIR}/sounds/${ARG2}-tmp)})
exten => s,n,NoOp( "Variables set for macro-systemrecording override ARG1: ${ARG1} ARG2: ${ARG2} ARG3: ${ARG3} MYRECFILE: ${MYRECFILE} MYTMPRECFILE: ${MYTMPRECFILE}" )
exten => s,n,NoOp( "copy ${MYRECFILE} to ${MYTMPRECFILE}" )
exten => s,n,System(cp ${MYRECFILE}.wav ${MYTMPRECFILE}.wav)
exten => s,n,NoOp( "SYSTEMSTATUS returned: ${SYSTEMSTATUS}" )
exten => s,n,Goto(${ARG1},1)
exten => dorecord,1,NoOp( "Start recording to ${MYTMPRECFILE}" )
exten => dorecord,n,Background(say-temp-msg-prs-pound)
exten => dorecord,n,Record(${MYTMPRECFILE}:wav)
exten => dorecord,n,Wait(1)
exten => dorecord,n,Goto(confmenu,1)
exten => docheck,1,NoOp( "Check recording of ${MYTMPRECFILE}" )
exten => docheck,n,Playback(beep)
exten => docheck,n(dc_start),Background(${MYTMPRECFILE},m,${LANGUAGE},macro-systemrecording)
exten => docheck,n,Wait(1)
exten => docheck,n,Goto(confmenu,1)
exten => doaccept,1,NoOp( "copy ${MYTMPRECFILE} to ${MYRECFILE}" )
exten => doaccept,n,System(cp ${MYTMPRECFILE}.wav ${MYRECFILE}.wav)
exten => doaccept,n,NoOp( "SYSTEMSTATUS returned: ${SYSTEMSTATUS}" )
exten => doaccept,n,Playback(auth-thankyou)
exten => doaccept,n,Wait(1)
exten => doaccept,n,Hangup
exten => confmenu,1,Background(to-listen-to-it&press-1&to-accept-recording&press-2&to-rerecord-it&press-3,m,${LANGUAGE},macro-systemrecording)
exten => confmenu,n,Read(RECRESULT,,1,,,4)
exten => confmenu,n,GotoIf($["x${RECRESULT}"="x3"]?dorecord,1)
exten => confmenu,n,GotoIf($["x${RECRESULT}"="x1"]?docheck,dc_start)
exten => confmenu,n,GotoIf($["x${RECRESULT}"="x2"]?doaccept,1)
exten => confmenu,n,Goto(1)
exten => 1,1,Goto(docheck,dc_start)
exten => 3,1,Goto(dorecord,1)
exten => t,1,Playback(goodbye)
exten => t,n,Hangup
exten => i,1,Playback(pm-invalid-option)
exten => i,n,Goto(confmenu,1)
exten => h,1,Hangup

; end of [macro-systemrecording]

One thing I’ve noticed is that when confmenu is called, sometimes you have to wait until all the options are spoken before pressing a key, and sometimes it will accept a keypress right away. Not sure why that is.

Now, I can set the feature code and a password for the message(s) that need to be updated, let the appropriate people know, and they can update it themselves. Adding new messages to the mix is so much easier now, too. It can be done entirely through the web interface.

If anyone can see a way to tighten this up, feel free to comment.


Is there any way to change this that after you accept the recording it returns to the IVR that called it?

mycroft: The new method of using a feature code in the System Recording section of FreePBX does not get called from an IVR, you just dial it directly.

The old hack that I was using to access the recording through the IVR could probably be setup to return back to the IVR instead of hanging up, yes.

I’m not sure exactly how, but I’d imagine that it could be as simple as changing the line where Hangup is called, to call the IVR instead.

Better coders than me lurk around here and would hopefully be able to answer.


I did finally figure it out, I replaced the hangups with Goto(${IVR_CONTEXT},return,1), and that returns to the calling IVR from whatever IVR that called it.

Reason is, I run a movie theater and use a good sized IVR(s) to accounce current movies, comming attrations etc. I wanted/needed a way that I could call in from a outbound line, and enter a special hidden option from the main IVR to get to a System Recording Main Menu, all that menu does is call the feature codes from the system recording module, but with the command above, it returns to my calling IVR, and then I can edit/re-record the next recording without hanging up etc. I did have to make misc destination to call the featurecodes - but it works.

Doing it with just the feature code, its only avail from a inside extention and it would hang up after every recording. Sometimes I have to edit 15+ recordings depending on what movies etc are changing…

I did use extentions_override_freepbx.conf and completly replace the maco cause I do not understand using the -custom contexts yet - as far as how they merge etc. But I am learing…

I thank you for your example, it now lets me get the recording right before it gets sent to the live system.

Thanks again