AutoDialer

  1. Create required databases
  2. Configure Mysql server
  3. Configure Web server (apache)
  4. Deploy Web Application
  5. Configure Control Bash Script
  6. Configure Asterisk Dialplan

Create databases for AutoDialer

Auto Dialer Application use one table for all campaigns the data.

campaign table example

campaign table example

mysql> select * from campaign;
+----+----------+--------------+-------+-------+---------+-------------+-------+------+------+------+------------+-----------+--------+
| id | campname | chan_context | retry | pause | timeout | ext_context | exten | var  | app  | data | concurrent | timestamp | active |
+----+----------+--------------+-------+-------+---------+-------------+-------+------+------+------+------------+-----------+--------+
|  2 | test_02  | from-dialer  | 0     | 15    | 45      | from-agents | 555   |      | NULL | NULL | 1          | NULL      | NULL   |
+----+----------+--------------+-------+-------+---------+-------------+-------+------+------+------+------------+-----------+--------+
1 row in set (0.00 sec)

Create the Database `autodialer`

Enter root password is set:

mysql -p

Create database from root mysql user.

Set privileges on the database.

Change YOUR_USER & YOUR_PASSWORD on own the data.

create database autodialer;

grant all privileges on autodialer.* to YOUR_USER@localhost identified by 'YOUR_PASSWORD';

flush privileges;

Create the table `campaign`

