- Announce queue position to a member in a given mod_callcenter queue.
-- Arguments are, in order: caller uuid, queue_name, interval (in milliseconds).
api = freeswitch.API()
caller_uuid = argv[1]
caller_id = tostring(argv[4])
queue_name = argv[2]
mseconds = argv[3]
if caller_uuid == nil or queue_name == nil or mseconds == nil then
return
end
played_greeting = false -- Flag to keep track of whether the greeting has been played
freeswitch.msleep(100)
while (true) do
members = api:executeString("callcenter_config queue list members "..queue_name)
pos = 1
exists = false
for line in members:gmatch("[^\r\n]+") do
if (string.find(line, "Trying") ~= nil or string.find(line, "Waiting") ~= nil) then
-- Members have a position when their state is Waiting or Trying
if string.find(line, caller_uuid, 1, true) ~= nil then
-- Member still in queue, so script must continue
exists = true
if played_greeting then
api:executeString("uuid_broadcast "..caller_uuid.." ivr/ivr-you_are_number.wav aleg")
api:executeString("uuid_broadcast "..caller_uuid.." digits/"..pos..".wav aleg")
end
if not played_greeting then -- Play greeting if it hasn't been played yet
api:executeString("uuid_broadcast "..caller_uuid.." ivr/Begrüßung.wav aleg")
played_greeting = true
end
end
pos = pos+1
end
end
-- If member was not found in queue, or its status is Aborted - terminate script
if exists == false then
return
end
-- Pause between announcements, except for the first iteration
if played_greeting then
freeswitch.msleep(mseconds)
end
end