Added Agent API pause_code function

git-svn-id: svn://192.168.202.10@2061 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2014-01-26 13:39:53 +00:00
parent b19d24664e
commit dab8f804e9
8 changed files with 164 additions and 21 deletions
+2
View File
@@ -176,6 +176,8 @@ OTHER CHANGES:
29. Added Lists Pass Report
30. Added Agent API pause_code function
+28 -1
View File
@@ -1,4 +1,4 @@
AGENT API DOCUMENT Started: 2008-07-03 Updated: 2012-09-13
AGENT API DOCUMENT Started: 2008-07-03 Updated: 2014-01-26
This document describes the functions of an API(Application Programming Interface)
for the VICIDIAL Agent screen. This functionality will be rather limited at first
@@ -30,6 +30,7 @@ recording - sends a recording start/stop signal or status of agent recording
webserver - display webserver information, very useful for load balanced setups
webphone_url - display the webphone url for the current agent's session
call_agent - send a call to connect the agent to their session
pause_code - set a pause code if the agent is paused
New scripts:
@@ -737,6 +738,32 @@ SUCCESS: call_agent function sent - 6666
--------------------------------------------------------------------------------
pause_code -
DESCRIPTION:
set a pause code for an agent that is paused
VALUES:
value - pause code to set, must be 6 characters or less
NOTES:
this function will not work if the agent is not paused
EXAMPLE URLS:
http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=pause_code&value=BREAK
RESPONSES:
ERROR: no user found - 6666
ERROR: agent_user is not logged in - 6666
ERROR: pause_code not valid - 6666|JUMPING
ERROR: pause_code error - agent is not paused - 6666
SUCCESS: pause_code function sent - 6666
+3 -1
View File
@@ -408,6 +408,8 @@ last_inbound_call_time DATETIME,
last_inbound_call_finish DATETIME,
campaign_grade TINYINT(2) UNSIGNED default '1',
external_recording VARCHAR(20) default '',
external_pause_code VARCHAR(6) default '',
pause_code VARCHAR(6) default '',
index (random_id),
index (last_call_time),
index (last_update_time),
@@ -3247,4 +3249,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version';
UPDATE system_settings set vdc_agent_api_active='1';
UPDATE system_settings SET db_schema_version='1364',db_schema_update_date=NOW();
UPDATE system_settings SET db_schema_version='1365',db_schema_update_date=NOW();
+5
View File
@@ -173,3 +173,8 @@ UPDATE system_settings SET db_schema_version='1363',db_schema_update_date=NOW()
CREATE INDEX vlecc on vicidial_log_extended (caller_code);
UPDATE system_settings SET db_schema_version='1364',db_schema_update_date=NOW() where db_schema_version < 1364;
ALTER TABLE vicidial_live_agents ADD external_pause_code VARCHAR(6) default '';
ALTER TABLE vicidial_live_agents ADD pause_code VARCHAR(6) default '';
UPDATE system_settings SET db_schema_version='1365',db_schema_update_date=NOW() where db_schema_version < 1365;
+87 -2
View File
@@ -69,10 +69,11 @@
# 130705-1526 - Added optional encrypted passwords compatibility
# 130802-1000 - Changed to PHP mysqli functions
# 140107-2140 - Added webserver and url logging
# 140126-0701 - Added pause_code function
#
$version = '2.8-35';
$build = '140107-2140';
$version = '2.8-36';
$build = '140126-0701';
$startMS = microtime();
@@ -3061,6 +3062,90 @@ if ($function == 'transfer_conference')
################################################################################
### BEGIN - pause_code - set a pause code for an agent that is already paused
################################################################################
if ($function == 'pause_code')
{
if ( (strlen($value)<1) or (strlen($value)>6) or ( (strlen($agent_user)<1) and (strlen($alt_user)<2) ) )
{
$result = 'ERROR';
$result_reason = "pause_code 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 (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 = 'ERROR';
$result_reason = "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)
{
$stmt = "select status from vicidial_live_agents where user='$agent_user' and status='PAUSED';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$rl_ct = mysqli_num_rows($rslt);
if ($rl_ct > 0)
{
$pause_code_string = preg_replace("/\|/","','",$agent_login_call);
$stmt="UPDATE vicidial_live_agents SET external_pause_code='$value' where user='$agent_user';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
$result = 'SUCCESS';
$result_reason = "pause_code function sent";
echo "$result: $result_reason - $agent_user\n";
$data = "$epoch";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
else
{
$result = 'ERROR';
$result_reason = "pause_code error - agent is not paused";
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 = 'ERROR';
$result_reason = "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 - pause_code
################################################################################
################################################################################
### BEGIN - optional "close window" link
################################################################################
+7 -5
View File
@@ -1,7 +1,7 @@
<?php
# conf_exten_check.php version 2.8
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed purely to send whether the meetme conference has live channels connected and which they are
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
@@ -61,10 +61,11 @@
# 130603-2218 - Added login lockout for 15 minutes after 10 failed logins, and other security fixes
# 130705-1524 - Added optional encrypted passwords compatibility
# 130802-1015 - Changed to use PHP mysqli functions
# 140126-0659 - Added external_pause_code function
#
$version = '2.8-36';
$build = '130802-1015';
$version = '2.8-37';
$build = '140126-0659';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=39;
$one_mysql_log=0;
@@ -449,7 +450,7 @@ if ($ACTION == 'refresh')
}
### grab the API hangup and API dispo fields in vicidial_live_agents
$stmt="SELECT external_hangup,external_status,external_pause,external_dial,external_update_fields,external_update_fields_data,external_timer_action,external_timer_action_message,external_timer_action_seconds,external_dtmf,external_transferconf,external_park,external_timer_action_destination,external_recording from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
$stmt="SELECT external_hangup,external_status,external_pause,external_dial,external_update_fields,external_update_fields_data,external_timer_action,external_timer_action_message,external_timer_action_seconds,external_dtmf,external_transferconf,external_park,external_timer_action_destination,external_recording,external_pause_code from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03010',$user,$server_ip,$session_name,$one_mysql_log);}
@@ -468,6 +469,7 @@ if ($ACTION == 'refresh')
$external_park = $row[11];
$timer_action_destination = $row[12];
$external_recording = $row[13];
$external_pause_code = $row[14];
$MDQ_count=0;
if ( ($api_manual_dial=='QUEUE') or ($api_manual_dial=='QUEUE_AND_AUTOCALL') )
@@ -688,7 +690,7 @@ if ($ACTION == 'refresh')
$external_pause='';
}
echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . '|APIdtmf: ' . $external_dtmf . '|APItransferconf: ' . $external_transferconf . '|APIpark: ' . $external_park . '|APITimerDestination: ' . $timer_action_destination . '|APIManualDialQueue: ' . $MDQ_count . '|APIRecording: ' . $external_recording . "\n";
echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . '|DEADcall: ' . $DEADcustomer . '|InGroupChange: ' . $InGroupChangeDetails . '|APIFields: ' . $external_update_fields . '|APIFieldsData: ' . $external_update_fields_data . '|APITimerAction: ' . $timer_action . '|APITimerMessage: ' . $timer_action_message . '|APITimerSeconds: ' . $timer_action_seconds . '|APIdtmf: ' . $external_dtmf . '|APItransferconf: ' . $external_transferconf . '|APIpark: ' . $external_park . '|APITimerDestination: ' . $timer_action_destination . '|APIManualDialQueue: ' . $MDQ_count . '|APIRecording: ' . $external_recording . '|APIPaUseCodE: ' . $external_pause_code . "\n";
if (strlen($timer_action) > 3)
{
+19 -9
View File
@@ -341,12 +341,13 @@
# 131209-1522 - Added called_count to log and closer log tables, fixed unanswered call logging issue
# 131210-1400 - Fixed manual dial CID choice issue with AC-CID settings
# 140124-1209 - Added error catching for start/dispo call URL logging
# 140126-0727 - Added pause_code API code
#
$version = '2.8-238';
$build = '140124-1209';
$version = '2.8-239';
$build = '140126-0727';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=533;
$mysql_log_count=535;
$one_mysql_log=0;
require_once("dbconnect_mysqli.php");
@@ -1466,7 +1467,7 @@ if ($ACTION == 'manDiaLnextCaLL')
##### gather local call time setting from campaign
$stmt="SELECT phone_number FROM vicidial_list where lead_id='$lead_id';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00534',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$lid_chk_ct = mysqli_num_rows($rslt);
if ($lid_chk_ct > 0)
@@ -2694,7 +2695,7 @@ if ($ACTION == 'manDiaLnextCaLL')
}
### update the agent status to INCALL in vicidial_live_agents
$stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME' where user='$user' and server_ip='$server_ip';";
$stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME',pause_code='' where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00035',$user,$server_ip,$session_name,$one_mysql_log);}
@@ -3407,7 +3408,7 @@ if ($ACTION == 'manDiaLonly')
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00045',$user,$server_ip,$session_name,$one_mysql_log);}
### update the agent status to INCALL in vicidial_live_agents
$stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME' where user='$user' and server_ip='$server_ip';";
$stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME',pause_code='' where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00046',$user,$server_ip,$session_name,$one_mysql_log);}
@@ -5119,7 +5120,7 @@ if ($ACTION == 'VDADcheckINCOMING')
$calls_today++;
### update the agent status to INCALL in vicidial_live_agents
$stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME' where user='$user' and server_ip='$server_ip';";
$stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME',pause_code='' where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00106',$user,$server_ip,$session_name,$one_mysql_log);}
@@ -6396,7 +6397,7 @@ if ($ACTION == 'VDADcheckINCOMINGemail')
$calls_today++;
### update the agent status to INCALL in vicidial_live_agents
$stmt = "UPDATE vicidial_live_agents set status='INCALL',comments='EMAIL',last_call_time='$NOW_TIME',lead_id='$lead_id',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME' where user='$user' and server_ip='$server_ip';";
$stmt = "UPDATE vicidial_live_agents set status='INCALL',comments='EMAIL',last_call_time='$NOW_TIME',lead_id='$lead_id',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME',pause_code='' where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00490',$user,$server_ip,$session_name,$one_mysql_log);}
@@ -9856,10 +9857,13 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') )
else
{
$vla_autodialSQL='';
$vla_pausecodeSQL='';
if (preg_match('/INBOUND_MAN/',$dial_method))
{$vla_autodialSQL = ",outbound_autodial='N'";}
if ($ACTION == 'VDADready')
{$vla_pausecodeSQL = ",pause_code='',external_pause_code=''";}
$random = (rand(1000000, 9999999) + 10000000);
$stmt="UPDATE vicidial_live_agents set uniqueid=0,callerid='',channel='', random_id='$random',comments='',last_state_change='$NOW_TIME' $vla_autodialSQL where user='$user' and server_ip='$server_ip';";
$stmt="UPDATE vicidial_live_agents set uniqueid=0,callerid='',channel='', random_id='$random',comments='',last_state_change='$NOW_TIME' $vla_autodialSQL $vla_pausecodeSQL where user='$user' and server_ip='$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00165',$user,$server_ip,$session_name,$one_mysql_log);}
@@ -10118,6 +10122,12 @@ if ($ACTION == 'PauseCodeSubmit')
}
else
{
$stmt="UPDATE vicidial_live_agents SET pause_code='$status',external_pause_code='' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00535',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$VLAPCaffected_rows_update = mysqli_affected_rows($link);
### if this is the first pause code entry in a pause session, simply update and log to queue_log
if ($stage < 1)
{
+13 -3
View File
@@ -417,10 +417,11 @@
# 131209-1604 - Addded called_count logging
# 131210-1354 - Fixed manual dial CID choice issue with AC-CID settings
# 140107-2034 - Added webserver/url login logging
# 140126-0741 - Added pause code API function
#
$version = '2.8-386c';
$build = '140107-2034';
$version = '2.8-387c';
$build = '140126-0741';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=79;
$one_mysql_log=0;
@@ -2780,7 +2781,7 @@ else
echo "<!-- campaign is set to auto_dial_level: $auto_dial_level -->\n";
$closer_chooser_string='';
$stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level,campaign_weight,calls_today,last_state_change,outbound_autodial,manager_ingroup_set,on_hook_ring_time,on_hook_agent,last_inbound_call_time,last_inbound_call_finish,campaign_grade) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level','$campaign_weight','$calls_today','$NOW_TIME','Y','N','$phone_ring_timeout','$on_hook_agent','$NOW_TIME','$NOW_TIME','$campaign_grade');";
$stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level,campaign_weight,calls_today,last_state_change,outbound_autodial,manager_ingroup_set,on_hook_ring_time,on_hook_agent,last_inbound_call_time,last_inbound_call_finish,campaign_grade,pause_code) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level','$campaign_weight','$calls_today','$NOW_TIME','Y','N','$phone_ring_timeout','$on_hook_agent','$NOW_TIME','$NOW_TIME','$campaign_grade','LOGIN');";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01044',$VD_login,$server_ip,$session_name,$one_mysql_log);}
@@ -4681,6 +4682,8 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
api_timer_action_destination = APITimerDestination_array[1];
var APIRecording_array = check_time_array[25].split("APIRecording: ");
var api_recording = APIRecording_array[1];
var APIPauseCode_array = check_time_array[26].split("APIPaUseCodE: ");
var api_pause_code = APIPauseCode_array[1];
var APIdtmf_array = check_time_array[20].split("APIdtmf: ");
api_dtmf = APIdtmf_array[1];
var APItransfercond_array = check_time_array[21].split("APItransferconf: ");
@@ -4695,6 +4698,13 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
var APIpark_array = check_time_array[22].split("APIpark: ");
api_parkcustomer = APIpark_array[1];
if (api_pause_code.length > 0)
{
if (VDRP_stage == 'PAUSED')
{
PauseCodeSelect_submit(api_pause_code);
}
}
if (api_recording=='START')
{
conf_send_recording('MonitorConf', session_id,'','1');