use autodialer
CREATE TABLE `campaign` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `campname` VARCHAR(64) DEFAULT NULL,
  `chan_context` VARCHAR(16) DEFAULT NULL,
  `retry` VARCHAR(16) DEFAULT NULL,
  `pause` VARCHAR(4) DEFAULT NULL,
  `timeout` VARCHAR(16) DEFAULT NULL,
  `ext_context` VARCHAR(16) DEFAULT NULL,
  `exten` VARCHAR(8) DEFAULT NULL,
  `var` VARCHAR(16) DEFAULT NULL,
  `app` VARCHAR(16) DEFAULT NULL,
  `data` VARCHAR(16) DEFAULT NULL,
  `concurrent` VARCHAR(8) DEFAULT NULL,
  `timestamp` VARCHAR(16) DEFAULT NULL,
  `active` VARCHAR(8) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `camp` (`campname`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Create the table `admin`

CREATE TABLE `admin` (
  `username` VARCHAR(255) NOT NULL,
  `password_sha1` VARCHAR(64) NOT NULL,
  PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Insert the default user admin/admin(sha1)

insert into admin set `username`='admin', `password_sha1`='d033e22ae348aeb5660fc2140aec35850c4da997';
Tables of the phone numbers for each campaign creates automatically, when create the campaign. It will be described below.

Configure Mysql server

For import the phone numbers from csv files, mysql required FILE privileges, because used LOAD DATA INFILE method.

I recommend not to import files more than 100,000 lines.

/etc/mysql/my.cnf

[mysqld]
secure-file-priv = ""

Restart Mysql Server

# systemctl restart mysql

Set FILE privileges

Connect Mysql CLI

mysql -p

Set privileges

grant file on *.* to YOUR_USER@localhost identified by 'YOUR_PASSWORD';

Check directory privileges

mysql> SHOW VARIABLES LIKE "secure_file_priv";
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| secure_file_priv |       |
+------------------+-------+
1 row in set (0.00 sec)

It's OK

Configure Web Server

Set Directory Granted

  • Debian based: /etc/apache2/apache2.conf
  • Centos: /etc/httpd/conf/httpd.conf

Add follow code to apache config, where /var/www/html/ad your web directory for application :

<Directory /var/www/html/ad>
	Options -Indexes
	AllowOverride All
	Require all granted
</Directory>

restart apache

 systemctl restart apache2

or for Centos

 systemctl restart httpd

Deploy Web Application

Web application is interface for runs the script and populate database.

Download web application and unpack to yours web server root directory:

ad.tar.gz

tar zvxf ad.tar.gz 

Configure mysql credentials previously set during database create

./config.php

...
$mysqli = new mysqli("localhost", "YOUR_USER", "YOUR_PASSWORD", "$conndb");
...

./auth.php

...
$mysqli = new mysqli("localhost", "YOUR_USER", "YOUR_PASSWORD", "$conndb");
...

Change own to asterisk.
This scenario assumes that the Asterisk and the Web server are launched from under asterisk user.

 chown -R asterisk. /var/www/html/ad/
 
 chmod -R 777 /var/www/html/ad/res/dialer/csv/

Configure the Control Bash Script

The script campy.sh very simplest, but make hard-work for the dialer. It take phone-numbers from database and create call files for originate calls.

See for call files: https://www.voip-info.org/asterisk-auto-dial-out/

Asterisk must be loaded with pbx_spool.so:

CLI> module show like spool
Module                         Description                              Use Count  Status      Support Level
pbx_spool.so                   Outgoing Spool Support                   0          Running              core
1 modules loaded

Move the script into /var/spool/asterisk

 mv /var/www/html/ad/campy.sh  /var/spool/asterisk/

Set own asterisk and mod execute

 chown asterisk. /var/spool/asterisk/campy.sh
 chmod a+x /var/spool/asterisk/campy.sh

Configure the database credentials

./campy.sh

user="YOUR_USER"
pass="YOUR_PASSWORD"
db="autodialer"

Web Application Start

It's all for installation.

Now open the web application in browser:

http://ip_address/ad

and authorize admin/admin by default (set during db create)

To add the new campaign just enter a camp name and destination answer.

  • Campaign name - use a-z, A-Z, 0-9 and _
  • Max retry - The number of attempts to dial one number, where 0 is one attempt
  • Pause - pause between attempts
  • Wait - Call time
  • Concurrent - number of simultaneous calls
  • Channel context - it's context to dial phone numbers.
  • Exten context - it's context to answer agents.
  • Answer Destination - dialplan extension for answered calls.
    • example 555 in: exten ⇒ _555,1,queue(queue_name)

The example simple dialplan:

[from-dialer]
exten => _X.,1,Dial(PJSIP/${EXTEN}@sip_trunk,,)
   same => n,hangup

[from-agents]
exten => _555,1,Noop
   same => n,queue(queue_name)

exten => _1XX,1,noop
   same => n,set(CALLERID(num)=${CALLERID(num)})
   same => n,dial(SIP/${EXTEN})

When creating a dialplan, as I understand it, you will face the problem of uniform loading of modems (round robin) and choosing a free line. In fact, I think that using these modems is a very bad idea: (

Campaign start

When campaign created, import a phone numbers from csv format.

Csv files format:

1234
1235
1236

or if need for the name

1234,name1
1235,name2
1236,name3

The name can be passed as a CALLERID(name) from the call file and displayed to the agent who received the call.

Checkbox unix need if you create a csv from Linux or Mac the newline format - \n
By default used Windows format - \r\n

Check the list numbers

Interaction with a dialplan

To change call status in the phone numbers database, it is necessary to use a func_odbc in dialplan

This is a difficult moment. maybe you will need my help.

Main problem pass the name of the campaign (it is the name of the table) to b-leg of call.

A call file can transfer the set variables to the dialplan, but they will fall into the a-leg channel, and the agent's response into b-leg.

/etc/asterisk/func_odbc.conf

Example func_odbc config

[ANSWER]
dsn=dialer
writesql=UPDATE ${VAL2} SET status='${VAL3}', timestamp='${VAL4}' WHERE camp='${VAL2}' and number='${VAL1}'
example dialplan
 exten => h,1,set(ODBC_ANSWER(1,2,3,4)=${number},${campaign_name},${DIALSTATUS},${time})

you must pass the following data

  • campaign name
  • called number
  • dialstatus and date,
  • and other data, if you need

This data must be added from dialplan variables.

I can not explain everything in this manual.

The simplest if i do it myself for you.

Maybe I underestimate you, excuse me.

Those you need write to table call status.
These tables are automatically created when importing csv and have campaign name.
The main purpose of the table is the representation of the control script phone numbers for call origin.
Set call status is required in particular so as not to ring the phones a second time.
It’s a good idea to write down the call status for each number after the call.
Call file script get the phone numbers with true status:

 cat /var/spool/asterisk/campy.sh | grep sqlread
sqlread="select concat(number,',',camp,',',name) from autodialer.$campaign where camp = '$campaign' and status in ('NOANS', 'BUSY', 'NOANSWER', 'CONGESTION') order by RAND() limit $limit"

Example really campaign with set status, notice the status column
NOANS - status by default:

MariaDB [autodialer]> select id, number, last_name, camp, status, timestamp from  million1 limit 10;
+----+-------------+--------------------+----------+-------------+-----------+
| id | number      | last_name          | camp     | status      | timestamp |
+----+-------------+--------------------+----------+-------------+-----------+
|  1 | 78967634025 | МАВЛОНОВ           | million1 | NOANSWER    | 16-10-18  |
|  2 | 78982656081 | СИТДИКОВ           | million1 | NOANS       | NULL      |
|  3 | 78982695621 | БУШМАНОВА          | million1 | CHANUNAVAIL | 18-10-18  |
|  4 | 78987292184 | ГАЛИЕВ             | million1 | NOANSWER    | 05-10-18  |
|  5 | 79000411500 | КОРБОЛИНА          | million1 | CHANUNAVAIL | 19-09-18  |
|  6 | 79000411555 | ЛАНЦОВА            | million1 | ANSWER      | 19-10-18  |
|  7 | 79000411593 | НАБИЕВ             | million1 | NOANS       | NULL      |
|  8 | 79000412264 | ВАХИТОВ            | million1 | CHANUNAVAIL | 14-09-18  |
|  9 | 79000412700 | КАРПОВА            | million1 | BUSY        | 14-09-18  |
| 10 | 79000412932 | СТРУГОВА           | million1 | NOANS       | NULL      |
+----+-------------+--------------------+----------+-------------+-----------+
10 rows in set (0.00 sec)

Status

This module needs configure Asterisk Http API and AMI.
It's not required for dialer works.
May be later.

PS

This is a complex solution, I hope I did not miss anything.
The application requires interaction with a dialplan written specifically for it.
It can be difficult for you, and will required help.

It can also be replayed for different tasks.
This version adapted for basic use.
Many other options can be added.

  • soft/call_center/asterisk_autodialer/en.txt
  • Последние изменения: 2020/08/27