Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- check answering time: https://gitlab.ivoice.online/ivoice-platform/call-task-service/merge_requests/76
- -- this parameter is set in FreeswitchGateway.originateParameter document
- local MachineAnsweringTimeUpToMsec = session:getVariable("machine_answering_time_up_to")
- if MachineAnsweringTimeUpToMsec == nil then
- freeswitch.consoleLog("INFO", "no machine_answering_time_up_to_passed - ignoring fast answer machine detection")
- else
- freeswitch.consoleLog("INFO", "MachineAnsweringTimeUpToMsec = " .. MachineAnsweringTimeUpToMsec)
- MachineAnsweringTimeUpToMsec = tonumber(MachineAnsweringTimeUpToMsec)
- -- if call answered too fast, assume answering machine
- local createdTime = session:getVariable("created_time")
- local answeredTime = session:getVariable("answered_time")
- local timeToAnswerMs = (answeredTime - createdTime) / 1000
- freeswitch.consoleLog("INFO", "time to answer, ms = " .. timeToAnswerMs)
- if timeToAnswerMs < MachineAnsweringTimeUpToMsec then
- local answeringMachineReason = "answered_in_timeToAnswerMs=" .. timeToAnswerMs .. "_MachineAnsweringTimeUpToMsec=" .. MachineAnsweringTimeUpToMsec
- freeswitch.consoleLog("INFO", "hangup because answering machine detected: " .. answeringMachineReason)
- session:setVariable("AnsweringMachine", "true")
- session:setVariable("AnsweringMachineReason", answeringMachineReason)
- session:hangup()
- return
- end
- end
- -- init params
- local Client = session:getVariable("Client")
- local Campaign = session:getVariable("Campaign")
- local CallTaskId = session:getVariable("CallTaskId")
- local CallingSystemCallUuid = session:getVariable("CallingSystemCallUuid")
- local CallTaskServiceHost = session:getVariable("ScenarioParametersApiHost")
- local CallTaskServicePort = session:getVariable("ScenarioParametersApiPort")
- local ScenarioResultTopic = session:getVariable("ScenarioResultTopic")
- local SleepTime = session:getVariable("SleepTime")
- local callerNumber = session:getVariable("sip_to_user")
- local SipServlet = session:getVariable("SipServlet")
- local AmdEnabled = session:getVariable("AmdEnabled")
- if AmdEnabled == nil then
- AmdEnabled = false
- end
- --- bridge processing to ss
- freeswitch.consoleLog("info", "dispatching request to: " .. SipServlet)
- local bridgeTo = "sofia/gateway/" .. SipServlet .. "/outgoingSolution?taskId=" .. CallTaskId .. "&amdEnabled=" .. tostring(AmdEnabled) .. "&callUuid=" .. CallingSystemCallUuid .. "&callTaskServiceHost=" .. CallTaskServiceHost .. "&callTaskServicePort=" .. CallTaskServicePort .. "&scenarioResultTopic=" .. ScenarioResultTopic .. "&sleepBeforeScenarioMs=" .. SleepTime
- freeswitch.consoleLog("info", "bridging to ss: " .. bridgeTo .. "; AmdEnabled = " .. tostring(AmdEnabled))
- local sipServletSession = freeswitch.Session(bridgeTo)
- freeswitch.bridge(session, sipServletSession)
- -- local bridgeParams = "{sip_cid_type=rpid,origination_caller_id_name=" .. callerNumber .. ",origination_caller_id_number=" .. callerNumber .. "}"
- local bridgeParams = "{sip_cid_type=none}"
- local bridgeAfterIvr = sipServletSession:getVariable("sip_bye_h_X-Ivoice-BridgeDestination")
- local phone=session:getVariable("caller_id_number")
- if Campaign == "6009540af961227f554be5c6" then
- freeswitch.consoleLog("INFO","shatalov_napominalka")
- bridgeParams="{sip_cid_type=none,origination_caller_id_name=shatalov_napominalka_"..phone..",sip_h_X-robot_ivoice=shatalov_napominalka_"..phone..",origination_caller_id_number=shatalov_napominalka_"..phone.."}"
- elseif Campaign == "60670c373bc0a6000178208f" then
- freeswitch.consoleLog("INFO","pulse_akciya")
- bridgeParams="{sip_cid_type=none,origination_caller_id_name=pulse_akciya_"..phone..",sip_h_X-robot_ivoice=pulse_akciya_"..phone..",origination_caller_id_number=pulse_akciya_"..phone.."}"
- elseif Campaign == "60670c563bc0a60001782090" then
- freeswitch.consoleLog("INFO","shatalov_akciya")
- bridgeParams="{sip_cid_type=none,origination_caller_id_name=shatalov_akciya_"..phone..",sip_h_X-robot_ivoice=shatalov_akciya_"..phone..",origination_caller_id_number=shatalov_akciya_"..phone.."}"
- else
- freeswitch.consoleLog("ERROR","bridge robot parameter should be provided, it wasn't")
- session:hangup()
- end
- if bridgeAfterIvr == nil then
- freeswitch.consoleLog("INFO", "bridgeAfterIvr is nil, hangup")
- session:hangup()
- else
- freeswitch.consoleLog("INFO", "bridgeAfterIvr not nil, bridging to " .. bridgeAfterIvr)
- local bridgeAfterIvrSession = freeswitch.Session(bridgeParams .. bridgeAfterIvr)
- freeswitch.bridge(session, bridgeAfterIvrSession)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement