586 lines
24 KiB
Perl
586 lines
24 KiB
Perl
#!/usr/bin/perl
|
|
#
|
|
# agi-set_variables.agi version 2.14
|
|
#
|
|
# runs after a call_log before call is placed out the trunk and sets all
|
|
# vicidial_list fields as variables for the call
|
|
#
|
|
# takes an optional argument to set SIP headers, PJSIP header, IAXVARs, and dialplan variables
|
|
# multiple can be set with a _ inbetween but combining SIP and PJSIP is not advised
|
|
#
|
|
# You need to put lines similar to those below in your extensions.conf file:
|
|
#
|
|
# ; VICIDIAL_auto_dialer transfer script AMD with Load Balanced:
|
|
# exten => _91NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
|
|
# exten => _91NXXNXXXXXX,n,AGI(agi-set_variables.agi,)
|
|
# exten => _91NXXNXXXXXX,n,Verbose("phone_code:${phone_code}, phone_number:${phone_number}, lead_id:${lead_id}")
|
|
# exten => _91NXXNXXXXXX,n,Dial(${TESTSIPTRUNK}/${EXTEN:2},${CAMPDTO},To)
|
|
# exten => _91NXXNXXXXXX,n,Hangup()
|
|
#
|
|
# ; Send SIP Headers
|
|
# exten => _91NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
|
|
# exten => _91NXXNXXXXXX,n,AGI(agi-set_variables.agi,SIP)
|
|
# exten => _91NXXNXXXXXX,n,Dial(${TESTSIPTRUNK}/${EXTEN:2},${CAMPDTO},To)
|
|
# exten => _91NXXNXXXXXX,n,Hangup()
|
|
#
|
|
# ; Send PJSIP Headers
|
|
# ; handler
|
|
# exten => pjsipheaders,1,AGI(agi-set_variables.agi,PJSIP)
|
|
# exten => pjsipheaders,n,Return()
|
|
# ; dialplan
|
|
# exten => _91NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
|
|
# exten => _91NXXNXXXXXX,n,Dial(${TESTSIPTRUNK}/${EXTEN:2},${CAMPDTO},Tob(default^pjsipheaders^1))
|
|
# exten => _91NXXNXXXXXX,n,Hangup()
|
|
#
|
|
# ; Send IAXVARs
|
|
# exten => _91NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
|
|
# exten => _91NXXNXXXXXX,n,AGI(agi-set_variables.agi,IAX)
|
|
# exten => _91NXXNXXXXXX,n,Dial(${TESTSIPTRUNK}/${EXTEN:2},${CAMPDTO},To)
|
|
# exten => _91NXXNXXXXXX,n,Hangup()
|
|
#
|
|
# ; Send SIP Headers and set dialplan variables
|
|
# exten => _91NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
|
|
# exten => _91NXXNXXXXXX,n,AGI(agi-set_variables.agi,SIP_dialplan)
|
|
# exten => _91NXXNXXXXXX,n,Verbose("phone_code:${phone_code}, phone_number:${phone_number}, lead_id:${lead_id}")
|
|
# exten => _91NXXNXXXXXX,n,Dial(${TESTSIPTRUNK}/${EXTEN:2},${CAMPDTO},To)
|
|
# exten => _91NXXNXXXXXX,n,Hangup()
|
|
#
|
|
# Copyright (C) 2026 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
|
#
|
|
# changes:
|
|
# 101118-1409 - First build
|
|
# 101125-2115 - Added parsing for 3-way calls
|
|
# 110404-1604 - Added dial_timeout and cpd_amd_action variables
|
|
# 141211-1643 - Added cpd_unknown_action
|
|
# 230606-0818 - Added remaining vicidial_list fields
|
|
# 260602-1356 - Added var_type option allowing SIP headers, PJSIP headers, and IAXVARs to be set
|
|
|
|
$script = 'agi-set_variables.agi';
|
|
|
|
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
|
$year = ($year + 1900);
|
|
$mon++;
|
|
if ($mon < 10) {$mon = "0$mon";}
|
|
if ($mday < 10) {$mday = "0$mday";}
|
|
if ($hour < 10) {$hour = "0$hour";}
|
|
if ($min < 10) {$min = "0$min";}
|
|
if ($sec < 10) {$sec = "0$sec";}
|
|
|
|
$now_date_epoch = time();
|
|
$now_date = "$year-$mon-$mday $hour:$min:$sec";
|
|
|
|
# default path to astguiclient configuration file:
|
|
$PATHconf = '/etc/astguiclient.conf';
|
|
|
|
|
|
# determine what type of variables are set IE dialplan, IAX, SIP, PJSIP
|
|
# dialplan are normal dialplan variables
|
|
# IAX uses the IAXVAR() function to set a variable that can be read on the other side of a IAX
|
|
$var_types = 'dialplan';
|
|
if (defined $ARGV[0]) { $var_types = $ARGV[0]; }
|
|
|
|
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
|
|
@conf = <conf>;
|
|
close(conf);
|
|
$i=0;
|
|
foreach(@conf)
|
|
{
|
|
$line = $conf[$i];
|
|
$line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
|
|
if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) )
|
|
{$PATHhome = $line; $PATHhome =~ s/.*=//gi;}
|
|
if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) )
|
|
{$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;}
|
|
if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) )
|
|
{$PATHagi = $line; $PATHagi =~ s/.*=//gi;}
|
|
if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) )
|
|
{$PATHweb = $line; $PATHweb =~ s/.*=//gi;}
|
|
if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) )
|
|
{$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;}
|
|
if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) )
|
|
{$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;}
|
|
if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) )
|
|
{$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;}
|
|
if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) )
|
|
{$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;}
|
|
if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) )
|
|
{$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;}
|
|
if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) )
|
|
{$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;}
|
|
if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) )
|
|
{$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;}
|
|
if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) )
|
|
{$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;}
|
|
$i++;
|
|
}
|
|
|
|
if (!$VARDB_port) {$VARDB_port='3306';}
|
|
if (!$AGILOGfile) {$AGILOGfile = "$PATHlogs/agiout.$year-$mon-$mday";}
|
|
|
|
use DBI;
|
|
use Asterisk::AGI;
|
|
$AGI = new Asterisk::AGI;
|
|
|
|
|
|
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
|
or die "Couldn't connect to database: " . DBI->errstr;
|
|
|
|
### Grab Server values from the database
|
|
$stmtA = "SELECT agi_output FROM servers where server_ip = '$VARserver_ip';";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($sthArows > 0)
|
|
{
|
|
$AGILOG = '0';
|
|
@aryA = $sthA->fetchrow_array;
|
|
$DBagi_output = $aryA[0];
|
|
if ($DBagi_output =~ /STDERR/) {$AGILOG = '1';}
|
|
if ($DBagi_output =~ /FILE/) {$AGILOG = '2';}
|
|
if ($DBagi_output =~ /BOTH/) {$AGILOG = '3';}
|
|
}
|
|
$sthA->finish();
|
|
|
|
### begin parsing run-time options ###
|
|
if (length($ARGV[0])>1)
|
|
{
|
|
if ($AGILOG)
|
|
{$agi_string = "Perl Environment Dump:"; &agi_output;}
|
|
$i=0;
|
|
while ($#ARGV >= $i)
|
|
{
|
|
$args = "$args $ARGV[$i]";
|
|
if ($AGILOG) {$agi_string = "$i|$ARGV[$i]"; &agi_output;}
|
|
$i++;
|
|
}
|
|
|
|
### list of command-line array arguments:
|
|
@ARGV_vars = split(/-----/, $ARGV[0]);
|
|
$CLI_exten = $ARGV_vars[0];
|
|
$force_playback = $ARGV_vars[1];
|
|
}
|
|
|
|
|
|
$|=1;
|
|
while(<STDIN>)
|
|
{
|
|
chomp;
|
|
last unless length($_);
|
|
if ($AGILOG)
|
|
{
|
|
if (/^agi_(\w+)\:\s+(.*)$/)
|
|
{
|
|
$AGI{$1} = $2;
|
|
}
|
|
}
|
|
|
|
if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;}
|
|
if (/^agi_priority\:\s+(.*)$/) {$priority = $1;}
|
|
if (/^agi_channel\:\s+(.*)$/) {$channel = $1;}
|
|
if (/^agi_extension\:\s+(.*)$/) {$extension = $1;}
|
|
if (/^agi_type\:\s+(.*)$/) {$type = $1;}
|
|
if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1; $calleridnum = $callerid;}
|
|
if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;}
|
|
}
|
|
|
|
if ( (length($callerid)>20) && ($callerid =~ /\"\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) )
|
|
{
|
|
$callerid =~ s/^\"//gi;
|
|
$callerid =~ s/\".*$//gi;
|
|
# ### set the callerid to the ACQS value(calleridname)
|
|
# print "SET CALLERID $callerid\n";
|
|
# checkresult($result);
|
|
# print STDERR "callerID changed: $callerid\n";
|
|
}
|
|
if ( (
|
|
(length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) )
|
|
) or ( (length($calleridname)>17) && ($calleridname =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) ) or ( (length($calleridname)>17) && ($calleridname =~ /\d\d\d\d\d\dW\d\d\d\d\d\d\d\d\d\dW$/) ) )
|
|
{
|
|
$callerid = $calleridname;
|
|
# ### set the callerid to the ACQS value(calleridname)
|
|
# print "SET CALLERID $callerid\n";
|
|
# checkresult($result);
|
|
# print STDERR "callerID changed: $callerid\n";
|
|
}
|
|
|
|
|
|
if ($AGILOG) {$agi_string = "AGI Environment Dump:"; &agi_output;}
|
|
|
|
foreach $i (sort keys %AGI)
|
|
{
|
|
if ($AGILOG) {$agi_string = " -- $i = $AGI{$i}"; &agi_output;}
|
|
}
|
|
|
|
if ($AGILOG) {$agi_string = "AGI Variables: |$unique_id|$channel|$extension|$type|$callerid|"; &agi_output;}
|
|
|
|
|
|
$VDADcampaign='';
|
|
$VDADphone='';
|
|
$VDADphone_code='';
|
|
$auto_dial_timeout='60';
|
|
$cpd_amd_action='DISABLED';
|
|
$cpd_unknown_action='DISABLED';
|
|
|
|
$callerid =~ s/\"//gi;
|
|
$callerid =~ s/ .*//gi;
|
|
$CIDlead_id = $callerid;
|
|
if ($CIDlead_id =~ /W\d\d\d\d\d\d\d\d\d\dW$/)
|
|
{
|
|
@CIDlead_id_array = split(/W/, $CIDlead_id);
|
|
$CIDlead_id = $CIDlead_id_array[1];
|
|
}
|
|
else
|
|
{
|
|
$CIDlead_id = substr($CIDlead_id, 10, 10);
|
|
}
|
|
$CIDlead_id = ($CIDlead_id + 0);
|
|
if ( ($CLIlead_id > 0) && ($CIDlead_id < 1) ) {$CIDlead_id = $CLIlead_id;}
|
|
$VD_lead_id = $CIDlead_id;
|
|
|
|
if ($AGILOG) {$agi_string = "+++++ VARIABLE SET START : |$CIDlead_id|$now_date|$AST_ver|$priority|$calleridname|"; &agi_output;}
|
|
|
|
|
|
########## FIND vicidial_auto_calls record ##########
|
|
$stmtA = "SELECT campaign_id,phone_number FROM vicidial_auto_calls where callerid='$callerid' order by auto_call_id desc limit 1;";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($AGILOG) {$agi_string = "$sthArows|$stmtA|"; &agi_output;}
|
|
if ($sthArows > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$campaign_id = $aryA[0];
|
|
$dialed_number = $aryA[1];
|
|
$sthA->finish();
|
|
}
|
|
|
|
$stmtA = "SELECT dial_timeout,cpd_amd_action,cpd_unknown_action FROM vicidial_campaigns where campaign_id='$campaign_id' limit 1;";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($AGILOG) {$agi_string = "$sthArows|$stmtA|"; &agi_output;}
|
|
if ($sthArows > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$auto_dial_timeout = $aryA[0];
|
|
# only set if auto-dial call
|
|
if ($callerid =~ /^V/)
|
|
{
|
|
$cpd_amd_action = $aryA[1];
|
|
$cpd_unknown_action = $aryA[2];
|
|
}
|
|
$sthA->finish();
|
|
}
|
|
|
|
$stmtA = "SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,phone_code,called_since_last_reset,entry_list_id,gmt_offset_now FROM vicidial_list where lead_id='$VD_lead_id';";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($sthArows > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$lead_id = $aryA[0];
|
|
$entry_date = $aryA[1];
|
|
$modify_date = $aryA[2];
|
|
$status = $aryA[3];
|
|
$user = $aryA[4];
|
|
$vendor_lead_code = $aryA[5];
|
|
$source_id = $aryA[6];
|
|
$list_id = $aryA[7];
|
|
$phone_number = $aryA[8];
|
|
$title = $aryA[9];
|
|
$first_name = $aryA[10];
|
|
$middle_initial = $aryA[11];
|
|
$last_name = $aryA[12];
|
|
$address1 = $aryA[13];
|
|
$address2 = $aryA[14];
|
|
$address3 = $aryA[15];
|
|
$city = $aryA[16];
|
|
$state = $aryA[17];
|
|
$province = $aryA[18];
|
|
$postal_code = $aryA[19];
|
|
$country_code = $aryA[20];
|
|
$gender = $aryA[21];
|
|
$date_of_birth = $aryA[22];
|
|
$alt_phone = $aryA[23];
|
|
$email = $aryA[24];
|
|
$security_phrase = $aryA[25];
|
|
$comments = $aryA[26];
|
|
$called_count = $aryA[27];
|
|
$last_local_call_time = $aryA[28];
|
|
$rank = $aryA[29];
|
|
$owner = $aryA[30];
|
|
$phone_code = $aryA[31];
|
|
$called_since_last_reset = $aryA[32];
|
|
$entry_list_id = $aryA[33];
|
|
$gmt_offset_now = $aryA[34];
|
|
}
|
|
$sthA->finish();
|
|
|
|
$lead_id =~ s/ /+/gi;
|
|
$entry_date =~ s/ /+/gi;
|
|
$modify_date =~ s/ /+/gi;
|
|
$status =~ s/ /+/gi;
|
|
$user =~ s/ /+/gi;
|
|
$vendor_lead_code =~ s/ /+/gi;
|
|
$source_id =~ s/ /+/gi;
|
|
$list_id =~ s/ /+/gi;
|
|
$phone_number =~ s/ /+/gi;
|
|
$title =~ s/ /+/gi;
|
|
$first_name =~ s/ /+/gi;
|
|
$middle_initial =~ s/ /+/gi;
|
|
$last_name =~ s/ /+/gi;
|
|
$address1 =~ s/ /+/gi;
|
|
$address2 =~ s/ /+/gi;
|
|
$address3 =~ s/ /+/gi;
|
|
$city =~ s/ /+/gi;
|
|
$state =~ s/ /+/gi;
|
|
$province =~ s/ /+/gi;
|
|
$postal_code =~ s/ /+/gi;
|
|
$country_code =~ s/ /+/gi;
|
|
$gender =~ s/ /+/gi;
|
|
$date_of_birth =~ s/ /+/gi;
|
|
$alt_phone =~ s/ /+/gi;
|
|
$email =~ s/ /+/gi;
|
|
$security_phrase =~ s/ /+/gi;
|
|
$comments =~ s/ /+/gi;
|
|
$called_count =~ s/ /+/gi;
|
|
$last_local_call_time =~ s/ /+/gi;
|
|
$rank =~ s/ /+/gi;
|
|
$owner =~ s/ /+/gi;
|
|
$phone_code =~ s/ /+/gi;
|
|
$called_since_last_reset =~ s/ /+/gi;
|
|
$entry_list_id =~ s/ /+/gi;
|
|
$gmt_offset_now =~ s/ /+/gi;
|
|
$campaign_id =~ s/ /+/gi;
|
|
$dialed_number =~ s/ /+/gi;
|
|
|
|
@vtypes = split( /_/, $var_types );
|
|
|
|
if ( (grep { $_ eq 'dialplan' } @vtypes) || (length($var_types) < 1) )
|
|
{
|
|
$AGI->exec("EXEC Set(_lead_id=$lead_id)");
|
|
$AGI->exec("EXEC Set(_entry_date=$entry_date)");
|
|
$AGI->exec("EXEC Set(_modify_date=$modify_date)");
|
|
$AGI->exec("EXEC Set(_status=$status)");
|
|
$AGI->exec("EXEC Set(_user=$user)");
|
|
$AGI->exec("EXEC Set(_vendor_lead_code=$vendor_lead_code)");
|
|
$AGI->exec("EXEC Set(_source_id=$source_id)");
|
|
$AGI->exec("EXEC Set(_list_id=$list_id)");
|
|
$AGI->exec("EXEC Set(_phone_number=$phone_number)");
|
|
$AGI->exec("EXEC Set(_title=$title)");
|
|
$AGI->exec("EXEC Set(_first_name=$first_name)");
|
|
$AGI->exec("EXEC Set(_middle_initial=$middle_initial)");
|
|
$AGI->exec("EXEC Set(_last_name=$last_name)");
|
|
$AGI->exec("EXEC Set(_address1=$address1)");
|
|
$AGI->exec("EXEC Set(_address2=$address2)");
|
|
$AGI->exec("EXEC Set(_address3=$address3)");
|
|
$AGI->exec("EXEC Set(_city=$city)");
|
|
$AGI->exec("EXEC Set(_state=$state)");
|
|
$AGI->exec("EXEC Set(_province=$province)");
|
|
$AGI->exec("EXEC Set(_postal_code=$postal_code)");
|
|
$AGI->exec("EXEC Set(_country_code=$country_code)");
|
|
$AGI->exec("EXEC Set(_gender=$gender)");
|
|
$AGI->exec("EXEC Set(_date_of_birth=$date_of_birth)");
|
|
$AGI->exec("EXEC Set(_alt_phone=$alt_phone)");
|
|
$AGI->exec("EXEC Set(_email=$email)");
|
|
$AGI->exec("EXEC Set(_security_phrase=$security_phrase)");
|
|
$AGI->exec("EXEC Set(_comments=$comments)");
|
|
$AGI->exec("EXEC Set(_called_count=$called_count)");
|
|
$AGI->exec("EXEC Set(_last_local_call_time=$last_local_call_time)");
|
|
$AGI->exec("EXEC Set(_rank=$rank)");
|
|
$AGI->exec("EXEC Set(_owner=$owner)");
|
|
$AGI->exec("EXEC Set(_phone_code=$phone_code)");
|
|
$AGI->exec("EXEC Set(_called_since_last_reset=$called_since_last_reset)");
|
|
$AGI->exec("EXEC Set(_entry_list_id=$entry_list_id)");
|
|
$AGI->exec("EXEC Set(_gmt_offset_now=$gmt_offset_now)");
|
|
$AGI->exec("EXEC Set(_campaign_id=$campaign_id)");
|
|
$AGI->exec("EXEC Set(_dialed_number=$dialed_number)");
|
|
$AGI->exec("EXEC Set(_auto_dial_timeout=$auto_dial_timeout)");
|
|
$AGI->exec("EXEC Set(_cpd_amd_action=$cpd_amd_action)");
|
|
$AGI->exec("EXEC Set(_cpd_unknown_action=$cpd_unknown_action)");
|
|
}
|
|
if ( grep { $_ eq 'IAX' } @vtypes )
|
|
{
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_lead_id)=$lead_id)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_entry_date)=$entry_date)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_modify_date)=$modify_date)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_status)=$status)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_user)=$user)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_vendor_lead_code)=$vendor_lead_code)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_source_id)=$source_id)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_list_id)=$list_id)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_phone_number)=$phone_number)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_title)=$title)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_first_name)=$first_name)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_middle_initial)=$middle_initial)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_last_name)=$last_name)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_address1)=$address1)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_address2)=$address2)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_address3)=$address3)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_city)=$city)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_state)=$state)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_province)=$province)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_postal_code)=$postal_code)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_country_code)=$country_code)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_gender)=$gender)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_date_of_birth)=$date_of_birth)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_alt_phone)=$alt_phone)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_email)=$email)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_security_phrase)=$security_phrase)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_comments)=$comments)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_called_count)=$called_count)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_last_local_call_time)=$last_local_call_time)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_rank)=$rank)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_owner)=$owner)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_phone_code)=$phone_code)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_called_since_last_reset)=$called_since_last_reset)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_entry_list_id)=$entry_list_id)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_gmt_offset_now)=$gmt_offset_now)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_campaign_id)=$campaign_id)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_dialed_number)=$dialed_number)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_auto_dial_timeout)=$auto_dial_timeout)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_cpd_amd_action)=$cpd_amd_action)");
|
|
$AGI->exec("Set", "IAXVAR(VICIDIAL_cpd_unknown_action)=$cpd_unknown_action)");
|
|
}
|
|
if ( grep { $_ eq 'SIP' } @vtypes )
|
|
{
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-lead_id:$lead_id");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-entry_date:$entry_date");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-modify_date:$modify_date");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-status:$status");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-user:$user");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-vendor_lead_code:$vendor_lead_code");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-source_id:$source_id");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-list_id:$list_id");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-phone_number:$phone_number");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-title:$title");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-first_name:$first_name");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-middle_initial:$middle_initial");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-last_name:$last_name");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-address1:$address1");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-address2:$address2");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-address3:$address3");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-city:$city");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-state:$state");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-province:$province");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-postal_code:$postal_code");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-country_code:$country_code");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-gender:$gender");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-date_of_birth:$date_of_birth");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-alt_phone:$alt_phone");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-email:$email");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-security_phrase:$security_phrase");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-comments:$comments");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-called_count:$called_count");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-last_local_call_time:$last_local_call_time");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-rank:$rank");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-owner:$owner");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-phone_code:$phone_code");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-called_since_last_reset:$called_since_last_reset");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-entry_list_id:$entry_list_id");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-gmt_offset_now:$gmt_offset_now");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-campaign_id:$campaign_id");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-dialed_number:$dialed_number");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-auto_dial_timeout:$auto_dial_timeout");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-cpd_amd_action:$cpd_amd_action");
|
|
$AGI->exec("SIPAddHeader", "X-VICIDIAL-cpd_unknown_action:$cpd_unknown_action");
|
|
}
|
|
if ( grep { $_ eq 'PJSIP' } @vtypes )
|
|
{
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-lead_id)=$lead_id)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-entry_date)=$entry_date)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-modify_date)=$modify_date)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-status)=$status)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-user)=$user)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-vendor_lead_code)=$vendor_lead_code)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-source_id)=$source_id)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-list_id)=$list_id)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-phone_number)=$phone_number)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-title)=$title)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-first_name)=$first_name)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-middle_initial)=$middle_initial)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-last_name)=$last_name)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-address1)=$address1)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-address2)=$address2)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-address3)=$address3)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-city)=$city)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-state)=$state)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-province)=$province)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-postal_code)=$postal_code)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-country_code)=$country_code)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-gender)=$gender)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-date_of_birth)=$date_of_birth)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-alt_phone)=$alt_phone)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-email)=$email)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-security_phrase)=$security_phrase)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-comments)=$comments)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-called_count)=$called_count)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-last_local_call_time)=$last_local_call_time)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-rank)=$rank)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-owner)=$owner)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-phone_code)=$phone_code)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-called_since_last_reset)=$called_since_last_reset)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-entry_list_id)=$entry_list_id)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-gmt_offset_now)=$gmt_offset_now)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-campaign_id)=$campaign_id)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-dialed_number)=$dialed_number)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-auto_dial_timeout)=$auto_dial_timeout)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-cpd_amd_action)=$cpd_amd_action)");
|
|
$AGI->exec("Set", "PJSIP_HEADER(add,X-VICIDIAL-cpd_unknown_action)=$cpd_unknown_action)");
|
|
}
|
|
|
|
$dbhA->disconnect();
|
|
|
|
|
|
if ($AGILOG) {$agi_string = "+++++ VARIABLE SET DONE EXITING : |$CIDlead_id|$now_date|$calleridname|$phone_number|"; &agi_output;}
|
|
|
|
|
|
|
|
|
|
exit;
|
|
|
|
sub checkresult
|
|
{
|
|
my ($res) = @_;
|
|
my $retval;
|
|
$tests++;
|
|
chomp $res;
|
|
if ($res =~ /^200/)
|
|
{
|
|
$res =~ /result=(-?\d+)/;
|
|
if (!length($1))
|
|
{
|
|
# print STDERR "FAIL ($res)\n";
|
|
$fail++;
|
|
}
|
|
else
|
|
{
|
|
# print STDERR "PASS ($1)\n";
|
|
$pass++;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
# print STDERR "FAIL (unexpected result '$res')\n";
|
|
$fail++;
|
|
}
|
|
}
|
|
|
|
|
|
sub agi_output
|
|
{
|
|
if ($AGILOG >=2)
|
|
{
|
|
### open the log file for writing ###
|
|
open(Lout, ">>$AGILOGfile")
|
|
|| die "Can't open $AGILOGfile: $!\n";
|
|
print Lout "$now_date|$script|$agi_string\n";
|
|
close(Lout);
|
|
}
|
|
### send to STDERR writing ###
|
|
if ( ($AGILOG == '1') || ($AGILOG == '3') )
|
|
{print STDERR "$now_date|$script|$agi_string\n";}
|
|
$agi_string='';
|
|
}
|