Recording and ACC Dialer (8.6.1000-8.6.1080)
The script uses the calling number to make it easier to route the call from ACC Dialer to the PSTN. Use the script in Khomp Flow, whenever you have ACC Dialer in your architecture.
|
Important Use this script if you have Altitude version up until 8.6.1080. If you have a higher version, please use Recording and ACC Dialer (8.6.1080-). |
The script uses a SIPREC parameter, cancel_call_on_fail, that behaves as follows:
- If the parameter is set to true, if the start of the call recording fails, the call is disconnected. If the call recording fails during the call, the call is not disconnected.
- If the parameter is set to false, if the start of the call recording fails, the call is not disconnected. The default value is false.
|
Attention
|
--------------------------------------------------------------------------------
-- Khomp Flow script
-- Version: Flow 1.0.5.5b Script version 2
-- Date: XX/02/2024
-- Khomp ID:
-- Khomp notes:
-- Altitude defect:
-- Altitude feature:
-- Altitude notes:
-- - Issue: "When the SIP REC recording is triggered by script and there is no reply, flow is disconnecting the call. No way to change this behaviour." (Fix: set_value("sip_rec.cancel_call_on_fail", "false"))
--------------------------------------------------------------------------------
--------------------------------------------
-- KHOMP - LUA SCRIPT
--
-- Link this script to a NAP to perform
-- functions at certain points of a call
--------------------------------------------
-- --------------------------------------------------------------------------------
-- ------------------ SIP REC BY DIALING SUFFIX - BEGIN ----------------------
-- --------------------------------------------------------------------------------
-- This table holds the possible returns of siprec_start() and siprec_stop() functions.
-- The first line maps the literal to a value and the second one, the value to its string.
SIPRECStatus = {
SUCCESS = 0, ERROR = 1, ALREADY_RUNNING = 2, NOT_AVAILABLE = 3;
[0] = "SUCCESS", "ERROR", "ALREADY_RUNNING", "NOT_AVAILABLE"
}
-- constants
ph_number_rec_suffix = '*9999'
-- siprec_server = 'QMS_REC_GRP'
siprec_server = 'QMS_RECORDER'
-- variable names
var_call_rec_is_enabled = "call_rec_is_enabled"
var_call_rec_calling_device_id = "call_rec_calling_device_id"
var_call_rec_called_device_id = "call_rec_called_device_id"
var_call_rec_siprec_device_id = "call_rec_siprec_device_id"
function siprec_setup_by_device (device_index, device_id, is_calling_party)
set_value(string.format("sip_rec_participant[%d].user",device_index), device_id)
set_value(string.format("sip_rec_participant[%d].extension",device_index), string.format("isCallingParty:%s", is_calling_party))
end
function get_call_rec_is_enabled_from_ph_number (ph_number)
local call_rec_is_enabled = false
local real_ph_number = ph_number
local ph_number_rec_suffix_index = ph_number:match( '()' .. ph_number_rec_suffix )
if ph_number_rec_suffix_index ~= nil and (ph_number_rec_suffix_index - 1 + ph_number_rec_suffix:len() == ph_number:len()) then
log ("recording suffix found in " .. ph_number)
real_ph_number = ph_number:sub(1, ph_number_rec_suffix_index - 1)
call_rec_is_enabled = true
else
log ("recording suffix not found in " .. ph_number)
end
return call_rec_is_enabled, real_ph_number
end
function check_set_call_rec_is_enabled_on_ph_number_2_var (var_ph_number)
local ph_number = get_value(var_ph_number)
local func_call_rec_is_enabled, func_real_ph_number = get_call_rec_is_enabled_from_ph_number (ph_number)
if func_call_rec_is_enabled then
set_value(var_ph_number,func_real_ph_number)
set_value(var_call_rec_is_enabled,tostring(true))
else
set_value(var_call_rec_is_enabled,tostring(false))
end
end
function check_set_call_rec_data (var_calling_device_id, var_called_device_id, var_siprec_device_id)
local call_rec_is_enabled = siprec_get_var_call_rec_is_enabled()
if call_rec_is_enabled == "true" then
local call_rec_calling_device_id = get_value (var_calling_device_id)
local call_rec_called_device_id = get_value (var_called_device_id)
local call_rec_siprec_device_id = get_value (var_siprec_device_id)
set_value(var_call_rec_calling_device_id,call_rec_calling_device_id)
set_value(var_call_rec_called_device_id,call_rec_called_device_id)
set_value(var_call_rec_siprec_device_id,call_rec_siprec_device_id)
end
end
function siprec_init()
set_value(var_call_rec_is_enabled,tostring(false))
set_value(var_call_rec_calling_device_id,"")
set_value(var_call_rec_called_device_id,"")
set_value(var_call_rec_siprec_device_id,"")
end
function siprec_get_var_call_rec_is_enabled()
local call_rec_is_enabled = get_value(var_call_rec_is_enabled)
if call_rec_is_enabled == nil or call_rec_is_enabled == "" then
call_rec_is_enabled = tostring(false)
end
return call_rec_is_enabled
end
function siprec_get_var_all()
local call_rec_is_enabled = siprec_get_var_call_rec_is_enabled()
local call_rec_calling_device_id = ""
local call_rec_called_device_id = ""
local call_rec_siprec_device_id = ""
if call_rec_is_enabled == "true" then
call_rec_calling_device_id = get_value(var_call_rec_calling_device_id)
call_rec_called_device_id = get_value(var_call_rec_called_device_id)
call_rec_siprec_device_id = get_value(var_call_rec_siprec_device_id)
if call_rec_calling_device_id == nil then
call_rec_calling_device_id = ""
end
if call_rec_called_device_id == nil then
call_rec_called_device_id = ""
end
if call_rec_siprec_device_id == nil then
call_rec_siprec_device_id = ""
end
end
return call_rec_is_enabled,call_rec_calling_device_id,call_rec_called_device_id,call_rec_siprec_device_id
end
function siprec_check_start_rec()
local status = SIPRECStatus.SUCCESS
local call_rec_is_enabled
local call_rec_calling_device_id
local call_rec_called_device_id
local call_rec_siprec_device_id
call_rec_is_enabled,call_rec_calling_device_id,call_rec_called_device_id,call_rec_siprec_device_id = siprec_get_var_all()
if call_rec_is_enabled == "true" and siprec_is_running() == false then
siprec_setup_by_device (0, call_rec_calling_device_id, true)
siprec_setup_by_device (1, call_rec_called_device_id, false)
set_value("sip_rec.cancel_call_on_fail", "false")
-- To assure that Enghouse QMS 9.1 records the call ...
set_value("sip_rec_recording.extension", "altitude-dummy:ABCD1234")
status = siprec_start(siprec_server)
end
if status ~= SIPRECStatus.SUCCESS then
log( "status = (" .. status .. ") " .. SIPRECStatus[status] )
end
end
function siprec_check_stop_rec()
local status = SIPRECStatus.SUCCESS
if siprec_is_running() then
status = siprec_stop()
end
if status ~= SIPRECStatus.SUCCESS then
log( "status = (" .. status .. ") " .. SIPRECStatus[status] )
end
end
function siprec_dump_call_information()
local call_rec_is_enabled
local call_rec_calling_device_id
local call_rec_called_device_id
local call_rec_siprec_device_id
call_rec_is_enabled,call_rec_calling_device_id,call_rec_called_device_id,call_rec_siprec_device_id = siprec_get_var_all()
get_value("dest_addr")
get_value("orig_addr")
get_value("X-ACS-DeviceId")
get_header_extension("X-ACS-DeviceId")
log ("call_rec_is_enabled = " .. call_rec_is_enabled)
log ("call_rec_calling_device_id = " .. call_rec_calling_device_id)
log ("call_rec_called_device_id = " .. call_rec_called_device_id)
log ("call_rec_siprec_device_id = " .. call_rec_siprec_device_id)
end
-- --------------------------------------------------------------------------------
-- ------------------ SIP REC BY DIALING SUFFIX - END ------------------------
-- --------------------------------------------------------------------------------
-- prerouting(): executed before routing procedure
-- - if the function returns true, it will accept current call
-- - if the function returns false, it will reject current call
function prerouting()
-- --------------------------------------------------------------------------------
-- ----------------- PREDICTIVE DIALING WITH CLASSIFICATION - BEGIN ---------------
-- --------------------------------------------------------------------------------
if (has_value("sip_header:X-Altitude-Purpose")) then
orig_addr = get_value("orig_addr")
set_value("orig_addr","CC#" .. orig_addr)
end
-- --------------------------------------------------------------------------------
-- ----------------- PREDICTIVE DIALING WITH CLASSIFICATION - END ---------------
-- --------------------------------------------------------------------------------
-- --------------------------------------------------------------------------------
-- ------------------ SIP REC BY DIALING SUFFIX - BEGIN ----------------------
-- --------------------------------------------------------------------------------
-- Outbound predictive dialing to ACS IVRs (phase: distribution to IVRs)
log ("Trigger = prerouting (from routing_accdialer.lua)")
siprec_init()
local x_altitude_fromaccdialer = get_header_extension( "X-Altitude-FromACCdialer" )
local x_altitude_data = get_header_extension( "x-altitude-data" )
local x_altitude_fromtrunk = get_header_extension( "X-Altitude-FromTrunk" )
if x_altitude_fromaccdialer ~= nil and x_altitude_data ~= nil and x_altitude_fromtrunk ~= nil and x_altitude_fromaccdialer == 'yes' then
check_set_call_rec_is_enabled_on_ph_number_2_var ("dest_addr")
check_set_call_rec_data("orig_addr", "dest_addr", "dest_addr")
end
-- siprec_dump_call_information ()
-- --------------------------------------------------------------------------------
-- ------------------ SIP REC BY DIALING SUFFIX - END ------------------------
-- --------------------------------------------------------------------------------
return true
end
-- postrouting(): executed after routing procedure
-- - if the function returns true, it will accept current call
-- - if the function returns false, it will reject current call
function postrouting()
return true
end
-- transfer(): executed when transfer is started
-- - if the function returns true, the transfer_type value defines the transfer behavior
-- - if the function returns false, the transfer_type is set to reject
function transfer()
-- --------------------------------------------------------------------------------
-- ------------------ SIP REC BY DIALING SUFFIX - BEGIN ----------------------
-- --------------------------------------------------------------------------------
-- Outbound predictive dialing to ACS IVRs (phase: distribution to IVRs)
log ("Trigger = transfer (from routing_accdialer.lua)")
-- siprec_dump_call_information ()
-- siprec_check_start_rec ()
-- --------------------------------------------------------------------------------
-- ------------------ SIP REC BY DIALING SUFFIX - END ------------------------
-- --------------------------------------------------------------------------------
return true
end
-- postcall(): executed after call has ended
-- - aways return true
function postcall()
return true
end
-- sipinfo(): executed after a SIP INFO is received
-- - if the function returns true then the SIP INFO is forwarded to the
-- other call leg
-- - if the function returns false then the SIP INFO is discarded
function sipinfo()
return true
end
-- sdpupdated( message ): executed after a sdpupdated is received
-- - always return true
function sdpupdated( message )
return true
end
function onconnectlega( )
-- --------------------------------------------------------------------------------
-- ------------------ SIP REC BY DIALING SUFFIX - BEGIN ----------------------
-- --------------------------------------------------------------------------------
-- Outbound predictive dialing to ACS IVRs (phase: distribution to IVRs)
log ("Trigger = onconnectlega (from routing_accdialer.lua)")
-- siprec_dump_call_information ()
siprec_check_start_rec ()
-- --------------------------------------------------------------------------------
-- ------------------ SIP REC BY DIALING SUFFIX - END ------------------------
-- --------------------------------------------------------------------------------
return true
end
-- onconnectlegb( ): Intercept leg b connection and execute lua code
-- - always return true
function onconnectlegb( )
return true
end