Added new Agent API function audio_playback to play audio files from the audio

store in an active agent session. See AGENT_API.txt doc for more info

git-svn-id: svn://192.168.202.10@2131 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2014-06-19 21:00:35 +00:00
parent d8bf53e43f
commit 3d9d78e0b1
8 changed files with 311 additions and 10 deletions
+2 -1
View File
@@ -56,7 +56,8 @@ OTHER CHANGES:
1. Added User setting for Wrapup Seconds Override
2. Added new Agent API function audio_playback to play audio files from the audio
store in an active agent session. See AGENT_API.txt doc for more info.
+64 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# ADMIN_keepalive_ALL.pl version 2.8
# ADMIN_keepalive_ALL.pl version 2.10
#
# Designed to keep the astGUIclient processes alive and check every minute
# Replaces all other ADMIN_keepalive scripts
@@ -93,9 +93,10 @@
# 140126-1153 - Added VMAIL_NO_INST option dialplan generation
# 140126-2252 - Added voicemail_instructions option for phones
# 140214-1519 - Added reload_timestamp value to conf files
# 140619-1001 - Added new ASTplay loop IAX trunk
#
$build = '140214-1519';
$build = '140619-1001';
$DB=0; # Debug flag
@@ -1609,9 +1610,11 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r
$ext .= "TRUNKloop = IAX2/ASTloop:$self_conf_secret\@127.0.0.1:40569\n";
$ext .= "TRUNKblind = IAX2/ASTblind:$self_conf_secret\@127.0.0.1:41569\n";
$ext .= "TRUNKplay = IAX2/ASTplay:$self_conf_secret\@127.0.0.1:42569\n";
$iax .= "register => ASTloop:$self_conf_secret\@127.0.0.1:40569\n";
$iax .= "register => ASTblind:$self_conf_secret\@127.0.0.1:41569\n";
$iax .= "register => ASTplay:$self_conf_secret\@127.0.0.1:42569\n";
$Lext = "\n";
$Lext .= "; Local Server: $server_ip\n";
@@ -1619,6 +1622,51 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r
$Lext .= "exten => _$VARremDIALstr*.,2,Hangup()\n";
$Lext .= "exten => _**$VARremDIALstr*.,1,Goto(default,\${EXTEN:18},1)\n";
$Lext .= "exten => _**$VARremDIALstr*.,2,Hangup()\n";
$Lext = "\n";
%ast_ver_str = parse_asterisk_version($asterisk_version);
if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 6))
{
$Lext .= "; Agent session audio playback meetme entry\n";
$Lext .= "exten => _473782178600XXX,1,Answer\n";
$Lext .= "exten => _473782178600XXX,n,Meetme(\${EXTEN:8},Fq)\n";
$Lext .= "exten => _473782178600XXX,n,Hangup()\n";
$Lext .= "; Agent session audio playback loop\n";
$Lext .= "exten => _473782168600XXX,1,Dial(\${TRUNKplay}/47378217\${EXTEN:8},5,To)\n";
$Lext .= "exten => _473782168600XXX,n,Hangup()\n";
$Lext .= "; Agent session audio playback extension\n";
$Lext .= "exten => 473782158521111,1,Answer\n";
$Lext .= "exten => 473782158521111,n,ControlPlayback(\${CALLERID(name)}|99999|0|1|2|3|4)\n";
$Lext .= "exten => 473782158521111,n,Hangup()\n";
$Lext .= "; SendDTMF to playback channel to control it\n";
$Lext .= "exten => _473782148521111.,1,Answer\n";
$Lext .= "exten => _473782148521111.,n,SendDTMF(\${CALLERID(num)}|250|250|IAX2/ASTplay-\${EXTEN:15})\n";
$Lext .= "exten => _473782148521111.,n,Hangup()\n";
$Lext .= "; Silent wait channel for DTMFsend\n";
$Lext .= "exten => 473782138521111,1,Answer\n";
$Lext .= "exten => 473782138521111,n,Wait(5)\n";
$Lext .= "exten => 473782138521111,n,Hangup()\n";
}
else
{
$Lext .= "; Agent session audio playback meetme entry\n";
$Lext .= "exten => _473782178600XXX,1,Meetme(\${EXTEN:8},q)\n";
$Lext .= "exten => _473782178600XXX,n,Hangup()\n";
$Lext .= "; Agent session audio playback loop\n";
$Lext .= "exten => _473782168600XXX,1,Dial(\${TRUNKplay}/47378217\${EXTEN:8},5,To)\n";
$Lext .= "exten => _473782168600XXX,n,Hangup()\n";
$Lext .= "; Agent session audio playback extension\n";
$Lext .= "exten => 473782158521111,1,Answer\n";
$Lext .= "exten => 473782158521111,n,ControlPlayback(\${CALLERID(name)},99999,0,1,2,3,4)\n";
$Lext .= "exten => 473782158521111,n,Hangup()\n";
$Lext .= "; SendDTMF to playback channel to control it\n";
$Lext .= "exten => _473782148521111.,1,Answer\n";
$Lext .= "exten => _473782148521111.,n,SendDTMF(\${CALLERID(num)},250,250,IAX2/ASTplay-\${EXTEN:15})\n";
$Lext .= "exten => _473782148521111.,n,Hangup()\n";
$Lext .= "; Silent wait channel for DTMFsend\n";
$Lext .= "exten => 473782138521111,1,Answer\n";
$Lext .= "exten => 473782138521111,n,Wait(5)\n";
$Lext .= "exten => 473782138521111,n,Hangup()\n";
}
$Liax .= "\n";
$Liax .= "[ASTloop]\n";
@@ -1648,6 +1696,20 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r
$Liax .= "allow=ulaw\n";
$Liax .= "qualify=yes\n";
$Liax .= "\n";
$Liax .= "[ASTplay]\n";
$Liax .= "accountcode=ASTplay\n";
$Liax .= "secret=$self_conf_secret\n";
$Liax .= "type=friend\n";
$Liax .= "requirecalltoken=no\n";
$Liax .= "context=default\n";
$Liax .= "auth=plaintext\n";
$Liax .= "host=dynamic\n";
$Liax .= "permit=0.0.0.0/0.0.0.0\n";
$Liax .= "disallow=all\n";
$Liax .= "allow=ulaw\n";
$Liax .= "qualify=yes\n";
##### Get the server_id for this server's server_ip #####
$stmtA = "SELECT server_id,vicidial_recording_limit FROM servers where server_ip='$server_ip';";
+48 -1
View File
@@ -1,4 +1,4 @@
AGENT API DOCUMENT Started: 2008-07-03 Updated: 2014-04-03
AGENT API DOCUMENT Started: 2008-07-03 Updated: 2014-06-19
This document describes the functions of an API(Application Programming Interface)
for the VICIDIAL Agent screen. This functionality will be rather limited at first
@@ -32,6 +32,7 @@ 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
audio_playback - basic play/pause/resume/stop/restart audio in agent session
New scripts:
@@ -776,6 +777,52 @@ SUCCESS: call_agent function sent - 6666
--------------------------------------------------------------------------------
audio_playback -
DESCRIPTION:
Basic play/stop/pause/resume/restart audio in agent session
NOTE: PAUSE/RESUME/RESTART features only work with Asterisk 1.8 and higher
(In Asterisk versions earlier than 1.8 you can replicate RESTART using PLAY and dial_override=Y)
VALUES:
stage -
REQUIRED, choices are below:
PLAY - starts playing of new audio file in agent session
STOP - kills playback of audio in agent session
PAUSE - pauses playing of audio
RESUME - resumes playing of audio after pause
RESTART - restarts playback at beginning of audio
value -
REQUIRED for stage of 'PLAY', name of audio file in audio store to play, must NOT have extension
dial_override -
OPTIONAL, (Y or N), default is N. Allows you to PLAY without issuing a STOP to a currently playing audio file
EXAMPLE URLS:
http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=audio_playback&value=ss-noservice&stage=PLAY
http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=audio_playback&stage=STOP
http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=audio_playback&stage=PAUSE
http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=audio_playback&stage=RESUME
http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=audio_playback&stage=RESTART
http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=audio_playback&value=ss-noservice&stage=PLAY&dial_override=Y
RESPONSES:
ERROR: no user found - 6666
ERROR: agent_user is not logged in - PLAY|6666
ERROR: audio_playback not valid - ss-noservice|PLAY|6666
ERROR: audio_playback error - entry is empty - PLAY|6666
ERROR: audio_playback error - no session data - PLAY|6666
ERROR: audio_playback error - no audio playing in agent session - 8600051|10.10.10.15|PAUSE|6666
ERROR: audio_playback error - audio already playing in agent session - 8600051|10.10.10.15|PLAY|6666
NOTICE: audio_playback previous playback stopped - PLAY|Y|6666
SUCCESS: audio_playback function sent - ss-noservice|PLAY|6666
--------------------------------------------------------------------------------
pause_code -
+4
View File
@@ -12,6 +12,9 @@
#
# Thanks to Rachad ALAO (ralao@venus.org) for writing ip_relay
#
# Changes:
# 140619-0954 - Added new port 42569 for playback loops
#
case "$1" in
@@ -21,6 +24,7 @@ case "$1" in
ip_relay 40569 127.0.0.1 4569 9999999 &
ip_relay 41569 127.0.0.1 4569 9999999 &
ip_relay 42569 127.0.0.1 4569 9999999 &
echo "done "
echo
+6 -3
View File
@@ -1,8 +1,8 @@
#!/usr/bin/perl
# install.pl version 2.8
# install.pl version 2.10
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
@@ -34,6 +34,7 @@
# 130805-0818 - Added support for mysqli
# 130902-1149 - Small fix for mysqli support
# 131121-1643 - Added robots.txt file to all web directories
# 140619-0958 - Added instructions for new ASTplay IAX loop trunk
#
############################################
@@ -752,10 +753,12 @@ if (length($ARGV[0])>1)
$ext = "\nAdd the following lines to your extensions.conf file:\n";
$ext .= "TRUNKloop = IAX2/ASTloop:test\@127.0.0.1:40569\n";
$ext .= "TRUNKblind = IAX2/ASTblind:test\@127.0.0.1:41569\n";
$ext .= "TRUNKplay = IAX2/ASTblind:test\@127.0.0.1:42569\n";
$iax = "\nAdd the following lines to your iax.conf file:\n";
$iax .= "register => ASTloop:test\@127.0.0.1:40569\n";
$iax .= "register => ASTblind:test\@127.0.0.1:41569\n";
$iax .= "register => ASTplay:test\@127.0.0.1:42569\n";
$Lext = "\n";
$Lext .= "; Local Server: $server_ip\n";
@@ -2509,7 +2512,7 @@ if ($WEBONLY < 1)
`ln -s $PATHhome/ip_relay/ip_relay_linux_i386 /usr/bin/ip_relay`;
`ln -s $PATHhome/ip_relay/ip_relay_linux_i386 /usr/local/bin/ip_relay`;
print "Starting ip_relay port forwarding for IAX on 40569 and 41569\n";
print "Starting ip_relay port forwarding for IAX on 40569, 41569 and 42569\n";
`$PATHhome/ip_relay/relay_control start 2>/dev/null 1>&2`;
}
if ($NOWEB < 1)
@@ -1,6 +1,7 @@
############################################################ ADMIN
Wrap Seconds Override||
If this setting is set to a number 0 or greater, then it will override the Campaign setting for Wrapup Seconds. This is a setting that is only refreshed in the agent interface at agent login time. Default is -1 for disabled||
This setting also limits the amount of time a 3-way call that has been left by an agent will stay up before it is terminated||
########################## CHANGES TO EXISTING PHRASES IN ADMIN TRANSLATION
+185 -2
View File
@@ -74,10 +74,11 @@
# 140301-2046 - Added options to dial next number and search for lead phone number
# 140403-1738 - Added option to append filename on recording start
# 140428-1656 - Added pause_type logging to queue_log pause/unpause entries for ra_call_control function
# 140619-1006 - Added basic audio_playback function
#
$version = '2.8-40';
$build = '140428-1656';
$version = '2.10-41';
$build = '140619-1006';
$startMS = microtime();
@@ -1111,6 +1112,188 @@ if ($function == 'call_agent')
################################################################################
### BEGIN - audio_playback - play/pause/resume/stop/restart audio in agent session
################################################################################
if ($function == 'audio_playback')
{
if ( ( (strlen($value)<1) and ($stage=='PLAY') ) or (strlen($stage)<4) or ( (strlen($agent_user)<1) and (strlen($alt_user)<2) ) )
{
$result = 'ERROR';
$result_reason = "audio_playback not valid";
$data = "$stage";
echo "$result: $result_reason - $value|$data|$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";
$data = "$stage|$alt_user";
echo "$result: $result_reason - $data\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 conf_exten,server_ip from vicidial_live_agents where user='$agent_user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$rl_ct = mysqli_num_rows($rslt);
if ($rl_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$VLAconf_exten = $row[0];
$VLAserver_ip = $row[1];
if ( (strlen($VLAconf_exten) > 5) and (strlen($VLAserver_ip) > 5) )
{
$stmt = "select ext_context from servers where server_ip='$VLAserver_ip';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$ext_context = $row[0];
$stmt = "select channel from live_channels where extension='$VLAconf_exten' and server_ip='$VLAserver_ip' and channel LIKE \"IAX2/ASTplay%\";";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$rl_ct = mysqli_num_rows($rslt);
if ($stage == 'PLAY')
{
if ($rl_ct > 0)
{
if ($dial_override == 'Y')
{
$row=mysqli_fetch_row($rslt);
$VLAchannel = $row[0];
$VLAchannel_inc = $VLAchannel;
$VLAchannel_inc = preg_replace("/IAX2\/ASTplay-/",'',$VLAchannel_inc);
$stmtX="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$VLAserver_ip','','Hangup','PLAYHU$ENTRYdate','Channel: $VLAchannel','','','','','','','','','');";
if ($format=='debug') {echo "\n<!-- $stmtX -->";}
$rslt=mysql_to_mysqli($stmtX, $link);
$result = 'NOTICE';
$data = "$stage|$dial_override";
$result_reason = "audio_playback previous playback stopped";
echo "$result: $result_reason - $data|$agent_user\n";
$data = "$epoch";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
$stmtX="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$VLAserver_ip','','Originate','$value','Channel: Local\/47378216$VLAconf_exten@$ext_context','Context: $ext_context','Exten: 473782158521111','Priority: 1','CallerID: $value','','','','','');";
}
else
{
$result = 'ERROR';
$data = "$VLAconf_exten|$VLAserver_ip|$stage|$dial_override";
$result_reason = "audio_playback error - audio already playing in agent session";
echo "$result: $result_reason - $data|$agent_user\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
}
else
{
$stmtX="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$VLAserver_ip','','Originate','$value','Channel: Local\/47378216$VLAconf_exten@$ext_context','Context: $ext_context','Exten: 473782158521111','Priority: 1','CallerID: $value','','','','','');";
}
}
else
{
if ($rl_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$VLAchannel = $row[0];
$VLAchannel_inc = $VLAchannel;
$VLAchannel_inc = preg_replace("/IAX2\/ASTplay-/",'',$VLAchannel_inc);
if ($stage == 'STOP')
{
$stmtX="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$VLAserver_ip','','Hangup','PLAYHU$ENTRYdate','Channel: $VLAchannel','','','','','','','','','');";
}
if ($stage == 'RESTART')
{
$stmtX="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$VLAserver_ip','','Originate','PLAYRS$ENTRYdate','Channel: Local\/473782148521111$VLAchannel_inc@$ext_context','Context: $ext_context','Exten: 473782138521111','Priority: 1','CallerID: 4','','','','','');";
}
if ( ($stage == 'PAUSE') or ($stage == 'RESUME') )
{
$stmtX="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$VLAserver_ip','','Originate','PLAYPA$ENTRYdate','Channel: Local\/473782148521111$VLAchannel_inc@$ext_context','Context: $ext_context','Exten: 473782138521111','Priority: 1','CallerID: 3','','','','','');";
}
}
else
{
$result = 'ERROR';
$data = "$VLAconf_exten|$VLAserver_ip|$stage";
$result_reason = "audio_playback error - no audio playing in agent session";
echo "$result: $result_reason - $data|$agent_user\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
}
if ($format=='debug') {echo "\n<!-- $stmtX -->";}
$rslt=mysql_to_mysqli($stmtX, $link);
$result = 'SUCCESS';
$data = "$value|$stage";
$result_reason = "audio_playback function sent";
echo "$result: $result_reason - $data|$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';
$data = "$stage";
$result_reason = "audio_playback error - entry is empty";
echo "$result: $result_reason - $data|$agent_user\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
}
else
{
$result = 'ERROR';
$data = "$stage";
$result_reason = "audio_playback error - no session data";
echo "$result: $result_reason - $data|$agent_user\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
}
else
{
$result = 'ERROR';
$data = "$stage";
$result_reason = "agent_user is not logged in";
echo "$result: $result_reason - $data|$agent_user\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
}
}
################################################################################
### END - audio_playback
################################################################################
################################################################################
### BEGIN - external_dial - place a manual dial phone call
################################################################################
+1 -1
View File
@@ -4004,7 +4004,7 @@ if ($SSoutbound_autodial_active > 0)
<BR>
<A NAME="servers-recording_limit">
<BR>
<B>Recording Limit -</B> This field is where you set the maximum number of minutes that a call recording initiated by the system can be. Default is 60 minutes.
<B>Recording Limit -</B> This field is where you set the maximum number of minutes that a call recording initiated by the system can be. Default is 60 minutes. This setting also limits the amount of time a 3-way call that has been left by an agent will stay up before it is terminated.
<BR>
<A NAME="servers-carrier_logging_active">