Recording incoming & outgoing calls with Asterisk

Recording incoming & outgoing calls with Asterisk

This was very tricky to set-up, but also full of satisfaction. These adds and changed will record .wav files of all calls incoming and outgoing and concatenate the streams, placing them in the /var/spool/asterisk/monitor directory with a filename detarmined by the date, time and caller/number called from what extension. Good job!;)

MORE…

in extensions_custom.conf i added this:

[ext-group-custom]
exten => h,1,Macro(record-cleanup)
exten => h,2,Hangup

[macro-record-on]
exten => s,1,AGI(set-timestamp.agi)
exten => s,2,SetVar(CALLFILENAME=${TIMESTAMP}-${CALLERIDNUM}-${ARG2})
exten => s,3,Monitor(wav,${CALLFILENAME}|mb)

[macro-record-cleanup]
exten => s,1,SetVar(MONITORDIR=/var/spool/asterisk/monitor)
exten => s,2,GotoIf($[${CALLFILENAME} = ${FOO}]?6:3)
exten => s,3,System(/usr/bin/soxmix ${MONITORDIR}/${CALLFILENAME}-in.wav ${MONITORDIR}/${CALLFILENAME}-out.wav ${MONITORDIR}/${CALLFILENAME}.wav)
exten => s,4,System(/bin/rm ${MONITORDIR}/${CALLFILENAME}-in.wav ${MONITORDIR}/${CALLFILENAME}-out.wav)
;exten => s,5,System(/usr/bin/toast -F ${MONITORDIR}/${CALLFILENAME})
exten => s,6,NoOp

—-
i have not installed toast for converting to smaller size file format… i just leave wav files.

and in extensions.conf i modified:
[macro-dial]
exten => s,1,Macro(record-on,${CALLERIDNUM})
exten => s,2,AGI,dialparties.agi
exten => s,10,Dial(${ds}) ; dialparties will set the priority to 10 if $ds is not null
exten => s,20,Wait(1) ; dialparties will set priority to 22 if was direct call and caller is on phone
exten => s,21,Voicemail(b${ARG3}) ; The call was internal to extension, and was busy
exten => o,1,Background(one-moment-please) ; 0 during vm message will hangup
exten => o,2,goto(from-pstn,s,1)
exten => h,1,Macro(record-cleanup)

[macro-hangupcall]
exten => s,1,Macro(record-cleanup)
exten => s,2,ResetCDR(w)
exten => s,3,NoCDR()
exten => s,4,Wait(5)
exten => s,5,Hangup

[macro-dialout-trunk]
exten => s,1,Macro(record-on,${CALLERIDNUM})
exten => s,2,GotoIf($[foo${ECID${CALLERIDNUM}} = foo]?5) ;check
for CID override for exten
exten => s,3,SetCallerID(${ECID${CALLERIDNUM}})
exten => s,4,Goto(7)
exten => s,5,GotoIf($[foo${OUTCID_${ARG1}} = foo]?7) ;check
for CID override for trunk
exten => s,6,SetCallerID(${OUTCID_${ARG1}})
exten => s,7,SetGroup(OUT_${ARG1})
exten => s,8,CheckGroup(${OUTMAXCHANS_${ARG1}})
; if we’ve used up the max channels, continue at 108 (n+101)
exten => s,9,SetVar(DIAL_NUMBER=${ARG2})
exten => s,10,SetVar(DIAL_TRUNK=${ARG1})
exten => s,11,AGI(fixlocalprefix) ; this sets DIAL_NUMBER to the proper dial string for this trunk
;exten => s,12,SetCIDNum(14573573)
exten => s,12,Dial(${OUT_${ARG1}}/${OUTPREFIX_${ARG1}}${DIAL_NUMBER})
; if dial fails (ie, all channels are busy), continue at 112 (n+101)

; we should only get here if the call was successful (?)
exten => s,10,Congestion

; exit points for macro
exten => s,109,NoOp(max channels used up)
exten => s,113,NoOp(dial failed)

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s