diff --git a/agc_2-X/trunk/agi/agi-3way_press_agent.agi b/agc_2-X/trunk/agi/agi-3way_press_agent.agi index 35b169e9..f864ea83 100644 --- a/agc_2-X/trunk/agi/agi-3way_press_agent.agi +++ b/agc_2-X/trunk/agi/agi-3way_press_agent.agi @@ -23,16 +23,17 @@ #exten => _49907.,n,Hangup # # -# Copyright (C) 2023 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2024 Matt Florell LICENSE: AGPLv2 # # changes: # 231113-2016 - First Build # 231118-1600 - Added endings for HUNGUP and TIMEOUT # 231227-1428 - Added multi-phone ability +# 240114-0942 - Added agent_heartbeat # $script = 'agi-3way_press_agent.agi'; -$build = '231227-1428'; +$build = '240114-0942'; $at='@'; $S='*'; @@ -406,7 +407,7 @@ if ( ($CALLphone_numbers_ct > 0) && (length($CALLphone_numbers) > 4) ) $allCIDs .= "$VIDqueryCID|"; ### Insert the call to vicidial_3way_press_live - $stmtA="INSERT INTO vicidial_3way_press_live SET call_date=\"$SQLdate\",caller_code='$calleridname',call_3way_id='$VIDqueryCID',lead_id='$lead_id',phone_number='$CALLphone_numbers_ARY[$vp]',dialstring='$temp_prefix_code$CALLphone_numbers_ARY[$vp]',outbound_cid='$original_cid',user='$CALLuser',session_id='$CALLsession_id',server_ip='$CALLserver_ip',session_id_3way='',status='NEW';"; + $stmtA="INSERT INTO vicidial_3way_press_live SET call_date=\"$SQLdate\",caller_code='$calleridname',call_3way_id='$VIDqueryCID',lead_id='$lead_id',phone_number='$CALLphone_numbers_ARY[$vp]',dialstring='$temp_prefix_code$CALLphone_numbers_ARY[$vp]',outbound_cid='$original_cid',user='$CALLuser',session_id='$CALLsession_id',server_ip='$CALLserver_ip',session_id_3way='',status='NEW',agent_heartbeat=NOW();"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $affected_rowsA = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live INSERT: |$affected_rowsA|$stmtA|"; &agi_output;} @@ -436,7 +437,7 @@ else $allCIDs .= "$VIDqueryCID|"; ### Insert the call to vicidial_3way_press_live - $stmtA="INSERT INTO vicidial_3way_press_live SET call_date=\"$SQLdate\",caller_code='$calleridname',call_3way_id='$VIDqueryCID',lead_id='$lead_id',phone_number='$phone_number',dialstring='$dialstring',outbound_cid='$original_cid',user='$CALLuser',session_id='$CALLsession_id',server_ip='$CALLserver_ip',session_id_3way='',status='NEW';"; + $stmtA="INSERT INTO vicidial_3way_press_live SET call_date=\"$SQLdate\",caller_code='$calleridname',call_3way_id='$VIDqueryCID',lead_id='$lead_id',phone_number='$phone_number',dialstring='$dialstring',outbound_cid='$original_cid',user='$CALLuser',session_id='$CALLsession_id',server_ip='$CALLserver_ip',session_id_3way='',status='NEW',agent_heartbeat=NOW();"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $affected_rowsA = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live INSERT: |$affected_rowsA|$stmtA|"; &agi_output;} @@ -471,6 +472,13 @@ while ($wait_loop < 100) $AGI->stream_file('hold_tone'); } + ### Update agent_heartbeat on all outside-agent calls + $stmtA="UPDATE vicidial_3way_press_live SET agent_heartbeat=NOW() where call_3way_id IN('$allCIDs');"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rowsA = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live agent_heartbeat UPDATE: |$affected_rowsA|$stmtA|"; &agi_output;} + + ### Find all associated outside-agent calls $stmtA = "SELECT status,call_3way_id FROM vicidial_3way_press_live where call_3way_id IN('$allCIDs') order by status desc limit 11;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; diff --git a/agc_2-X/trunk/agi/agi-3way_press_outside.agi b/agc_2-X/trunk/agi/agi-3way_press_outside.agi index c72765f6..2394f2b3 100644 --- a/agc_2-X/trunk/agi/agi-3way_press_outside.agi +++ b/agc_2-X/trunk/agi/agi-3way_press_outside.agi @@ -53,10 +53,11 @@ # 231113-2041 - First Build # 231227-1427 - Added multi-phone ability # 240108-1503 - Added call_channel and call_transfer logging +# 240114-0946 - Added check of agent_heartbeat # $script = 'agi-3way_press_outside.agi'; -$build = '231227-1427'; +$build = '240114-0946'; $at='@'; $S='*'; @@ -332,7 +333,8 @@ $CALLsession_id=''; $CALLuser=''; $CALLlead_id=''; $CALLsession_id_3way=''; -$stmtA = "SELECT server_ip,session_id,user,lead_id,session_id_3way FROM vicidial_3way_press_live where call_3way_id='$calleridname' order by call_date desc limit 1;"; +$CALLagent_heartbeat=0; +$stmtA = "SELECT server_ip,session_id,user,lead_id,session_id_3way,UNIX_TIMESTAMP(agent_heartbeat) FROM vicidial_3way_press_live where call_3way_id='$calleridname' order by call_date desc limit 1;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -345,9 +347,39 @@ if ($sthArows > 0) $CALLuser = $aryA[2]; $CALLlead_id = $aryA[3]; $CALLsession_id_3way = $aryA[4]; + $CALLagent_heartbeat = $aryA[5]; } $sthA->finish(); +$heartbeat_test = ( (time()) - 9); +if ( ($sthArows > 0) && ($CALLagent_heartbeat <= $heartbeat_test) ) + { + if ($AGILOG) {$agi_string = "3-WAY AGENT ERROR: heartbeat gone, exiting... |($CALLagent_heartbeat < $heartbeat_test)|$calleridname|"; &agi_output;} + + ### Update the call in vicidial_3way_press_live + $stmtA="DELETE FROM vicidial_3way_press_live where call_3way_id='$calleridname';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rowsA = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live agent gone DELETE: |$affected_rowsA|$stmtA|"; &agi_output;} + + ### Update the call in vicidial_3way_press_log + $stmtA="UPDATE vicidial_3way_press_log SET result=CONCAT(result,'|Agent Gone: $SQLdate') where call_3way_id='$calleridname';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rowsA = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- vicidial_3way_press_log agent gone UPDATE: |$affected_rowsA|$stmtA|"; &agi_output;} + + print "SET CONTEXT $context\n"; + $result = ; + checkresult($result); + print "SET EXTENSION i\n"; + $result = ; + checkresult($result); + print "SET PRIORITY 1\n"; + $result = ; + checkresult($result); + exit; + } + $stmtA = "SELECT user FROM vicidial_live_agents where lead_id='$lead_id' and server_ip='$CALLserver_ip' order by live_agent_id desc limit 1;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -451,7 +483,7 @@ if ($stage =~ /accepted/i) $AGI->stream_file('hold_tone'); } - $stmtA = "SELECT status,session_id_3way FROM vicidial_3way_press_live where call_3way_id='$calleridname' order by call_date desc limit 1;"; + $stmtA = "SELECT status,session_id_3way,UNIX_TIMESTAMP(agent_heartbeat) FROM vicidial_3way_press_live where call_3way_id='$calleridname' order by call_date desc limit 1;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -459,11 +491,41 @@ if ($stage =~ /accepted/i) if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $CALLstatus = $aryA[0]; - $CALLconf_exten = $aryA[1]; + $CALLstatus = $aryA[0]; + $CALLconf_exten = $aryA[1]; + $CALLagent_heartbeat = $aryA[2]; } $sthA->finish(); + $heartbeat_test = ( (time()) - 9); + if ($CALLagent_heartbeat <= $heartbeat_test) + { + if ($AGILOG) {$agi_string = "3-WAY AGENT ERROR: heartbeat gone 2, exiting... |($CALLagent_heartbeat < $heartbeat_test)|$calleridname|"; &agi_output;} + + ### Update the call in vicidial_3way_press_live + $stmtA="DELETE FROM vicidial_3way_press_live where call_3way_id='$calleridname';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rowsA = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live agent gone 2 DELETE: |$affected_rowsA|$stmtA|"; &agi_output;} + + ### Update the call in vicidial_3way_press_log + $stmtA="UPDATE vicidial_3way_press_log SET result=CONCAT(result,'|Agent Gone: $SQLdate') where call_3way_id='$calleridname';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rowsA = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- vicidial_3way_press_log agent gone 2 UPDATE: |$affected_rowsA|$stmtA|"; &agi_output;} + + print "SET CONTEXT $context\n"; + $result = ; + checkresult($result); + print "SET EXTENSION i\n"; + $result = ; + checkresult($result); + print "SET PRIORITY 1\n"; + $result = ; + checkresult($result); + exit; + } + if ( ($CALLstatus =~ /RESERVED/) && (length($CALLconf_exten) > 0) ) { ### Update the call in vicidial_3way_press_live diff --git a/agc_2-X/trunk/docs/AGENT_3WAY_PRESS-1_CALLS.txt b/agc_2-X/trunk/docs/AGENT_3WAY_PRESS-1_CALLS.txt index 06ff552a..7cda085c 100644 --- a/agc_2-X/trunk/docs/AGENT_3WAY_PRESS-1_CALLS.txt +++ b/agc_2-X/trunk/docs/AGENT_3WAY_PRESS-1_CALLS.txt @@ -1,4 +1,4 @@ -Agent 3-way Press-1 Calls DOC Started: 2023-11-13 Updated: 2024-01-10 +Agent 3-way Press-1 Calls DOC Started: 2023-11-13 Updated: 2024-01-14 This document will go over how to set up Agent Screen 3-way calls with outside @@ -44,6 +44,7 @@ Transfer = The outside-user call is transferred to the agent and customer. Declined = The outside-user call did not press '1' to accept the call. Too Slow = Multi-Call Only, The outside-user did press '1' to accept the call, but another outside-user pressed '1' before them. Defeated = Multi-Call Only, another outside-user pressed '1' before them, so this call was hung up. +Agent Gone = The agent 3way call is gone, no ability to accept outside-agent transfer Hungup = Either the call timed out or another outside-user pressed '1' before them, so this call was hung up. @@ -133,6 +134,7 @@ server_ip VARCHAR(15), session_id_3way VARCHAR(20) default '', status VARCHAR(40), call_channel VARCHAR(100) default '', +agent_heartbeat DATETIME, index(call_date), index(caller_code), index(call_3way_id), diff --git a/agc_2-X/trunk/docs/VICIDIAL_statuses.txt b/agc_2-X/trunk/docs/VICIDIAL_statuses.txt index a528da25..3ab04810 100644 --- a/agc_2-X/trunk/docs/VICIDIAL_statuses.txt +++ b/agc_2-X/trunk/docs/VICIDIAL_statuses.txt @@ -82,3 +82,4 @@ IQNANQ - In-Queue call No-Agent-No-Queue drop SRDROP - SHARED outbound campaign drop to in-group, not included in most DROP stats HUCXXX - Enhanced Disconnect Logging level 3 failed calls, where 'XXX' is the disconnect code. For example: "HUC18" for Cause 18 (SIP 408 Request timeout) ADAIR - Dead Air Auto, for AMD NOAUDIODATA calls +ACFLTR - Inbound call areacode filter check diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index 01fd99a4..4044cf90 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -5065,6 +5065,7 @@ server_ip VARCHAR(15), session_id_3way VARCHAR(20) default '', status VARCHAR(40), call_channel VARCHAR(100) default '', +agent_heartbeat DATETIME, index(call_date), index(caller_code), index(call_3way_id), @@ -5573,4 +5574,4 @@ INSERT INTO `wallboard_reports` VALUES ('AGENTS_AND_QUEUES','Agents and Queues', UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1704',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1705',db_schema_update_date=NOW(),reload_timestamp=NOW(); diff --git a/agc_2-X/trunk/extras/upgrade_2.14.sql b/agc_2-X/trunk/extras/upgrade_2.14.sql index b9c7ae07..e3e41cf4 100644 --- a/agc_2-X/trunk/extras/upgrade_2.14.sql +++ b/agc_2-X/trunk/extras/upgrade_2.14.sql @@ -2589,3 +2589,7 @@ ALTER TABLE vicidial_3way_press_log_archive ADD call_channel VARCHAR(100) defaul ALTER TABLE vicidial_3way_press_log_archive ADD call_transfer ENUM('N','Y') default 'N'; UPDATE system_settings SET db_schema_version='1704',db_schema_update_date=NOW() where db_schema_version < 1704; + +ALTER TABLE vicidial_3way_press_live ADD agent_heartbeat DATETIME; + +UPDATE system_settings SET db_schema_version='1705',db_schema_update_date=NOW() where db_schema_version < 1705; diff --git a/agc_2-X/trunk/www/vicidial/AST_3way_press_log_report.php b/agc_2-X/trunk/www/vicidial/AST_3way_press_log_report.php index db28ae15..5ac2a15c 100644 --- a/agc_2-X/trunk/www/vicidial/AST_3way_press_log_report.php +++ b/agc_2-X/trunk/www/vicidial/AST_3way_press_log_report.php @@ -7,6 +7,7 @@ # # 231228-2204 - First build # 240108-1556 - Added channel/server display +# 240114-1018 - Added Agent Gone summary stat # $startMS = microtime(); @@ -443,6 +444,7 @@ else $TOTtooslow=0; $TOTdefeated=0; $TOTtransfer=0; + $TOTagentgone=0; $stmt = "SELECT date_format(call_date, '%Y-%m-%d %H:%i:%s') as date,user,lead_id,phone_number,outbound_cid,result,call_channel,server_ip from ".$vicidial_3way_press_log_table." where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' $user_SQL $phone_number_SQL order by call_date desc limit 100000"; $rslt=mysql_to_mysqli($stmt, $link); @@ -487,6 +489,7 @@ else if (preg_match("/Declined/",$Rresult[$i])) {$TOTdeclined++;} if (preg_match("/Too Slow/",$Rresult[$i])) {$TOTtooslow++;} if (preg_match("/Defeated/",$Rresult[$i])) {$TOTdefeated++;} + if (preg_match("/Agent Gone/",$Rresult[$i])) {$TOTagentgone++;} if (preg_match("/Transfer/",$Rresult[$i])) {$TOTtransfer++; $Rtransfer[$i]++;} else {$BD=''; $ED='';} @@ -520,6 +523,7 @@ else $TOTtooslow = sprintf("%10s", $TOTtooslow); $TOTdefeated = sprintf("%10s", $TOTdefeated); $TOTtransfer = sprintf("%10s", $TOTtransfer); + $TOTagentgone = sprintf("%10s", $TOTagentgone); $ASCII_text.=""._QXZ("Results Summary").":\n"; $ASCII_text.="+------------+------------+\n"; @@ -529,6 +533,7 @@ else $ASCII_text.="| "._QXZ("Declined",10)." | $TOTdeclined |\n"; $ASCII_text.="| "._QXZ("Too Slow",10)." | $TOTtooslow |\n"; $ASCII_text.="| "._QXZ("Defeated",10)." | $TOTdefeated |\n"; + $ASCII_text.="| "._QXZ("Agent Gone",10)." | $TOTagentgone |\n"; $ASCII_text.="| "._QXZ("Transfer",10)." | $TOTtransfer |\n"; $ASCII_text.="+------------+------------+\n"; @@ -546,6 +551,7 @@ else $file_output .= "\""._QXZ("Declined")."\",\"".trim($TOTdeclined)."\"\n"; $file_output .= "\""._QXZ("Too Slow")."\",\"".trim($TOTtooslow)."\"\n"; $file_output .= "\""._QXZ("Defeated")."\",\"".trim($TOTdefeated)."\"\n"; + $file_output .= "\""._QXZ("Agent Gone")."\",\"".trim($TOTagentgone)."\"\n"; $file_output .= "\""._QXZ("Transfer")."\",\"".trim($TOTtransfer)."\"\n"; $file_output .= "\n"; $file_output .= "\""._QXZ("Results Detail").":\"\n";