ABillS. Installing and configuring Callcenter

Once in one company, in order to simplify the search for callers in ABillS, it was necessary to install the Callcenter module, which has different capabilities, but what we needed was pop-up notifications in the browser with a link to the caller’s page.

The Callcenter.pm file will be issued by the ABillS developers after purchasing the module, move it to the required directory:

mv Callcenter.pm /usr/abills/Abills/mysql/

We import data from Callcenter.sql and Events.sql into the database:

mysql --default-character-set=utf8 -D abills < /usr/abills/db/Callcenter.sql
mysql --default-character-set=utf8 -D abills < db/Events.sql

Let’s open the ABillS configuration file:

nano /usr/abills/config.pl

We activate the Callcenter module, and also need the Events module:

@MODULES = (
             'Callcenter',
             'Events',
            );

I also added some parameters:

$conf{CALLCENTER_ASTERISK_PHONE_PREFIX}='\+38';
$conf{EVENTS_ASTERISK} = 1;
$conf{ASTERISK_AMI_IP} = '192.168.5.5';
$conf{ASTERISK_AMI_PORT} = '5039';
$conf{ASTERISK_AMI_USERNAME} = 'abills_admin';
$conf{ASTERISK_AMI_SECRET} = 'Password';
$conf{WEBSOCKET_ENABLED} = 1;

CALLCENTER_ASTERISK_PHONE_PREFIX allows you to remove unnecessary characters at the beginning of the number, I removed +38, because when you call Asterisk sends, for example, +380670000000, and in ABillS, client phones are set as 0670000000.

You also need to configure the Asterisk AMI, as I described in the article:
How to configure Asterisk AMI

Install the necessary components:

sudo apt update
sudo apt install libanyevent-perl
sudo a2enmod proxy
sudo a2enmod proxy_wstunnel
sudo service apache2 restart
sudo apt install -yq cpanminus build-essential
sudo cpanm Protocol::WebSocket
sudo cpanm Asterisk::AMI

Let’s open the web configuration in a text editor:

sudo nano /etc/apache2/sites-enabled/abills_httpd.conf

And inside “VirtualHost” add the following lines:

ProxyPass "/admin/wss/" "ws://127.0.0.1:19443/wss/admin/" retry=1

Just in case, let’s check the correctness of the apache2 configuration and restart it:

sudo apachectl -t
sudo service apache2 restart

It remains to run websocket_backend.pl:

ln -s /usr/abills/misc/websocket_backend.pl /usr/abills/libexec/websocket_backend.pl
chmod +x /usr/abills/libexec/websocket_backend.pl
/usr/abills/libexec/websocket_backend.pl -d

You can also do this:

/usr/abills/libexec/websocket_backend.pl start
/usr/abills/libexec/websocket_backend.pl status
/usr/abills/libexec/websocket_backend.pl -d LOG_FILE=/tmp/abills_websocket.log DEBUG=5

You can check whether websocket_backend.pl is running and terminate it with the commands:

ps xa |grep websocket_backend.pl
sudo killall websocket_backend.pl

Open a port in iptables if necessary:

iptables -I INPUT 1 -p tcp --dport 19443 -j ACCEPT

To make websocket_backend.pl start automatically when Ubuntu starts up, I created an autorun script and activated it:

nano /etc/systemd/system/abills-backend.service
[Unit]
Description=ABillS Websocket Server
After=network.target
After=mysql.service
Requires=mysql.service
 
[Service]
Type=forking
 
PIDFile=/usr/abills/var/log/websocket_backend.pid
 
ExecStartPre=/bin/chown -R www-data /usr/abills/var/
ExecStart=/usr/abills/libexec/websocket_backend.pl -d
ExecReload=/usr/abills/libexec/websocket_backend.pl stop
 
[Install]
WantedBy=multi-user.target
systemctl is-enabled abills-backend.service
systemctl enable abills-backend.service
systemctl start abills-backend.service
systemctl status abills-backend.service
service abills-backend status

Or, instead of the autostart script, you can simply add websocket_backend.pl to /etc/rc.local:

(sleep 5 && /usr/abills/libexec/websocket_backend.pl -d) &

It is also worth considering that the websocket_backend.pl script may suddenly stop working, so I made a watchdog script that will restart it if it crashes, an example can be found in my article:
Simple Watchdog script

The following files will be created in the directory with logs:
/usr/abills/var/log/websocket_internal.log
/usr/abills/var/log/websocket_backend.pid
/usr/abills/var/log/websocket.log
/usr/abills/var/log/event_asterisk.log

To all administrators who should receive notifications in the browser, I indicated the phone number: goip4new in the SIP settings, since several gateways with SIM cards were used and Asterisk sends, for example, goip4 and goip4new.

See also my articles:
Installing Asterisk on Ubuntu
Configuring GOIP4 with Asterisk

Leave a comment

Leave a Reply