Automatic Dialer With Asterisk And GNUDialer - Page 2
MySQL
Now, we have to create the database:
mysqladmin –u root –p create dialer
We will be prompted for a password, enter the same password from the installation, this server should not be public, hence disabling the root user is not mandatory (but equally recommended), if you want to disable it, you can follow these steps:
mysql -u root -p
mysql> use mysql;
mysql> update user set user="remoteroot" where user="root";
mysql> flush privileges;
mysql> quit
Asterisk
Now, we have to patch and install our Asterisk sources. If you already have am asterisk server in place, make sure you have the correct sources.
cd /usr/src
tar zvfx asterisk-1.4.24.1.tar.gz
Aplying the patches:
cd /usr/src/gnudialer
patch -p1 < manager.c.sendevent.14.txt
If you are using asterisk 1.2.x you need to replace the file previous for manager.c.both-patches.txt. When asked for a file to patch, write /usr/src/asterisk-1.4.24.1/main/manager.c
If you are using Asterisk 1.2.x:
patch -p1 < channel.c.hangup_callerid_ast12.diff
When asked for a file to patch, write /usr/src/asterisk-1.2.x/main/channel.c
If you are using Asterisk 1.4.x:
wget http://dynx.net/ASTERISK/gnudialer/channel.c.hangup.1418.diff.txt
patch -p1 < channel.c.hangup.1418.diff.txt
When asked for a file to patch, write /usr/src/asterisk-1.4.24.1/main/channel.c
Now, we can compile asterisk, if you have not succesfully applied the patches, the GNUDialer will not work.
cd ..
cd asterisk-1.4.24.1
./configure
make menuconfig
make
make install
make samples
make config
We now test our asterisk, it should say "Asterisk Ready", then we escape with CTRL+C
asterisk -vvvvvvvc
Start it with
asterisk
AstCRM 1.1.6
AstCRM is the web frontend for the agent, is written in Java and is where the Agent logins so he can start receiving calls.
mkdir /var/www/cgi-bin
chmod 755 /var/www/cgi-bin
cd /usr/src/gnudialer/astcrm-1.1.6
nano Makefile
Look for
[...] DOCROOT=/var/www/html/ [...]
and leave as
[...] DOCROOT=/var/www/ [...]
Open the file get.h and under #include <string> add #include <cstdlib>.
#include <iostream> #include <string> #include <cstdlib>
Same for submitinfo.cpp and under #include <string> add #include <cstdlib>.
#include <iostream> #include <fstream> #include <string> #include <cstdlib> #include <vector> #include <signal.h> #include <sys/time.h> #include <mysql.h> #include "cam2closer.h"
Now, compile and install:
make
make install
Open the file /var/www/cgi-bin/astcrm.conf and configure:
leave-this root # If you change it, put the real MySQL username 1234 # The password from the install localhost # The database host dialer # The database
GNUDialer Puff r181
Once we have all the requirements in place and working, we can install the dialer. First we add the dialer contexts to Asterisk:
cp /usr/src/gnudialer/dialer.conf.14 /etc/asterisk/dialer.conf
echo "#include \"dialer.conf\" " >> /etc/asterisk/extensions.conf
cp /usr/src/gnudialer/gnudialer.conf.EXAMPLE /etc/gnudialer.conf
cp /usr/src/gnudialer/gdhosts.conf.EXAMPLE /etc/gdhosts.conf
updatedb #this is important
Now, we have to open /etc/asterisk/manager.conf and make sure it looks like this (back up before saving):
[general] displaysystemname = yes enabled = yes port = 5038 bindaddr = 0.0.0.0 displayconnects = yes timestampevents = yes [dialer] secret = 1234 read = system,call,log,verbose,command,agent,user write = system,call,log,verbose,command,agent,user permit=0.0.0.0/0.0.0.0 [crm] secret = 1234 read = call,agent,user write = call,agent,user permit=0.0.0.0/0.0.0.0
Open the file /etc/gnudialer.conf and configure:
1234 # GNUDialer admin Password root # If you change it, put the real MySQL username 1234 # The password from the install localhost # The database host dialer # The database name dialer # The username from manager.conf 1234 # The secret from manager.conf localhost # host of the asterisk (yes, we can control remote machines) 5038 # The manager port
cd /usr/src/gnudialer
nano Makefile
Look for
[...] DOCROOT=/var/www/html/ [...]
and leave as
[...] DOCROOT=/var/www/ [...]
We now have to add some stuff to the source code, this is because (I think) the different gcc versions used in the debugging process.
Open dialeradmin.cpp and leave it like this:
#include <iostream> #include <sstream> #include <string> #include <stdio.h> #include <stdlib.h> #include <algorithm> #include <vector> #include <fstream> #include <mysql.h> #include <time.h> #include "post.h" #include "queue.h" #include "agent.h" #include "adminwork.h" #include "settings.h" #include "itos.h" #include "stoi.h" #include "log.h" #include "dispo.h" #include "abnhelper.h" //#include "etcinfo.h"
Then, around line 36 of the same file, look for:
static char *dispo2short(int dispo); static char *dispo2long(int dispo);
and replace with
const char *dispo2short(int dispo); const char *dispo2long(int dispo);
Open the file dispo.h, and around line 76 look for
static char *dispo2short(int dispo);
and replace with
const char *dispo2short(int dispo);
Again around line 87 look for
static char *dispo2long(int dispo);
and replace for
const char *dispo2long(int dispo);
Open log.h and modify it:
#include <iostream> #include <fstream> #include <stdio.h> #include <mysql.h> #include <stdlib.h> #include <algorithm>
Open queue.h and modify it:
#include <string> #include <stdio.h> #include <stdlib.h> #include <algorithm> #include <vector> #include <iterator> #include <iostream> #include <fstream> #include <sstream> #include <unistd.h> #include <time.h> #include "agent.h" #include "call.h" #include "abnhelper.h" #include "exceptions.h"
Open stoi.h and modify it:
#include <string> #include <sstream> #include <stdio.h> #include <stdlib.h> #include <algorithm>
Now, we can compile and install:
make
make install
asterisk -rx "module reload"
Now, you can test the installation by executing:
gnudialer --no-daemon
If you see
d1:/usr/src/gnudialer# gnudialer --no-daemon
--------------------------------------------------
Debug Level: 2
Debug Logfile: /tmp/test.txt
Global TZOffset: -8
Global Maxlines: 23
GnuDialer: Started
GnuDialer: Loading gdhost.conf
GnuDialer: Loading gdhost.conf (done)
GnuDialer: Querying Astersik Agents
GnuDialer: Querying Astersik Agents (done)
CLOSER: Settings Pre-Check
CLOSER: Resetting Filters
DNC: Settings Pre-Check
DNC: Resetting Filters
INBOUND: Settings Pre-Check
INBOUND: Resetting Filters
Then you are all set, you have a working automatic dialer.
The last thing to do is configure Apache so you can execute the proper cgi scripts.
Open /etc/apache2/sites-enabled/000-default and look for ScriptAlias and change it accordingly:
ScriptAlias /cgi-bin/ /var/www/cgi-bin/ <Directory "/var/www/cgi-bin">
Finally, restart Apache:
/etc/init.d/apache2 restart
and using your web browser go to http://your_machine/gnudialer/dialerlogin.html log in by entering the string from the first line of /etc/gnudialer.conf as it is your gnudialer admin password.
That's it! There is a lot of documentation on how to use the dialer in the many README files from the sources and in the forums.
GNUDialer is licensed under the GNU/GPL license written by Heath Schultz, Richard Lyman and Jamerson Medley.
This how to was originally written in Spanish by Mario Hernández and it is available in http://bleh.spooky.cl/2009/05/discadores-automaticos-con-gnudialer.html