Bringing Telecommunications In-House - Part 5:
Recording Calls

The fifth part in the series bringing my telecommunications in-house. This article will cover call recording in Asterisk 13.

DPMA Call Recording

When in an active call, my Digium D70 has (due to my DPMA configuration) a Record soft key. It is, however, non-functional at present.

There are going to be two goals in this article:

  1. Allow per-call recording from devices.
  2. Record all calls that go through Asterisk.

I'm hoping that to get my D70 to record calls is going to be as simple as adding a voicemail mailbox to the phone.

D70 Voicemail

sudo nano /etc/asterisk/voicemail.conf
[voicemail-johncook]
6003 => 12345,John Cook
sudo nano /etc/asterisk/res_digium_phone.conf
[6003]
...
mailbox=6003@voicemail-johncook

[6004]
...
mailbox=6003@voicemail-johncook

[6005]
...
mailbox=6003@voicemail-johncook

[6006]
...
mailbox=6003@voicemail-johncook

[6007]
...
mailbox=6003@voicemail-johncook

[6008]
...
mailbox=6003@voicemail-johncook
sudo asterisk -rvvv
voicemail reload
module reload res_digium_phone.so
digium_phones reconfigure phone John
quit
sudo chown -R asterisk:asterisk /var/spool/asterisk/

At this point my first objective is complete: I can now record all incoming/outgoing calls at the touch of a button.

One current issue, however, is that although calls are recorded no useful information about the call is recorded, such as caller ID.

Recording All Calls Automatically

sudo nano /etc/asterisk/extensions.conf

Modify the incoming and outgoing contexts, so that they look like the following:


[sipgate-in]

exten => _+4419INCOMING,1,Set(thedid=${SIP_HEADER(To)})
same => 2,Set(thedid=${CUT(thedid,@,1)})
same => 3,Set(thedid=${CUT(thedid,:,2)})
same => 4,GotoIf($["${thedid:0:2}" == "00"]?5:6)
same => 5,Set(thedid=+${thedid:2})
same => 6,MixMonitor(${UNIQUEID}.wav,abm(6003@voicemail-johncook/Cust5))
same => 7,GotoIf($["${thedid}" == "+4419INCOMING"]?8:9)
same => 8,Dial(SIP/6005&SIP/6010,60,tr) ; phone must be registered
same => 9,StopMixMonitor()
same => 10,Hangup

Note: I have masked my incoming DID by replacing it with +4419INCOMING - had I used XXXXXX someone may have copy/pasted without modifying the code and spent some time wondering where their error is.

sudo asterisk -rx "dialplan reload"

What I have done here is modify Asterisk auto Call recording from Stack Overflow, adding MixMonitor after modifications to the incoming/outgoing number, and StopMixMonitor after the Dial references before Hangup.

I have used the same location used by my Digium D70 so all calls are recorded and end up in my visual voicemail folder "Recordings".

Again, caller ID for outgoing calls is not displayed, and the resultant files are mono 16-bit 8 Khz PCM (wav). The files are both saved to /var/spool/asterisk/monitor/ and /var/spool/asterisk/voicemail/.../Cust5/.

This is only a temporary solution, and I will undoubtedly modify it at a later time for multiple channels (e.g. stereo for regular calls) and higher quality when G722 or similar is used. this will do for now, though.