Added CLI flags for timeout and outside-agent dial timeout in the 3way-press-agent scripts

git-svn-id: svn://192.168.202.10@3800 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2024-01-17 05:26:50 +00:00
parent 3e4a361310
commit 4561fcf68a
3 changed files with 59 additions and 14 deletions
+31 -8
View File
@@ -19,9 +19,13 @@
#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)
#exten => _49907.,n,AGI(agi-3way_press_agent.agi,start---50---30)
#exten => _49907.,n,Hangup
#
# The CLI flags for the 'agi-3way_press_agent.agi' script above are:
# - stage = 'start' is the only value for this variable
# - 3way agent timeout = number of seconds after launching 3way outside-agent calls before this script times out
# - 3way dial timeout = the Asterisk Dial() timeout for the 3way outside-agent calls
#
# Copyright (C) 2024 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
@@ -30,10 +34,11 @@
# 231118-1600 - Added endings for HUNGUP and TIMEOUT
# 231227-1428 - Added multi-phone ability
# 240114-0942 - Added agent_heartbeat
# 240116-2110 - Added CLI flags for timeout and outside-agent dial timeout
#
$script = 'agi-3way_press_agent.agi';
$build = '240114-0942';
$build = '240116-2110';
$at='@';
$S='*';
@@ -41,6 +46,8 @@ $mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=272;
$one_mysql_log=0;
$MT[0]='';
$timeout=100;
$Local_dial_timeout=80;
$now_date_epoch = time();
@@ -183,7 +190,21 @@ if (length($ARGV[0])>1)
### list of command-line array arguments:
@ARGV_vars = split(/---/, $ARGV[0]);
$stage = $ARGV_vars[0];
$stage = $ARGV_vars[0];
$CLI_timeout = $ARGV_vars[1];
$CLI_dial_timeout = $ARGV_vars[2];
$CLI_timeout =~ s/\D//gi;
if (length($CLI_timeout) > 0)
{
if ($AGILOG) {$agi_string = " Timeout CLI override: $timeout -> $CLI_timeout"; &agi_output;}
$timeout = $CLI_timeout;
}
$CLI_dial_timeout =~ s/\D//gi;
if (length($CLI_dial_timeout) > 0)
{
if ($AGILOG) {$agi_string = " Dial Timeout CLI override: $Local_dial_timeout -> $CLI_dial_timeout"; &agi_output;}
$Local_dial_timeout = $CLI_dial_timeout;
}
}
$|=1;
@@ -399,6 +420,7 @@ if ( ($CALLphone_numbers_ct > 0) && (length($CALLphone_numbers) > 4) )
$vp=0;
$temp_phone_length = (length($CALLphone_numbers_ARY[$vp]) * -1);
$temp_prefix_code = substr($dialstring,0,$temp_phone_length);
$Local_dial_timeout = ($Local_dial_timeout * 1000);
while ($vp < $CALLphone_numbers_ct)
{
$VIDqueryCID = "T$CIDdateD$vp$PADlead_id";
@@ -419,7 +441,7 @@ if ( ($CALLphone_numbers_ct > 0) && (length($CALLphone_numbers) > 4) )
if ($AGILOG) {$agi_string = "-- vicidial_3way_press_log LOG INSERT: |$affected_rowsB|$stmtA|"; &agi_output;}
### Insert the outside-agent call into vicidial_manager
$stmtA="INSERT INTO vicidial_manager values('','',NOW(),'NEW','N','$CALLserver_ip','','Originate','$VIDqueryCID','Channel: Local/$temp_prefix_code$CALLphone_numbers_ARY[$vp]$CALLcontext','Context: xfer_press_dialplan','Exten: s','Priority: 1','Callerid: $newcallerid','Variable: __lead_id=$lead_id','','','','');";
$stmtA="INSERT INTO vicidial_manager values('','',NOW(),'NEW','N','$CALLserver_ip','','Originate','$VIDqueryCID','Channel: Local/$temp_prefix_code$CALLphone_numbers_ARY[$vp]$CALLcontext','Context: xfer_press_dialplan','Exten: s','Priority: 1','Callerid: $newcallerid','Timeout: $Local_dial_timeout','Variable: __lead_id=$lead_id','','','');";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rowsG = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- vicidial_manager INSERT: |$affected_rowsG|$stmtA|"; &agi_output;}
@@ -435,6 +457,7 @@ else
$newcallerid = "\"$VIDqueryCID <$original_cid>\"";
$CALLcontext = '@default';
$allCIDs .= "$VIDqueryCID|";
$Local_dial_timeout = ($Local_dial_timeout * 1000);
### 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',agent_heartbeat=NOW();";
@@ -449,7 +472,7 @@ else
if ($AGILOG) {$agi_string = "-- vicidial_3way_press_log LOG INSERT: |$affected_rowsB|$stmtA|"; &agi_output;}
### Insert the outside-agent call into vicidial_manager
$stmtA="INSERT INTO vicidial_manager values('','',NOW(),'NEW','N','$CALLserver_ip','','Originate','$VIDqueryCID','Channel: Local/$dialstring$CALLcontext','Context: xfer_press_dialplan','Exten: s','Priority: 1','Callerid: $newcallerid','Variable: __lead_id=$lead_id','','','','');";
$stmtA="INSERT INTO vicidial_manager values('','',NOW(),'NEW','N','$CALLserver_ip','','Originate','$VIDqueryCID','Channel: Local/$dialstring$CALLcontext','Context: xfer_press_dialplan','Exten: s','Priority: 1','Callerid: $newcallerid','Timeout: $Local_dial_timeout','Variable: __lead_id=$lead_id','','','');";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rowsG = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- vicidial_manager INSERT: |$affected_rowsG|$stmtA|"; &agi_output;}
@@ -464,7 +487,7 @@ $allCIDs =~ s/\|$//gi;
$allCIDs =~ s/\|/','/gi;
$wait_loop=0;
while ($wait_loop < 100)
while ($wait_loop < $timeout)
{
usleep(1*990*1000);
if ($wait_loop =~ /0$|5$/)
@@ -476,7 +499,7 @@ while ($wait_loop < 100)
$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;}
if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live agent_heartbeat UPDATE $wait_loop: |$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;";
@@ -670,7 +693,7 @@ while ($wait_loop < 100)
$wait_loop++;
}
if ($wait_loop >= 100)
if ($wait_loop >= $timeout)
{
### 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 IN('$allCIDs');";
+12 -3
View File
@@ -25,7 +25,7 @@
#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,AGI(agi-3way_press_outside.agi,answered---20)
#exten => s,n,Playback(sip-silence)
#exten => s,n,Wait(1)
#exten => s,n,Background(outside-sales)
@@ -54,10 +54,11 @@
# 231227-1427 - Added multi-phone ability
# 240108-1503 - Added call_channel and call_transfer logging
# 240114-0946 - Added check of agent_heartbeat
# 240116-2109 - Added CLI flag for timeout
#
$script = 'agi-3way_press_outside.agi';
$build = '240114-0946';
$build = '240116-2109';
$at='@';
$S='*';
@@ -65,6 +66,7 @@ $mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=272;
$one_mysql_log=0;
$MT[0]='';
$timeout=100;
$now_date_epoch = time();
@@ -207,6 +209,13 @@ if (length($ARGV[0])>1)
@ARGV_vars = split(/---/, $ARGV[0]);
$stage = $ARGV_vars[0];
$CLI_timeout = $ARGV_vars[1];
$CLI_timeout =~ s/\D//gi;
if (length($CLI_timeout) > 0)
{
if ($AGILOG) {$agi_string = " Timeout CLI override: $timeout -> $CLI_timeout"; &agi_output;}
$timeout = $CLI_timeout;
}
}
$|=1;
@@ -475,7 +484,7 @@ if ($stage =~ /accepted/i)
$CALLstatus='';
$CALLconf_exten='';
$wait_loop=0;
while ($wait_loop < 100)
while ($wait_loop < $timeout)
{
usleep(1*990*1000);
if ($wait_loop =~ /0$|5$/)
@@ -1,4 +1,4 @@
Agent 3-way Press-1 Calls DOC Started: 2023-11-13 Updated: 2024-01-14
Agent 3-way Press-1 Calls DOC Started: 2023-11-13 Updated: 2024-01-17
This document will go over how to set up Agent Screen 3-way calls with outside
@@ -67,6 +67,19 @@ You can actually change the prompts to the outside-users to anything in the Audi
Are there any definable timeouts for these processes?
There are actually 4 separate timeouts for this process that you can define in the custom dialplan entry in System Settings:
1. The VICIdial agent timeout: This is the total time from the initiation of the 3way call process, this includes the outside-agent dial time, and the prompting of the outside-agent and waiting for their response. If you want 30 seconds of dial time and 20 seconds waiting for a response, then you would want to set this to '50'.
2. The 3way call dial timeout: This is the outside-agent call Dial() timeout, how long the system will wait without receiving an Answer signal before hanging up the call. Default is '80', but I've set this to '30' in the example below.
3. The outside-agent prompt timeout: This is the amount of time waiting for the outside-agent to press '1' after the prompt finishes, default for this is '20'
4. The outside-agent acceptance timeout: This is only the time after the outside-agent presses '1' and is waiting for transfer to the customer/agent session in most cases, this doesn't need to be any higher than '10'.
SYSTEM SETTINGS DIALPLAN ENTRIES, PUT AT THE BOTTOM OF THE ENTRY!!! :
@@ -95,7 +108,7 @@ 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,AGI(agi-3way_press_outside.agi,accepted---10)
exten => 1,n,Hangup()
exten => t,1,Playback(buzz)
@@ -108,7 +121,7 @@ exten => i,n,Hangup()
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,AGI(agi-3way_press_agent.agi,start---50---30)
exten => _49907.,n,Hangup