Announce Position in Queue upon Entry and continue to update

kenn10

New Member
Sep 11, 2018
8
2
3
69
I found this post about how to make changes in FreeSwitch and FusionPBX to have the Call Center queue announce the position in queue to the customer. The post form @TurabG got me thinking that it would be nice to tell you your position as soon as you enter the queue. This is his post: https://www.pbxforums.com/threads/t...call-center-queue-and-make-it-permanent.6921/

I played around and made a few changes. I hope some folks will find it useful.

1) I did not like the way it announced "Call number X" so I made a few recordings: using a similar AI voice. Zip file attached.
  1. "You are first in line"
  2. "You are caller"
  3. "Waiting to speak with a representative.
2) Then I changed the code to make a position announcement upon entering the queue. If you are the first (or only) caller, it says "You are first in line waiting to speak with a representative."

3) If you are the second or subsequent caller in queue, it says "You are caller X waiting to speak with a representative.

4) The position in queue announcement will play immediately after the queue entry main recording and then repeat at the interval you select.

5) My code below has the changes I added to create the callcenter-announce-position.lua originally posted in the thread. I have longer time between the announcements but it is user adjustable as outlined in the original post.

Here is my LUA code:
Code:
-- callcenter-announce-position.lua
-- Announce queue position to a member in a given mod_callcenter queue.
-- Arguments: 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

function announce_position()
    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
            if string.find(line, caller_uuid, 1, true) ~= nil then
                exists = true
                if pos == 1 then
                    api:executeString("uuid_broadcast " .. caller_uuid .. " misc/you_are_first.wav aleg")
                    api:executeString("uuid_broadcast " .. caller_uuid .. " misc/waiting_to_speak.wav aleg")
                else
                    api:executeString("uuid_broadcast " .. caller_uuid .. " misc/your_call_is_number.wav aleg")
                    api:executeString("uuid_broadcast " .. caller_uuid .. " digits/" .. pos .. ".wav aleg")
                    api:executeString("uuid_broadcast " .. caller_uuid .. " misc/waiting_to_speak.wav aleg")
                end
            end
            pos = pos + 1
        end
    end
    return exists
end

-- First immediate announcement
freeswitch.msleep(750)
if not announce_position() then
    return
end

-- Then repeat every mseconds
while (true) do
    freeswitch.msleep(mseconds)
    if not announce_position() then
        return
    end
end
 

Attachments

Last edited:
  • Like
Reactions: pbxgeek