Ring phones while greeting is playing

Status
Not open for further replies.

farshidhakimy

New Member
Feb 24, 2023
5
0
1
18
Hello,
I am currently trying out FusionPBX and I really like it.
However, I am trying to get the phones to ring while the greeting is playing in the Callcenter module for some days now and I could not get it to work.
Is there a way to achieve this or is this not possible in FusionPBX?
 

farshidhakimy

New Member
Feb 24, 2023
5
0
1
18
I got it working with a dirty workaround:
Code:
- 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
That's the Lua script for announcing the position in /usr/share/freeswitch/scripts/ and which I call in the dialplan.
The greeting is in the different folders somewhere in /usr/share/freeswitch/(sounds)?
 
Last edited:
Status
Not open for further replies.