FusionPBX: Position in Queue

Status
Not open for further replies.

krooney

Member
Jun 18, 2018
172
16
18
@francois
### I was able to add second language announcement with the following ###

-- callcenter-announce-position.lua
-- 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]
queue_name = argv[2]
mseconds = argv[3]
if caller_uuid == nil or queue_name == nil or mseconds == nil then
return
end
while (true) do

-- Pause between announcements
freeswitch.msleep(mseconds)
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
api:executeString("uuid_broadcast "..caller_uuid.." /usr/share/freeswitch/sounds/fr/ca/june/ivr/ivr-you_are_number.wav aleg")
api:executeString("uuid_broadcast "..caller_uuid.." /usr/share/freeswitch/sounds/fr/ca/june/digits/"..pos..".wav aleg")
api:executeString("uuid_broadcast "..caller_uuid.." /usr/share/freeswitch/sounds/en/us/callie/ivr/ivr-you_are_number.wav aleg")
api:executeString("uuid_broadcast "..caller_uuid.." /usr/share/freeswitch/sounds/en/us/callie/digits/"..pos..".wav aleg")
end
pos = pos+1
end
end
-- If member was not found in queue, or it's status is Aborted - terminate script
if exists == false then
return
end
end
 

gflow

Active Member
Aug 25, 2019
267
31
28
Is there any way to make this permanent? After I save any changes to my queue I need to manually re-add the lua script line to the Dialplan Manager XML file.
 

francois

New Member
Oct 3, 2019
28
9
3
57
This is because your dialplan is rebuilt during the save.
You will have to add some php code in app/call_centers/resources/classes/call_center.php to build your dialplan like you want.
 

gflow

Active Member
Aug 25, 2019
267
31
28
This is because your dialplan is rebuilt during the save.
You will have to add some php code in app/call_centers/resources/classes/call_center.php to build your dialplan like you want.
I ended up adding calling the lua script via the Dialplan Manager in a rule just above the Call Centre Queue, that seems to work fine.
 

agile

New Member
Oct 21, 2020
27
2
3
42
Make file /usr/share/freeswitch/scripts/callcenter-announce-position.lua (owner www-data:www-data), paste into it script from https://freeswitch.org/confluence/display/FREESWITCH/mod_callcenter (Lua Script to announce members position).
Edit your call center xml file, paste
<action application="set" data="result=${luarun(callcenter-announce-position.lua ${uuid} 19e610b8-4962-4810-a396-79dcd5f857c8 30000)}"/>

before line

<action application="callcenter" data="19e610b8-4962-4810-a396-79dcd5f857c8"/>

Bold number - change to uuid of your call center.
Hi I am new to fusionpbx Where is the Call center xml file located?
do I need to create one?
and how do i get the call center UUID

I have created the file /usr/share/freeswitch/scripts/callcenter-announce-position.lua
and copied the file from

Lua​

Lua Script to announce members position
This is the script to place in $PREFIX/scripts:

Code:
-- callcenter-announce-position.lua
-- 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]
queue_name = argv[2]
mseconds = argv[3]
if caller_uuid == nil or queue_name == nil or mseconds == nil then
    return
end
while (true) do
    -- Pause between announcements
    freeswitch.msleep(mseconds)
    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
                api:executeString("uuid_broadcast "..caller_uuid.." ivr/ivr-you_are_number.wav aleg")
                api:executeString("uuid_broadcast "..caller_uuid.." digits/"..pos..".wav aleg")
            end
            pos = pos+1
        end
    end
    -- If member was not found in queue, or it's status is Aborted - terminate script
    if exists == false then
        return
    end
end
 

jeetz

Member
Oct 15, 2019
84
2
8
41
hi @char1

is this correct? sorry just a noob.

Jeet

1634133820643.png
Make file /usr/share/freeswitch/scripts/callcenter-announce-position.lua (owner www-data:www-data), paste into it script from https://freeswitch.org/confluence/display/FREESWITCH/mod_callcenter (Lua Script to announce members position).
Edit your call center xml file, paste
<action application="set" data="result=${luarun(callcenter-announce-position.lua ${uuid} 19e610b8-4962-4810-a396-79dcd5f857c8 30000)}"/>

before line

<action application="callcenter" data="19e610b8-4962-4810-a396-79dcd5f857c8"/>

Bold number - change to uuid of your call center.
 
Status
Not open for further replies.