Calling queues and distributing calls to operators is one of the main tasks of the call center serving incoming calls when the number of calls exceeds the number of available operators (standard situation for most call centers). The caller is queued under a certain number, which the IVR informs him of, and plays music, periodically telling about the change in place in the queue and the expected waiting time (before the operator answers). If you're lucky, the music will be pleasant, and the wait is not too long. Want to learn how to quickly organize a call center with the described functionality, without getting into the wilds and the complexity of IP-telephony - welcome under the cat. 

// ACD require(Modules.ACD); var request, // <-- ACDRequest originalCall, // <-- callerid, statusInterval; // VoxEngine.addEventListener(AppEvents.CallAlerting, handleInboundCall); // function handleInboundCall(e) { originalCall = e.call; callerid = e.callerid; // originalCall.addEventListener(CallEvents.Connected, handleCallConnected); originalCall.addEventListener(CallEvents.PlaybackFinished, handlePlaybackFinished); originalCall.addEventListener(CallEvents.Failed, cleanup); originalCall.addEventListener(CallEvents.Disconnected, cleanup); // originalCall.answer(); } // function cleanup(e) { if (request) { // - request.cancel(); request = null; } // VoxEngine.terminate(); } // function handlePlaybackFinished(e) { e.call.startPlayback("http://cdn.voximplant.com/toto.mp3"); } // function handleCallConnected(e) { // 'MainQueue', request = VoxEngine.enqueueACDRequest("MainQueue", callerid); // request.addEventListener(ACDEvents.Queued, function (acdevent) { request.getStatus(); }); // request.addEventListener(ACDEvents.Waiting, function (acdevent) { var minutesLeft = acdevent.ewt + 1; var minutesWord = " ."; if ((minutesLeft > 10 && minutesLeft < 20) || (minutesLeft % 10 > 4 || minutesLeft % 10 == 0)) { minutesWord = " ."; } else if (minutesLeft % 10 == 1) { minutesWord = " ."; } originalCall.say(" " + acdevent.position + ". " + (acdevent.ewt + 1) + minutesWord, Language.RU_RUSSIAN_FEMALE); }); // request.addEventListener(ACDEvents.OperatorReached, function (acdevent) { VoxEngine.sendMediaBetween(acdevent.operatorCall, originalCall); acdevent.operatorCall.addEventListener(CallEvents.Disconnected, VoxEngine.terminate); clearInterval(statusInterval); }); // - request.addEventListener(ACDEvents.Offline, function (acdevent) { originalCall.say(" , . , .", Language.RU_RUSSIAN_FEMALE); originalCall.addEventListener(CallEvents.PlaybackFinished, function (e) { VoxEngine.terminate(); }); }); // 30 statusInterval = setInterval(request.getStatus, 30000); } 




Source: https://habr.com/ru/post/242397/
All Articles