Asterisk and recording incoming and outgoing calls

Namphibian picture Namphibian · Apr 8, 2012 · Viewed 13.8k times · Source

So I have been trying to learn asterisk with some limited success. Essentially what I would like to do is record both incoming and outgoing calls. However there seems to be a gap in my understanding.

From what I understand, can one of the asterisk gurus confirm that my understanding is either correct or incorrect.

  1. sip.conf and iax.conf is used to register "channels". These channels could be softphones, analog phones or even other devices that connect to my asterisk server.

  2. extensions.conf defines the route for incoming calls into asterisk. Thus I can say if someone calls extension 100 on my asterisk box connect this call to sip device 100 or play the hello-world sample.

I suspect my understanding of extensions might be flawed a little. Here is what I am trying to do. I want to record both incoming and outgoing calls to asterisk no matter what extension. From what I can see you can use the monitor and mixmonitor commands in the dialplan. So my understanding is that you can only specify what happens to incoming calls in the dialplan.

So for example I could possibly record incoming calls to extension 600 by adding the following to my extension.conf

exten => 600,1,Answer()
same => 600,2,Monitor(wav,,m)

I suspect I am making a terribly wrong assumption on how the dialplan works.

Thanks

Answer

mriiidul picture mriiidul · Feb 11, 2014

incoming & outgoing call can be record via this dial plane

add this line to extensions.conf

**

exten => _!,n,System(mkdir "/var/spool/asterisk/${CALLERID(number)}")
exten => _!,n,Set(FILENAME=CallingTime(${DATETIME})-Called(${EXTEN}))
exten => _!,n,Set(MONITOR_EXEC_ARGS=&& mv "/var/spool/asterisk/monitor/${FILENAME}.wav" "/var/spool/asterisk/${CALLERID(number)}/")
exten => _!,n,Monitor(wav,${FILENAME},mb)
exten => _!,n,Dial(SIP/100,,r)
exten => _!,n,Hangup()

**