Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Initialization of variables
- api = freeswitch.API()
- -- First argument is caller uuid.
- caller_uuid = argv[1]
- if caller_uuid==nil then return end
- -- Second argument is callcenter name.
- queue_name = argv[2]
- if queue_name==nil then return end
- -- Third argument is repeating interval in miliseconds.
- mseconds = argv[3]
- if mseconds==nil then return end
- times_announced = 0
- while (true) do
- freeswitch.msleep(mseconds) -- Pause before announcing position
- members = api:executeString("callcenter_config queue list members "..queue_name)
- pos=1 -- Variable to count position
- exists=false -- Variable to allow script termination when member leaves queue
- 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
- exists=true -- Member still in queue so script must continue
- --api:executeString("uuid_broadcast "..caller_uuid.." ivr/ivr-you_are_number.wav aleg")
- --api:executeString("uuid_broadcast "..caller_uuid.." digits/"..pos..".wav aleg")
- if pos == 1 then
- if times_accounced == 0 then
- api:executeString("uuid_broadcast "..caller_uuid.." say:'Please hold. You will be connected to a representative shortly.' aleg")
- else
- api:executeString("uuid_broadcast "..caller_uuid.." say:'We are sorry to keep you waiting. You will be connected to a representative shortly.' aleg")
- end
- elseif pos == 2 then
- if times_accounced == 0 then
- api:executeString("uuid_broadcast "..caller_uuid.." say:'There is 1 caller ahead of you. We will be with you shortly.' aleg")
- else
- api:executeString("uuid_broadcast "..caller_uuid.." say:'We are sorry to keep you waiting. There is 1 caller ahead of you. We will be with you shortly.' aleg")
- end
- else
- if times_accounced == 0 then
- api:executeString("uuid_broadcast "..caller_uuid.." say:'There are "..(pos-1).." callers ahead of you. We will be with you shortly.' aleg")
- else
- api:executeString("uuid_broadcast "..caller_uuid.." say:'We are sorry to keep you waiting. There are "..(pos-1).." callers ahead of you. We will be with you shortly.' aleg")
- end
- end
- times_announced = times_announced + 1
- end
- pos=pos+1
- end
- end
- if exists==false then return end -- If member was not found in queue, or it's status is Aborted - terminate script
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement