Added force_fronter_leave_3way Agent API function

git-svn-id: svn://192.168.202.10@3026 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2018-09-09 13:28:03 +00:00
parent ea5c29567b
commit c35a32b1c1
9 changed files with 300 additions and 11 deletions
+3
View File
@@ -348,6 +348,9 @@ OTHER CHANGES:
updated on your system using the following command:
/usr/share/astguiclient/ADMIN_area_code_populate.pl --purge-table --debug
96. Added new 'force_fronter_leave_3way' Agent API function, allowing an API
command to be sent to the fronter of a call to leave-3way their call.
+10 -1
View File
@@ -23,10 +23,11 @@
# by the administrator of the external system. It should look something like this:
# http://server/vicidial/non_agent_api.php?user=6666&pass=1234&source=test&function=ccc_lead_info&call_id=--A--call_id--B--
#
# Copyright (C) 2017 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2018 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# changes:
# 170609-1326 - First build
# 180908-1414 - Added extra logging
#
$script = 'cm_sc_ccc_lookup_insert.agi';
@@ -151,14 +152,19 @@ $extension =~ s/\'|\"|\\\\|\\\|\\|\\;|\\\;|\;|;//gi;
$blind_xfer=0;
$three_way=0;
$remote_lead_id=0;
if ($calleridname =~ /^V\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d|^Y\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d|^M\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d|^J\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/)
{
$blind_xfer=1;
$remote_lead_id = substr($calleridname, 10, 10);
$remote_lead_id = ($remote_lead_id + 0);
}
elsif ($calleridname =~ /^DC\d\d\d\d\d\dW\d\d\d\d\d\d\d\d\d\dW/)
{
$three_way=1;
$remote_lead_id = substr($calleridname, 9, 10);
$remote_lead_id = ($remote_lead_id + 0);
}
else
{
@@ -395,6 +401,9 @@ if ( (length($Wdocline_cat) > 29) && ($Wdocline_cat !~ /ERROR: ccc_lead_info /)
$AGI->set_callerid($Ynewcallerid);
if ($AGILOG) {$agi_string = "callerID changed: $Ynewcallerid"; &agi_output;}
$stmtA = "INSERT INTO vicidial_ccc_log SET call_date=NOW(),remote_call_id='$calleridname',local_call_id='$YqueryCID',lead_id='$new_lead_id',uniqueid='$uniqueid',channel='$channel',server_ip='$VARserver_ip',list_id='$LEADlist_id',container_id='$container_id',remote_lead_id='$remote_lead_id';";
$affected_rows = $dbhA->do($stmtA);
$external_found=1;
}
}
+30 -1
View File
@@ -130,9 +130,10 @@
# 180301-1257 - Added more teodDB logging
# 180512-2214 - Added reset of hopper_calls_today
# 180818-2229 - Added rolling of vicidial_recent_ascb_calls records
# 180908-1428 - Added daily rolling of vicidial_ccc_log records
#
$build = '180818-2229';
$build = '180908-1428';
$DB=0; # Debug flag
$teodDB=0; # flag to log Timeclock End of Day processes to log file
@@ -1436,6 +1437,34 @@ if ($timeclock_end_of_day_NOW > 0)
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
# roll of vicidial_ccc_log records, keep only 1 day of records in active table
if (!$Q) {print "\nProcessing vicidial_ccc_log table...\n";}
$stmtA = "INSERT IGNORE INTO vicidial_ccc_log_archive SELECT * from vicidial_ccc_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
$event_string = "$sthArows rows inserted into vicidial_ccc_log_archive table";
if (!$Q) {print "$event_string \n";}
if ($teodDB) {&teod_logger;}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_ccc_log WHERE call_date < \"$RMSQLdate\";";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
$event_string = "$sthArows rows deleted from vicidial_ccc_log table";
if (!$Q) {print "$event_string \n";}
if ($teodDB) {&teod_logger;}
$stmtA = "optimize table vicidial_ccc_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
# reset in-group closing_time_now_trigger trigger flag
$stmtA = "UPDATE vicidial_inbound_groups SET closing_time_now_trigger='N' WHERE closing_time_now_trigger='Y';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+32 -1
View File
@@ -1,4 +1,4 @@
AGENT API DOCUMENT Started: 2008-07-03 Updated: 2018-03-23
AGENT API DOCUMENT Started: 2008-07-03 Updated: 2018-09-08
This document describes the functions of an API(Application Programming Interface)
for the VICIDIAL Agent screen. This functionality will be rather limited at first
@@ -35,6 +35,7 @@ pause_code - set a pause code if the agent is paused
audio_playback - basic play/pause/resume/stop/restart audio in agent session
switch_lead - for inbound calls, switches lead_id of live inbound call on agent screen
calls_in_queue_count - display a count of the calls waiting in queue for the specific agent
force_fronter_leave_3way - will send a command to fronter agent to leave-3way call that executing agent is on
New scripts:
@@ -912,6 +913,36 @@ SUCCESS: calls_in_queue_count - 0
--------------------------------------------------------------------------------
force_fronter_leave_3way -
DESCRIPTION:
will send a command to fronter agent to leave-3way call that executing agent is on. Will not execute command for the named 'agent_user', but will look for oldest other user currently on a call with the same lead_id that the named agent_user is on the phone with.
VALUES:
value -
REQUIRED, choices are below:
LOCAL_ONLY - looks for fronter only on local cluster
LOCAL_AND_CCC - looks on local cluster and remote CCC to send command to (will always check local first)
CCC_REMOTE - use this when the closer is not on this cluster
lead_id -
OPTIONAL, only to be used with CCC_REMOTE value commands
EXAMPLE URLS:
http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=force_fronter_leave_3way&value=LOCAL_ONLY
http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=force_fronter_leave_3way&value=LOCAL_AND_CCC
RESPONSES:
ERROR: no user found - 6666
ERROR: agent_user is not logged in - 6666
ERROR: agent_user is not on a phone call - 6666
ERROR: no fronter found - 6666
SUCCESS: force_fronter_leave_3way SENT - 6667
SUCCESS: force_fronter_leave_3way command sent over CCC - test_ccc
--------------------------------------------------------------------------------
Other information:
@@ -1,4 +1,4 @@
CROSS-CLUSTER COMMUNICATION Started: 2011-05-27 Updated: 2017-08-09
CROSS-CLUSTER COMMUNICATION Started: 2011-05-27 Updated: 2018-09-08
--------------------------------
@@ -25,7 +25,7 @@ Below is a description of a simple cross-cluster option, which is to send lead d
# 2- local list_id to insert lead into(if not populated, will use external system's list_id for the lead)
- The AGI script will use parameters defined in a Settings Container for the URL of the originating system's Non-Agent API and credentials
The originating server will need to set up a user of level 8 with view reports and Agent API abilities, and the ccc_lead_info API function enabled
The originating server will need to set up a user of level 8 with view reports and Agent API abilities, and the 'ccc_lead_info' API function enabled
You will need to add a Settings Container to hold the URL for the originating system to look up the lead data, something like this:
http://server/vicidial/non_agent_api.php?user=6666&pass=1234&source=test&function=ccc_lead_info&call_id=--A--call_id--B--
@@ -42,6 +42,7 @@ NOTES:
# If lead is not found on external system, call will go to the 'B' option in the call menu
# If container is not found, call will go to the 'C' option in the call menu
# If call_id is not defined, call will go to the 'D' option in the call menu
# If you are planning to use the 'force_fronter_leave_3way' function across this CCC connection, make sure you have that API permission set for the API user above
@@ -3979,6 +3979,7 @@ channel VARCHAR(100) default '',
server_ip VARCHAR(60) NOT NULL,
list_id BIGINT(14) UNSIGNED,
container_id VARCHAR(40) default '',
remote_lead_id INT(9) UNSIGNED,
index (call_date),
index (local_call_id),
index (lead_id)
@@ -4216,6 +4217,9 @@ CREATE UNIQUE INDEX vdidla_key on vicidial_did_log_archive(uniqueid, call_date,
CREATE TABLE vicidial_recent_ascb_calls_archive LIKE vicidial_recent_ascb_calls;
CREATE TABLE vicidial_ccc_log_archive LIKE vicidial_ccc_log;
CREATE UNIQUE INDEX ccc_unq_key on vicidial_ccc_log_archive(uniqueid, call_date, lead_id);
GRANT RELOAD ON *.* TO cron@'%';
GRANT RELOAD ON *.* TO cron@localhost;
@@ -4295,4 +4299,4 @@ INSERT INTO vicidial_settings_containers(container_id,container_notes,container_
UPDATE system_settings set vdc_agent_api_active='1';
UPDATE system_settings SET db_schema_version='1555',db_schema_update_date=NOW(),reload_timestamp=NOW();
UPDATE system_settings SET db_schema_version='1556',db_schema_update_date=NOW(),reload_timestamp=NOW();
+8
View File
@@ -672,6 +672,7 @@ channel VARCHAR(100) default '',
server_ip VARCHAR(60) NOT NULL,
list_id BIGINT(14) UNSIGNED,
container_id VARCHAR(40) default '',
remote_lead_id INT(9) UNSIGNED,
index (call_date),
index (local_call_id),
index (lead_id)
@@ -747,3 +748,10 @@ UPDATE system_settings SET db_schema_version='1554',db_schema_update_date=NOW()
CREATE INDEX vicidial_email_group_key on vicidial_email_list(group_id);
UPDATE system_settings SET db_schema_version='1555',db_schema_update_date=NOW() where db_schema_version < 1555;
ALTER TABLE vicidial_ccc_log ADD remote_lead_id INT(9) UNSIGNED;
CREATE TABLE vicidial_ccc_log_archive LIKE vicidial_ccc_log;
CREATE UNIQUE INDEX ccc_unq_key on vicidial_ccc_log_archive(uniqueid, call_date, lead_id);
UPDATE system_settings SET db_schema_version='1556',db_schema_update_date=NOW() where db_schema_version < 1556;
+205 -2
View File
@@ -96,10 +96,11 @@
# 180301-2302 - Added GET-AND-POST URL logging
# 180323-2227 - Fix for dial_ingroup error message on external_dial function
# 180903-1606 - Added count for waiting emails to calls_in_queue_count function
# 180908-1433 - Added force_fronter_leave_3way function
#
$version = '2.14-62';
$build = '180903-1606';
$version = '2.14-63';
$build = '180908-1433';
$startMS = microtime();
@@ -4185,6 +4186,208 @@ if ($function == 'calls_in_queue_count')
################################################################################
### BEGIN - force_fronter_leave_3way - will send a command to fronter agent to leave-3way call that executing agent is on
################################################################################
if ($function == 'force_fronter_leave_3way')
{
if ( ( ($value!='LOCAL_ONLY') and ($value!='LOCAL_AND_CCC') and ($value!='CCC_REMOTE') ) or ( (strlen($agent_user)<1) and (strlen($alt_user)<2) ) )
{
$result = _QXZ("ERROR");
$result_reason = _QXZ("force_fronter_leave_3way not valid");
echo "$result: $result_reason - $value|$agent_user\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
else
{
if ( (!preg_match("/ $function /",$VUapi_allowed_functions)) and (!preg_match("/ALL_FUNCTIONS/",$VUapi_allowed_functions)) )
{
$result = _QXZ("ERROR");
$result_reason = _QXZ("auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION");
echo "$result: $result_reason - $value|$user|$function|$VUuser_group\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
if (strlen($alt_user)>1)
{
$stmt = "select count(*) from vicidial_users where custom_three='$alt_user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
if ($row[0] > 0)
{
$stmt = "select user from vicidial_users where custom_three='$alt_user' order by user;";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$agent_user = $row[0];
}
else
{
$result = _QXZ("ERROR");
$result_reason = _QXZ("no user found");
echo "$result: $result_reason - $alt_user\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
}
$stmt = "SELECT count(*) from vicidial_live_agents where user='$agent_user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
if ( ($row[0] > 0) or ($value == 'CCC_REMOTE') )
{
$Alead_id=0;
### grab the lead_id for this logged-in agent
$stmt="SELECT lead_id from vicidial_live_agents where user='$agent_user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$vla_ct = mysqli_num_rows($rslt);
if ($vla_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$Alead_id = $row[0];
}
if ( ($Alead_id > 0) or ( (strlen($lead_id) > 0) and ($value == 'CCC_REMOTE') ) )
{
$QUERYlead_id = $Alead_id;
if ($value == 'CCC_REMOTE')
{$QUERYlead_id = $lead_id;}
$other_user='';
$fronter_found=0;
### user ID of fronter agent
$stmt="SELECT user from vicidial_live_agents where user!='$agent_user' and lead_id='$QUERYlead_id' order by last_call_time limit 1;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$vla_ct = mysqli_num_rows($rslt);
if ($vla_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$other_user = $row[0];
$fronter_found++;
$external_transferconf = "LEAVE_3WAY_CALL---------NO------------$epoch";
$stmt="UPDATE vicidial_live_agents set external_transferconf='$external_transferconf' where user='$other_user';";
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
$result = _QXZ("SUCCESS");
$result_reason = _QXZ("SUCCESS: force_fronter_leave_3way SENT")." - $other_user";
echo "$result_reason";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
else
{
if ($value == 'LOCAL_AND_CCC')
{
# check for CCC-fronted call on this server
$stmt="SELECT remote_lead_id,container_id from vicidial_ccc_log where lead_id='$QUERYlead_id';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$vcl_ct = mysqli_num_rows($rslt);
if ($vcl_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$remote_lead_id = $row[0];
$container_id = $row[1];
$stmt="SELECT container_entry from vicidial_settings_containers where container_id='$container_id';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$vsc_ct = mysqli_num_rows($rslt);
if ($vsc_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$container_entry = $row[0];
$container_entry = preg_replace("/ccc_lead_info/","force_fronter_leave_3way&value=CCC_REMOTE&lead_id=$remote_lead_id&agent_user=CCC_REMOTE",$container_entry);
$container_entry = preg_replace("/vicidial\/non_agent_|admin\/non_agent_/","agc/",$container_entry);
$SQL_log = "$container_entry";
$SQL_log = preg_replace('/;/','',$SQL_log);
$SQL_log = addslashes($SQL_log);
$stmt = "INSERT INTO vicidial_url_log SET uniqueid='$uniqueid',url_date='$NOW_TIME',url_type='start',url='$SQL_log',url_response='';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
$url_id = mysqli_insert_id($link);
$URLstart_sec = date("U");
### grab the call_start_url ###
if ($DB > 0) {echo "$container_entry<BR>\n";}
$SCUfile = file("$container_entry");
if ( !($SCUfile) )
{
$error_array = error_get_last();
$error_type = $error_array["type"];
$error_message = $error_array["message"];
$error_line = $error_array["line"];
$error_file = $error_array["file"];
}
if ($DB > 0) {echo "$SCUfile[0]<BR>\n";}
### update url log entry
$URLend_sec = date("U");
$URLdiff_sec = ($URLend_sec - $URLstart_sec);
if ($SCUfile)
{
$SCUfile_contents = implode("", $SCUfile);
$SCUfile_contents = preg_replace('/;/','',$SCUfile_contents);
$SCUfile_contents = addslashes($SCUfile_contents);
$fronter_found++;
$result = _QXZ("SUCCESS");
$result_reason = _QXZ("force_fronter_leave_3way command sent over CCC")." - $container_id";
echo "$result: $result_reason\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
else
{
$SCUfile_contents = "PHP ERROR: Type=$error_type - Message=$error_message - Line=$error_line - File=$error_file";
}
$stmt = "UPDATE vicidial_url_log SET response_sec='$URLdiff_sec',url_response='$SCUfile_contents' where url_log_id='$url_id';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$affected_rows = mysqli_affected_rows($link);
}
}
}
}
if ($fronter_found < 1)
{
$result = _QXZ("ERROR");
$result_reason = _QXZ("no fronter found");
echo "$result: $result_reason - $agent_user\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
}
else
{
$result = _QXZ("ERROR");
$result_reason = _QXZ("agent_user is not on a phone call");
echo "$result: $result_reason - $agent_user\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
}
else
{
$result = _QXZ("ERROR");
$result_reason = _QXZ("agent_user is not logged in");
echo "$result: $result_reason - $agent_user\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
}
}
################################################################################
### END - force_fronter_leave_3way
################################################################################
################################################################################
### BEGIN - optional "close window" link
################################################################################
+4 -3
View File
@@ -126,7 +126,7 @@ $UGreports = 'ALL REPORTS, NONE, Real-Time Main Report, Real-Time Campaign Summa
$Vtables = 'NONE,log_noanswer,did_agent_log,contact_information';
$APIfunctions = 'ALL_FUNCTIONS add_group_alias add_lead add_list add_phone add_phone_alias add_user agent_ingroup_info agent_stats_export agent_status audio_playback blind_monitor call_agent callid_info change_ingroups check_phone_number did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list park_call pause_code preview_dial_action ra_call_control recording recording_lookup send_dtmf server_refresh set_timer_action sounds_list st_get_agent_active_lead st_login_log transfer_conference update_fields update_lead update_list update_log_entry update_phone update_phone_alias update_user user_group_status vm_list webphone_url webserver logged_in_agents update_campaign update_did lead_field_info phone_number_log switch_lead ccc_lead_info lead_status_search call_status_stats calls_in_queue_count';
$APIfunctions = 'ALL_FUNCTIONS add_group_alias add_lead add_list add_phone add_phone_alias add_user agent_ingroup_info agent_stats_export agent_status audio_playback blind_monitor call_agent callid_info change_ingroups check_phone_number did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list park_call pause_code preview_dial_action ra_call_control recording recording_lookup send_dtmf server_refresh set_timer_action sounds_list st_get_agent_active_lead st_login_log transfer_conference update_fields update_lead update_list update_log_entry update_phone update_phone_alias update_user user_group_status vm_list webphone_url webserver logged_in_agents update_campaign update_did lead_field_info phone_number_log switch_lead ccc_lead_info lead_status_search call_status_stats calls_in_queue_count force_fronter_leave_3way';
### BEGIN housecleaning of old static report files, if not done before ###
@@ -4441,12 +4441,13 @@ else
# 180812-0902 - Added scheduled_callbacks_auto_reschedule campaign setting
# 180825-2100 - Added scheduled_callbacks_timezones_container campaign setting and timezones display
# 180904-1206 - Added copying of in-group user grades/ranks when copying an in-group
# 180908-1618 - Added force_fronter_leave_3way API function
#
# make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time
$admin_version = '2.14-686a';
$build = '180904-1206';
$admin_version = '2.14-687a';
$build = '180908-1618';
$STARTtime = date("U");
$SQLdate = date("Y-m-d H:i:s");