BLF of agent status "agent+username@domain.com (#3860)
* BLF of agent status "agent+username@domain.com Add the ability to monitor the availability status of a call center agent with "agent+agentname@domain.com". * Update index.lua Send notify to blf with "agent+agentname@domain.com"
This commit is contained in:
parent
dd27347353
commit
9ff799cfe4
|
|
@ -18,6 +18,8 @@
|
||||||
json = require "resources.functions.lunajson"
|
json = require "resources.functions.lunajson"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local presence_in = require "resources.functions.presence_in"
|
||||||
|
|
||||||
--set the api
|
--set the api
|
||||||
api = freeswitch.API();
|
api = freeswitch.API();
|
||||||
|
|
||||||
|
|
@ -181,6 +183,15 @@
|
||||||
event:addHeader("answer-state", "confirmed");
|
event:addHeader("answer-state", "confirmed");
|
||||||
event:fire();
|
event:fire();
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (action == "login") then
|
||||||
|
blf_status = "false"
|
||||||
|
end
|
||||||
|
if string.find(agent_name, 'agent+', nil, true) ~= 1 then
|
||||||
|
presence_in.turn_lamp( blf_status,
|
||||||
|
'agent+'..agent_name.."@"..domain_name
|
||||||
|
);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--unauthorized
|
--unauthorized
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ end
|
||||||
|
|
||||||
require "resources.functions.config"
|
require "resources.functions.config"
|
||||||
require "resources.functions.split"
|
require "resources.functions.split"
|
||||||
|
require "resources.functions.trim";
|
||||||
|
|
||||||
local log = require "resources.functions.log"[service_name]
|
local log = require "resources.functions.log"[service_name]
|
||||||
local presence_in = require "resources.functions.presence_in"
|
local presence_in = require "resources.functions.presence_in"
|
||||||
|
|
@ -82,6 +83,34 @@ end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local find_agent_status do
|
||||||
|
|
||||||
|
local find_agent_uuid_sql = [[select t1.call_center_agent_uuid
|
||||||
|
from v_call_center_agents t1 inner join v_domains t2 on t1.domain_uuid = t2.domain_uuid
|
||||||
|
where t2.domain_name = :domain_name and t1.agent_name = :agent_name
|
||||||
|
]]
|
||||||
|
|
||||||
|
function find_agent_status(user)
|
||||||
|
local agent_name, domain_name = split_first(user, '@', true)
|
||||||
|
local _, short = split_first(agent_name, '+', true)
|
||||||
|
if not domain_name then return end
|
||||||
|
local dbh = Database.new('system')
|
||||||
|
if not dbh then return end
|
||||||
|
local row = dbh:first_row(find_agent_uuid_sql, {
|
||||||
|
domain_name = domain_name, agent_name = agent_name
|
||||||
|
})
|
||||||
|
dbh:release()
|
||||||
|
if not row then return end
|
||||||
|
if row.call_center_agent_uuid then
|
||||||
|
local cmd = "callcenter_config agent get status "..row.call_center_agent_uuid.."";
|
||||||
|
freeswitch.consoleLog("notice", "[user status][login] "..cmd.."\n");
|
||||||
|
user_status = trim(api:executeString(cmd));
|
||||||
|
end
|
||||||
|
return row.call_center_agent_uuid, user_status
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
local protocols = {}
|
local protocols = {}
|
||||||
|
|
||||||
protocols.flow = function(event)
|
protocols.flow = function(event)
|
||||||
|
|
@ -140,6 +169,24 @@ protocols.forward = function(event)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protocols.agent = function(event)
|
||||||
|
local from, to = event:getHeader('from'), event:getHeader('to')
|
||||||
|
local expires = tonumber(event:getHeader('expires'))
|
||||||
|
if expires and expires > 0 then
|
||||||
|
local proto, user = split_first(to, '+', true)
|
||||||
|
user = user or proto
|
||||||
|
local call_center_agent_uuid, agent_status = find_agent_status(user)
|
||||||
|
if agent_status then
|
||||||
|
log.noticef("Find agent: %s status: %s", user, tostring(agent_status))
|
||||||
|
presence_in.turn_lamp(agent_status == "Available", to)
|
||||||
|
else
|
||||||
|
log.warningf("Can not find agent status: %s", to)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
log.noticef("%s UNSUBSCRIBE from %s", from, to)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if proto ~= 'all' then
|
if proto ~= 'all' then
|
||||||
for name in pairs(protocols) do
|
for name in pairs(protocols) do
|
||||||
if proto ~= name then
|
if proto ~= name then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue