Dynamically Recording Calls


Here’s what we would like to do:

We have a manager who oversees a call center. On our old system (Talkswitch), she would put a splitter on the analog line and hook up a tape recorder. She would hit record and let it record all day long.

Is there some sort of option for Asterisk to do this.? We have the *1 option set up, but we would like the manager to have the functionality to turn on/off recording for a certain agent.

Can it be done?


Yes it can be done. You need to set a global variable (or use the Asterisk Database, probably better) in your dialplan that would be something like DORECORDING=TRUE. Then everytime before a Dial command you check to see if the variable is true and if it is then you execute a Monitor command in your dialplan else just Dial. The DORECORDING variable can be set by dialling an extension on the phone like *11 or something.

Example (not tested):

;turn on
exten => *11,1,Answer

;turn off
exten => *22,1,Answer
exten => *22,2,Set(DB(RECORDING/ENABLED=False)

exten => s,1,Answer
exten => s,2,GotoIf($[“x${DB(RECORDING/ENABLED)}x” = “xTRUEx”]?3:4)
exten => s,3,Monitor(…
exten => s,4,Dial(…

Be careful with recording, some states requires the consent of the other party to be recorded.


I was attempting something similar, but I’m new to the dialplan stuff, so it would have taken me forever.

Here’s a twist though. I only want it to record one person, not everybody. Is there a way to just get the SIP identity in the dial plan, like SIP/joeschmoe? I could write something that would set a DB variable, but I don’t know how to determine who is actually dialing out.


Yes. The ${CALLERIDNUM} would = 1234 or ${CallerID} would = “Joe Schmoe <1234>”.

You can also set a global variable for Joe under the [Global] context

JOE="Joe Schmoe <1234>"
JOE=1234 depending on if you going to test for ${CALLERID} or ${CALLERIDNUM}

When I get a moment I will see if I can write something for you. I will PM you.


Awesome, I think I have a place to go now.

One last bit. What abour recording inbound calls when they go through a queue. I can see how to do outbound and direct inbound, but I don’t know about queues.


This is a snippet out of the queues.conf file. You can find a lot of information in the conf files if you have done the make samples. Also great deal of info can be found at:


; Calls may be recorded using Asterisk’s monitor resource
; This can be enabled from within the Queue application, starting recording
; when the call is actually picked up; thus, only successful calls are
; recorded, and you are not recording while people are listening to MOH.
; To enable monitoring, simply specify “monitor-format”; it will be disabled
; otherwise.
; You can specify the monitor filename with by calling SetVar(MONITOR_FILENAME=foo)
; Otherwise it will use ${UNIQUEID}
; monitor-format = gsm|wav|wav49


Thanks for your help.

I was able to create a PHP script that used AMI to set database values, so you can do recording from a webpage. Right now it only does outbound calls.

The only problem is recording inboud calls that fall into the queue. I don’t want to record every call that hits our queue, just the ones that are picked up by a certain user.

Anyways, thanks again for your help.