From 24fa986d5ec174cd30527ad07d5b79a1dafe74c4 Mon Sep 17 00:00:00 2001 From: mattf Date: Sat, 18 Nov 2023 21:07:19 +0000 Subject: [PATCH] Updates for agent 3-way press-1 calls feature git-svn-id: svn://192.168.202.10@3778 3d104415-ff17-0410-8863-d5cf3c621b8a --- UPGRADE | 5 ++ agi/agi-3way_press_agent.agi | 37 +++++++++- agi/agi-3way_press_outside.agi | 2 + bin/AST_conf_update.pl | 13 ++++ bin/AST_conf_update_3way.pl | 8 ++ bin/AST_flush_DBqueue.pl | 20 +++++ bin/FastAGI_log.pl | 37 +++++++++- docs/AGENT_3WAY_PRESS-1_CALLS.txt | 117 ++++++++++++++++++++++++++++++ docs/CALLER_ID_NAME_CODES.txt | 3 +- 9 files changed, 239 insertions(+), 3 deletions(-) create mode 100644 docs/AGENT_3WAY_PRESS-1_CALLS.txt diff --git a/UPGRADE b/UPGRADE index c818d9db..72974461 100644 --- a/UPGRADE +++ b/UPGRADE @@ -826,6 +826,11 @@ OTHER CHANGES: 233. Added the "lead_dearchive" Non-Agent API function, to move archived leads back to the active list table. +234. Added the ability for agents to place 3way calls and require that the + called-party press 1 before the call is bridged to the agent and + customer. For more information, see the AGENT_3WAY_PRESS-1_CALLS.txt + document. + diff --git a/agi/agi-3way_press_agent.agi b/agi/agi-3way_press_agent.agi index 96f0e4fd..be2913f8 100644 --- a/agi/agi-3way_press_agent.agi +++ b/agi/agi-3way_press_agent.agi @@ -27,6 +27,7 @@ # # changes: # 231113-2016 - First Build +# 231118-1600 - Added endings for HUNGUP and TIMEOUT # $script = 'agi-3way_press_agent.agi'; @@ -454,7 +455,8 @@ while ($wait_loop < 100) if ($AGILOG) {$agi_string = "-- vicidial_3way_press_log reserved UPDATE: |$affected_rowsA|$stmtA|"; &agi_output;} ### Update vicidial_conferences to leave_3way - # $stmtA="UPDATE vicidial_conferences set leave_3way='1', leave_3way_datetime=NOW(), extension='3WAY_$CALLuser' where server_ip='$CALLserver_ip' and conf_exten='$CALLconf_exten';"; + # $Ttimeout='Xtimeout9'; + # $stmtA="UPDATE vicidial_conferences set leave_3way='1', leave_3way_datetime=NOW(), extension='3WAY_$CALLuser$Ttimeout' where server_ip='$CALLserver_ip' and conf_exten='$CALLconf_exten';"; # if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} # $affected_rowsD = $dbhA->do($stmtA); # if ($AGILOG) {$agi_string = "-- vicidial_conferences UPDATE: |$affected_rowsD|$stmtA|"; &agi_output;} @@ -492,11 +494,44 @@ while ($wait_loop < 100) exit; } + if ($CALLstatus =~ /HUNGUP/) + { + ### Delete the call in vicidial_3way_press_live + $stmtA="DELETE from vicidial_3way_press_live where call_3way_id='$VIDqueryCID';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rowsE = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live hungup DELETE: |$affected_rowsE|$stmtA|"; &agi_output;} + + if ($AGILOG) {$agi_string = "3-WAY AGENT TRANSFER HUNGUP: |$CALLuser|$CALLserver_ip|$CALLconf_exten|$calleridname|$VIDqueryCID|"; &agi_output;} + $AGI->stream_file('buzz'); + usleep(1*490*1000); + + exit; + } + $wait_loop++; } +if ($wait_loop >= 100) + { + ### Update the call in vicidial_3way_press_log + $stmtA="UPDATE vicidial_3way_press_log SET session_id_3way='$CALLconf_exten', result=CONCAT(result,'|Timeout: ',NOW()) where call_3way_id='$VIDqueryCID';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rowsA = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- vicidial_3way_press_log timeout UPDATE: |$affected_rowsA|$stmtA|"; &agi_output;} + ### Delete the call in vicidial_3way_press_live + $stmtA="DELETE from vicidial_3way_press_live where call_3way_id='$VIDqueryCID';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rowsE = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live timeout DELETE: |$affected_rowsE|$stmtA|"; &agi_output;} + if ($AGILOG) {$agi_string = "3-WAY AGENT TRANSFER TIMEOUT: |$CALLuser|$CALLserver_ip|$CALLconf_exten|$calleridname|$VIDqueryCID|"; &agi_output;} + $AGI->stream_file('buzz'); + usleep(1*490*1000); + + exit; + } # send call to special extension with lead_id defined and handle_method set to CLOSER diff --git a/agi/agi-3way_press_outside.agi b/agi/agi-3way_press_outside.agi index 01ba7047..2083e95c 100644 --- a/agi/agi-3way_press_outside.agi +++ b/agi/agi-3way_press_outside.agi @@ -444,6 +444,8 @@ if ($stage =~ /accepted/i) if ($AGILOG) {$agi_string = "-- vicidial_3way_press_log transfer UPDATE: |$affected_rowsA|$stmtA|"; &agi_output;} ### Update vicidial_conferences to leave_3way=1 + # $Ttimeout='Xtimeout9'; + # $stmtA="UPDATE vicidial_conferences set leave_3way='1', leave_3way_datetime=NOW(), extension='3WAY_$CALLuser$Ttimeout' where server_ip='$CALLserver_ip' and conf_exten='$CALLconf_exten';"; $stmtA="UPDATE vicidial_conferences set leave_3way='1', leave_3way_datetime=NOW(), extension='3WAY_$CALLuser' where server_ip='$CALLserver_ip' and conf_exten='$CALLconf_exten';"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $affected_rowsD = $dbhA->do($stmtA); diff --git a/bin/AST_conf_update.pl b/bin/AST_conf_update.pl index cc350ff4..472f24c5 100644 --- a/bin/AST_conf_update.pl +++ b/bin/AST_conf_update.pl @@ -22,6 +22,7 @@ # 180420-2302 - Fix for high-volume systems, added varibles to hangup queryCID # 200413-1356 - Fix for \n\n at the end of PING commands causing errors in AMI # 231117-2254 - Added AMI version 5 compatibility +# 231118-1111 - Added override option of up to Xtimeout9 for 3WAY_... leave-3way sessions # # constants @@ -400,6 +401,12 @@ if ($no_vc_3way_check < 1) { $NEWexten[$i] = $PTextensions[$i]; $leave_3waySQL='1'; + if ($PTextensions[$i] =~ /Xtimeout9$/i) {$NEWexten[$i] =~ s/Xtimeout9$/Xtimeout8/gi;} + if ($PTextensions[$i] =~ /Xtimeout8$/i) {$NEWexten[$i] =~ s/Xtimeout8$/Xtimeout7/gi;} + if ($PTextensions[$i] =~ /Xtimeout7$/i) {$NEWexten[$i] =~ s/Xtimeout7$/Xtimeout6/gi;} + if ($PTextensions[$i] =~ /Xtimeout6$/i) {$NEWexten[$i] =~ s/Xtimeout6$/Xtimeout5/gi;} + if ($PTextensions[$i] =~ /Xtimeout5$/i) {$NEWexten[$i] =~ s/Xtimeout5$/Xtimeout4/gi;} + if ($PTextensions[$i] =~ /Xtimeout4$/i) {$NEWexten[$i] =~ s/Xtimeout4$/Xtimeout3/gi;} if ($PTextensions[$i] =~ /Xtimeout3$/i) {$NEWexten[$i] =~ s/Xtimeout3$/Xtimeout2/gi;} if ($PTextensions[$i] =~ /Xtimeout2$/i) {$NEWexten[$i] =~ s/Xtimeout2$/Xtimeout1/gi;} if ($PTextensions[$i] =~ /Xtimeout1$/i) {$NEWexten[$i] = ''; $leave_3waySQL='0';} @@ -612,6 +619,12 @@ if ( !( ( @PTextensions == 1 ) && ( $PTextensions[0] eq '') ) ) else { $NEWexten[$i] = $PTextensions[$i]; + if ($PTextensions[$i] =~ /Xtimeout9$/i) {$NEWexten[$i] =~ s/Xtimeout9$/Xtimeout8/gi;} + if ($PTextensions[$i] =~ /Xtimeout8$/i) {$NEWexten[$i] =~ s/Xtimeout8$/Xtimeout7/gi;} + if ($PTextensions[$i] =~ /Xtimeout7$/i) {$NEWexten[$i] =~ s/Xtimeout7$/Xtimeout6/gi;} + if ($PTextensions[$i] =~ /Xtimeout6$/i) {$NEWexten[$i] =~ s/Xtimeout6$/Xtimeout5/gi;} + if ($PTextensions[$i] =~ /Xtimeout5$/i) {$NEWexten[$i] =~ s/Xtimeout5$/Xtimeout4/gi;} + if ($PTextensions[$i] =~ /Xtimeout4$/i) {$NEWexten[$i] =~ s/Xtimeout4$/Xtimeout3/gi;} if ($PTextensions[$i] =~ /Xtimeout3$/i) {$NEWexten[$i] =~ s/Xtimeout3$/Xtimeout2/gi;} if ($PTextensions[$i] =~ /Xtimeout2$/i) {$NEWexten[$i] =~ s/Xtimeout2$/Xtimeout1/gi;} if ($PTextensions[$i] =~ /Xtimeout1$/i) {$NEWexten[$i] = '';} diff --git a/bin/AST_conf_update_3way.pl b/bin/AST_conf_update_3way.pl index 31987daf..5e4b386e 100644 --- a/bin/AST_conf_update_3way.pl +++ b/bin/AST_conf_update_3way.pl @@ -22,6 +22,7 @@ # 180420-2301 - Fix for high-volume systems, added varibles to hangup queryCID # 200413-1356 - Fix for \n\n at the end of PING commands causing errors in AMI # 231117-2255 - Added AMI version 5 compatibility +# 231118-1110 - Added override option of up to Xtimeout9 for 3WAY_... leave-3way sessions # # constants @@ -405,6 +406,13 @@ while ($loops > $loop_counter) { $NEWexten[$i] = $PTextensions[$i]; $leave_3waySQL='1'; + if ($PTextensions[$i] =~ /Xtimeout9$/i) {$NEWexten[$i] =~ s/Xtimeout9$/Xtimeout8/gi;} + if ($PTextensions[$i] =~ /Xtimeout8$/i) {$NEWexten[$i] =~ s/Xtimeout8$/Xtimeout7/gi;} + if ($PTextensions[$i] =~ /Xtimeout7$/i) {$NEWexten[$i] =~ s/Xtimeout7$/Xtimeout6/gi;} + if ($PTextensions[$i] =~ /Xtimeout6$/i) {$NEWexten[$i] =~ s/Xtimeout6$/Xtimeout5/gi;} + if ($PTextensions[$i] =~ /Xtimeout5$/i) {$NEWexten[$i] =~ s/Xtimeout5$/Xtimeout4/gi;} + if ($PTextensions[$i] =~ /Xtimeout4$/i) {$NEWexten[$i] =~ s/Xtimeout4$/Xtimeout3/gi;} + if ($PTextensions[$i] =~ /Xtimeout3$/i) {$NEWexten[$i] =~ s/Xtimeout3$/Xtimeout2/gi;} if ($PTextensions[$i] =~ /Xtimeout2$/i) {$NEWexten[$i] =~ s/Xtimeout2$/Xtimeout1/gi;} if ($PTextensions[$i] =~ /Xtimeout1$/i) {$NEWexten[$i] = ''; $leave_3waySQL='0';} if ( ($PTextensions[$i] !~ /Xtimeout\d$/i) and (length($PTextensions[$i])> 0) ) {$NEWexten[$i] .= 'Xtimeout2';} diff --git a/bin/AST_flush_DBqueue.pl b/bin/AST_flush_DBqueue.pl index be126e12..a9867799 100644 --- a/bin/AST_flush_DBqueue.pl +++ b/bin/AST_flush_DBqueue.pl @@ -32,6 +32,7 @@ # 191029-1555 - Added flushing of vicidial_agent_vmm_overrides table # 220921-1148 - Added optimize of vicidial_users table # 230414-1622 - Added --reset-stuck-leads option +# 231118-1256 - Added clearing of old vicidial_3way_press_live records # $session_flush=0; @@ -591,6 +592,25 @@ while ($sthArowsSERVERS > $aas) $sthA->finish(); +$stmtA = "DELETE from vicidial_3way_press_live where call_date < '$SQLdate_NEG_sixhour';"; +if($DB){print STDERR "\n|$stmtA|\n";} +if (!$T) { $affected_rows = $dbhA->do($stmtA);} +if (!$Q) {print " - vicidial_3way_press_live flush: $affected_rows rows\n";} + +$stmtA = "OPTIMIZE table vicidial_3way_press_live;"; +if($DB){print STDERR "\n|$stmtA|\n";} +if (!$T) + { + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + @aryA = $sthA->fetchrow_array; + if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";} + $sthA->finish(); + } +if (!$Q) {print " - OPTIMIZE vicidial_3way_press_live \n";} + + if ($session_flush > 0) { $stmtA = "DELETE from vicidial_sessions_recent where call_date < '$SQLdate_NEG_1hour';"; diff --git a/bin/FastAGI_log.pl b/bin/FastAGI_log.pl index f862ff33..e9ed5b58 100644 --- a/bin/FastAGI_log.pl +++ b/bin/FastAGI_log.pl @@ -98,7 +98,8 @@ # 221221-2134 - Added enhanced_disconnect_logging=3 support , issue #1367 # 230120-1557 - Added CAMPDTO dialplan variable for ^DC 3-way agent screen calls # 231116-0846 - Added hopper_hold_inserts option -# +# 231118-1054 - Added hangup processing of 3-way press outside-agent calls +# # defaults for PreFork $VARfastagi_log_min_servers = '3'; @@ -1042,6 +1043,40 @@ sub process_request } ### END log end of real-time blind monitor calls ### + + ### BEGIN log end of 3-way press outside-agent calls ### + if ($callerid =~ /^T\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) + { + $stmtA = "SELECT status from vicidial_3way_press_live where call_3way_id='$callerid';"; + $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; + $sthA->finish(); + $TW_status = $aryA[0]; + + if ($TW_status !~ /HUNGUP/) + { + $stmtA = "UPDATE vicidial_3way_press_live SET status='HUNGUP' where call_3way_id='$callerid';"; + $affected_rowsTWV = $dbhA->do($stmtA); + + $stmtB = "UPDATE vicidial_3way_press_log SET result=CONCAT(result,'|Hungup: ',NOW()) where call_3way_id='$callerid';"; + $affected_rowsTWL = $dbhA->do($stmtB); + + if ($AGILOG) {$agi_string = "3WAY press outside-agent call updated: |$affected_rowsTWV|$affected_rowsTWL|$stmtA|$stmtB|"; &agi_output;} + } + else + { + if ($AGILOG) {$agi_string = "3WAY press outside-agent call NOT updated: |$TW_status|$stmtA|"; &agi_output;} + } + } + if ($AGILOG) {$agi_string = "|$affected_rowsBM|$stmtA|$monitor_start_time|$EPOCHmonitor_start_time|"; &agi_output;} + } + ### END log end of real-time blind monitor calls ### + + ### get uniqueid and start_epoch from the call_log table $CALLunique_id = $unique_id; $stmtA = "SELECT uniqueid,start_epoch,channel,end_epoch,channel_group FROM call_log where uniqueid='$unique_id';"; diff --git a/docs/AGENT_3WAY_PRESS-1_CALLS.txt b/docs/AGENT_3WAY_PRESS-1_CALLS.txt new file mode 100644 index 00000000..a27c7b7b --- /dev/null +++ b/docs/AGENT_3WAY_PRESS-1_CALLS.txt @@ -0,0 +1,117 @@ +Agent 3-way Press-1 Calls DOC Started: 2023-11-13 Updated: 2023-11-18 + + +This document will go over how to set up Agent Screen 3-way calls with outside +users that have to press-1 on their phone to be bridged with the agent and +customer. + +NOTE: This requires svn/trunk revision 3778 or higher!!! + + +What is an Agent Screen 3-way calls with an outside user that has to press-1? + +The purpose of this feature is to allow agents using the Agent Screen the ability to call an outside number as part of a 3-way call and require that the outside called party press 1 on their phone before they will be bridged to the agent and their customer. To make this work, instead of just sending the "phone_number" you want to call by itself, you will need to send a dial-string that has a reserved prefix for this feature (this is "49907"), then you will need to add the dial_prefix you want to use for the call to the outside-agent(for example: '9'), then the phone_code of '1' then the "phone_number" (for this example: '7275551212'), so the resulting dialstring you would want to use would be "49907917275551212", you will also must check the DIAL OVERRIDE checkbox before clicking on the "DIAL WITH CUSTOMER" button for this to work properly. Alternatively, you can use the Agent API's "transfer_conference" function with the phone_number field set to "49907917275551212" and the "dial_override" variable to "YES". + +On the agent side, after placing the 3-way call while waiting for the called-party to answer and press-1, the agent and customer will only hear a quiet hold tone once every 5 seconds until the call is bridged. If the called-party does not press-1 after answering, then the call will time out after 20 seconds(this is configurable in the custom dialplan below), they will hear a quick buzz sound, and the Xfer line will hang up. + +All activity for these calls are logged, with the logs being visible in the Admin Modify Lead page, in the "3-WAY PRESS LOGS FOR THIS LEAD" section. + + + +How do I configure this on my system? + +All that is required is the lines below be added to the System Settings "Custom Dialplan Entry", and the "Reload Dialplan On Servers" option set to '1' before submitting the changes. + + + +SYSTEM SETTINGS DIALPLAN ENTRIES, PUT AT THE BOTTOM OF THE ENTRY!!! : +------------------------------------------------------------------------- + + +; VICIdial agent initation of outside-agent transfer: +exten => _49907.,1,Dial(${TRUNKloop}/499${EXTEN},,to) +exten => _49907.,n,Hangup() +exten => _49949907.,1,Goto(xfer_press_dialplan,${EXTEN:3},1) +exten => _49949907.,n,Hangup() + +; VICIdial outside-agent transfer after initiated by agent: +[xfer_press_dialplan] +exten => s,1,Answer +exten => s,n,NoOp(${call_3way_id}) +exten => s,n,NoOp(${CALLERID(name)}) +exten => s,n,AGI(agi-3way_press_outside.agi,answered) +exten => s,n,Playback(sip-silence) +exten => s,n,Background(outside-sales) +exten => s,n,Background(press-1) +exten => s,n,Background(now) +exten => s,n,WaitExten(20) +exten => s,n,AGI(agi-3way_press_outside.agi,declined) +exten => s,n,Hangup + +exten => 1,1,NoOp(${call_3way_id}) +exten => 1,n,NoOp(${CALLERID(name)}) +exten => 1,n,AGI(agi-3way_press_outside.agi,accepted) +exten => 1,n,Hangup() + +exten => t,1,Playback(buzz) +exten => t,n,Hangup() + +exten => i,1,Playback(buzz) +exten => i,n,Hangup() + +; VICIdial agent initation of outside-agent transfer: +exten => _49907.,1,Answer +exten => _49907.,n,NoOp(${CALLERID(name)}) +exten => _49907.,n,Playback(sip-silence) +exten => _49907.,n,AGI(agi-3way_press_agent.agi,start) +exten => _49907.,n,Hangup + + +------------------------------------------------------------------------- + + + + + +DATABASE CHANGES FOR REFERENCE ONLY!!!!!!!!! + +CREATE TABLE vicidial_3way_press_live ( +call_date DATETIME(6), +caller_code VARCHAR(30) NOT NULL, +call_3way_id VARCHAR(30) NOT NULL, +lead_id INT(9) UNSIGNED, +phone_number VARCHAR(18), +dialstring VARCHAR(28), +outbound_cid VARCHAR(20), +user VARCHAR(20), +session_id VARCHAR(20), +server_ip VARCHAR(15), +session_id_3way VARCHAR(20) default '', +status VARCHAR(40), +index(call_date), +index(caller_code), +index(call_3way_id), +index(lead_id) +) ENGINE=MyISAM; + +CREATE TABLE vicidial_3way_press_log ( +call_date DATETIME(6), +caller_code VARCHAR(30) NOT NULL, +call_3way_id VARCHAR(30) NOT NULL, +lead_id INT(9) UNSIGNED, +phone_number VARCHAR(18), +dialstring VARCHAR(28), +outbound_cid VARCHAR(20), +user VARCHAR(20), +session_id VARCHAR(20), +server_ip VARCHAR(15), +session_id_3way VARCHAR(20) default '', +result TEXT, +index(call_date), +index(caller_code), +index(call_3way_id), +index(lead_id) +) ENGINE=MyISAM; + +CREATE TABLE vicidial_3way_press_log_archive LIKE vicidial_3way_press_log; +CREATE UNIQUE INDEX vdpla on vicidial_3way_press_log_archive (call_date,caller_code,user); diff --git a/docs/CALLER_ID_NAME_CODES.txt b/docs/CALLER_ID_NAME_CODES.txt index 687488d8..e2f523ca 100644 --- a/docs/CALLER_ID_NAME_CODES.txt +++ b/docs/CALLER_ID_NAME_CODES.txt @@ -1,4 +1,4 @@ -CALLER ID NAME CODES DOC Started: 2013-07-15 Updated: 2023-06-07 +CALLER ID NAME CODES DOC Started: 2013-07-15 Updated: 2023-11-18 This document is meant for reference only, and it does not contain all CID name codes possible, but more will be added over time. @@ -39,4 +39,5 @@ E - Inbound Email, tracking only (E0001797980001237995) ACagcW - Noone in session call agent phone (ACagcW15167259066666) AM - Agent mute of recording (AM273955W0001922575W) G - Recording Gateway inbound call (G2010021380000000023) +T - 3-way press outside-agent call (T1180828420014842682) CID - SendCID test page (CID1451019998883112)