I have a client with particular call recording needs that I've been trying to meet for quite some time now.
They wanted their calls to be automatically recorded (easily done through Incredible PBX GUI) but also wanted employees to be able to search through their recorded calls and download them (easily done through UCP). The problem was, they also wanted to be able to delete individual call recordings. I couldn't find a way to do this other than by configuring a chronjob that deleted calls every x amount of days. They wanted something more user friendly.
They use FOP2 which provides an easy way to record calls, listen to, download and delete them. Unfortunately, it doesn't allow for automatic call recording.
What I've done, with some much appreciated guidance from Nicolás Gudiño (creator of FOP2), is written a post recording script that allows users to manage (listen, download and delete) their recordings from the FOP2 GUI.
Here's how:
For starters, I created a file in /var/lib/asterisk/bin/ and called it postrecording.sh. This file needs proper permissions to function chmod 755 postrecording.sh.
The script:
#!/bin/bash
#Post recording
mysql -u username -ppassword <<EOF
use mysql
####VARIABLES
SET @path := (SELECT DATE_FORMAT(CURDATE(),'/var/spool/asterisk/monitor/%Y/%m/%d/'));
####MAIN
INSERT IGNORE INTO asterisk.fop2recordings
(uniqueid, datetime, ownerextension, targetextension, filename, duration, context)
SELECT uniqueid, calldate, cnum, dst, CONCAT(@path,recordingfile), duration, dcontext
FROM asteriskcdrdb.cdr
WHERE recordingfile LIKE '%wav%'
ORDER BY calldate DESC
LIMIT 10
EOF
What it does:
When FreePBX finishes a recording, it is stored in a mysql table asteriskcdrdb.cdr.
The script takes certain important values and writes them to FOP2's recording table asterisk.fop2recordings.
The @path variable allows us to save the recorded file as /var/spool/asterisk/monitor/year/day/filename.wav in asterisk.fop2recordings. This is important because without the path, you can't listen to or download the recordings.
If you want to see recordings of incoming calls and not just outbound calls, there are a few extra needed steps.
You'll need to modify:
/var/www/html/fop2/recordings.php
If you scroll down, you'll get to a section that starts with // Sanitize Input. A little bit further, you'll find this line:
$grid->set_condition("(ownerextension='$extension' OR $admin=1)");
change it to:
$grid->set_condition("(ownerextension='$extension' OR $admin=1 OR targetextension='$extension')");
One last step is needed. For the script to be automatically run after recorded calls are completed, you need to go to settings, advanced settings, in the Incredible PBX GUI. Change Display Readonly Settings and Override Readonly Settings to true and click apply. Next insert /var/lib/asterisk/bin/postrecording.sh under the Post Call Recording Script section.
There you have it, an easy way for users to retrieve and delete their calls through FOP2.
*NOTE
Default Incredible PBX credentials for MYSQL are
username: root
password: passw0rd
If you see any weaknesses in my script please let me know. This is my first time writing a script.
They wanted their calls to be automatically recorded (easily done through Incredible PBX GUI) but also wanted employees to be able to search through their recorded calls and download them (easily done through UCP). The problem was, they also wanted to be able to delete individual call recordings. I couldn't find a way to do this other than by configuring a chronjob that deleted calls every x amount of days. They wanted something more user friendly.
They use FOP2 which provides an easy way to record calls, listen to, download and delete them. Unfortunately, it doesn't allow for automatic call recording.
What I've done, with some much appreciated guidance from Nicolás Gudiño (creator of FOP2), is written a post recording script that allows users to manage (listen, download and delete) their recordings from the FOP2 GUI.
Here's how:
For starters, I created a file in /var/lib/asterisk/bin/ and called it postrecording.sh. This file needs proper permissions to function chmod 755 postrecording.sh.
The script:
#!/bin/bash
#Post recording
mysql -u username -ppassword <<EOF
use mysql
####VARIABLES
SET @path := (SELECT DATE_FORMAT(CURDATE(),'/var/spool/asterisk/monitor/%Y/%m/%d/'));
####MAIN
INSERT IGNORE INTO asterisk.fop2recordings
(uniqueid, datetime, ownerextension, targetextension, filename, duration, context)
SELECT uniqueid, calldate, cnum, dst, CONCAT(@path,recordingfile), duration, dcontext
FROM asteriskcdrdb.cdr
WHERE recordingfile LIKE '%wav%'
ORDER BY calldate DESC
LIMIT 10
EOF
What it does:
When FreePBX finishes a recording, it is stored in a mysql table asteriskcdrdb.cdr.
The script takes certain important values and writes them to FOP2's recording table asterisk.fop2recordings.
The @path variable allows us to save the recorded file as /var/spool/asterisk/monitor/year/day/filename.wav in asterisk.fop2recordings. This is important because without the path, you can't listen to or download the recordings.
If you want to see recordings of incoming calls and not just outbound calls, there are a few extra needed steps.
You'll need to modify:
/var/www/html/fop2/recordings.php
If you scroll down, you'll get to a section that starts with // Sanitize Input. A little bit further, you'll find this line:
$grid->set_condition("(ownerextension='$extension' OR $admin=1)");
change it to:
$grid->set_condition("(ownerextension='$extension' OR $admin=1 OR targetextension='$extension')");
One last step is needed. For the script to be automatically run after recorded calls are completed, you need to go to settings, advanced settings, in the Incredible PBX GUI. Change Display Readonly Settings and Override Readonly Settings to true and click apply. Next insert /var/lib/asterisk/bin/postrecording.sh under the Post Call Recording Script section.
There you have it, an easy way for users to retrieve and delete their calls through FOP2.
*NOTE
Default Incredible PBX credentials for MYSQL are
username: root
password: passw0rd
If you see any weaknesses in my script please let me know. This is my first time writing a script.
Last edited: