Voximplant. Blog

Using ACD module for call queuing

ACD

Call queuing is required to process inbound calls to PBX or contact center, callers are put into queue where they wait for a free operator and listening to some music. IVR usually notifies a caller about his position in a queue and about estimate waiting time. Operators have controls to set their availability, because some time is required to put data about previous call before answering the next one. VoxImplant has all capabilities required to build contact center functionality including ACD (Automatic call distributor) that can be controlled using the ACD Module. In this tutorial we will build a simple queue that is being processed by operators with the same skill set.

The following steps are required to build our contact center:
1. Create VoxImplant application (let’s call it callcenter)
2. Create application users (they will be our call center operators)
3. Create Queue (in Settings menu) for the application
4. Create Skill (in Settings menu), choose the queue and assign users to the group
5. Create VoxEngine Scenario that will handle inbound calls and put them in a queue
6. Create application Rule to use the scenario to process calls
7. Create operator’s web interface using Web SDK

VoxImplant Application

Open Applications section of the control panel and create new application, call it “callcenter”. Full name will look like callcenter.your_account_name.voximplant.com

Users (operators)

Open Users section of the control panel and create a few users, call them operator1, operator2, etc. Assign them to the application we created earlier.

Creating Queue

Open Queues section of the control panel (under Settings menu) and create new queue with the following parameters:
New Queue

Adding Skill

Open Skills section of the control panel (under Settings menu) and create new Skill – specify queue and assign users we created before.
Skill

Creating VoxEngine Scenario

Open Scenarios section of the control panel and create new scenario:

  1. // Enable ACD module
  2. require(Modules.ACD);
  3.  
  4. var request,
  5. originalCall,
  6. callerid,
  7. statusInterval;
  8.  
  9. VoxEngine.addEventListener(AppEvents.CallAlerting, handleInboundCall);
  10.  
  11. // Handle inbound call
  12. function handleInboundCall(e) {
  13. originalCall = e.call;
  14. callerid = e.callerid;
  15. // Add event listeners
  16. originalCall.addEventListener(CallEvents.Connected, handleCallConnected);
  17. originalCall.addEventListener(CallEvents.PlaybackFinished, handlePlaybackFinished);
  18. originalCall.addEventListener(CallEvents.Failed, cleanup);
  19. originalCall.addEventListener(CallEvents.Disconnected, cleanup);
  20. // Answer call
  21. originalCall.answer();
  22. }
  23.  
  24. // Terminate call and session
  25. function cleanup(e) {
  26. if (request) {
  27. // Remove call from queue
  28. request.cancel();
  29. request = null;
  30. }
  31. // terminate session
  32. VoxEngine.terminate();
  33. }
  34.  
  35. // Play music after TTS finish
  36. function handlePlaybackFinished(e) {
  37. e.call.startPlayback("http://cdn.voximplant.com/toto.mp3");
  38. }
  39.  
  40. // Get suffix for the number
  41. function ordinal_suffix_of(i) {
  42. var j = i % 10,
  43. k = i % 100;
  44. if (j == 1 && k != 11) {
  45. return i + "st";
  46. }
  47. if (j == 2 && k != 12) {
  48. return i + "nd";
  49. }
  50. if (j == 3 && k != 13) {
  51. return i + "rd";
  52. }
  53. return i + "th";
  54. }
  55.  
  56. // Call connected
  57. function handleCallConnected(e) {
  58. // Put the call into the queue 'MainQueue'
  59. request = VoxEngine.enqueueACDRequest("MainQueue", callerid);
  60.  
  61. // Get call status in queue after it was put in the queue
  62. request.addEventListener(ACDEvents.Queued, function (acdevent) {
  63. request.getStatus();
  64. });
  65.  
  66. // Notify caller about his position in the queue
  67. request.addEventListener(ACDEvents.Waiting, function (acdevent) {
  68. var minutesLeft = acdevent.ewt + 1;
  69. var minutesWord = " minute.";
  70. if (minutesLeft > 1) {
  71. minutesWord = " minutes.";
  72. }
  73. originalCall.say("You are " + ordinal_suffix_of(acdevent.position) +
  74. " in a queue. Represetative will answer you in " + (acdevent.ewt + 1) + minutesWord, Language.US_ENGLISH_FEMALE);
  75. });
  76.  
  77. // Connect caller with operator
  78. request.addEventListener(ACDEvents.OperatorReached, function (acdevent) {
  79. VoxEngine.sendMediaBetween(acdevent.operatorCall, originalCall);
  80. acdevent.operatorCall.addEventListener(CallEvents.Disconnected, VoxEngine.terminate);
  81. clearInterval(statusInterval);
  82. });
  83.  
  84. // No operators are available
  85. request.addEventListener(ACDEvents.Offline, function (acdevent) {
  86. originalCall.say("All operators are currently offline, please try to call again later.", Language.US_ENGLISH_FEMALE);
  87. originalCall.addEventListener(CallEvents.PlaybackFinished, function (e) {
  88. VoxEngine.terminate();
  89. });
  90. });
  91.  
  92. // Get current call status in a queue every 30 seconds
  93. statusInterval = setInterval(request.getStatus, 30000);
  94. }

Call it ‘ACD’ and save. Now we need to connect the scenario to our application and connect some phone number to the application.

Buying Phone Number

Open Phone numbers section of the control panel and buy phone number there:
Phone numbers
After that you will need to attach the phone number to our application:
Application Number
Now we need to forward calls from the phone number to our ACD scenario.

Creating Application Rule

Go to Applications and edit our callcenter application – open Rules tab and click Add rule button, let’s call it InboundCalls and put our phone number into the Pattern input field, then drag’n’drop ACD scenario to the Assigned scenarios list:
New Rule
Click Add button and you will see the new rule in the application rules list:
Rules List

Building Web Client for Operators using Web SDK

The last thing we need to finish our simple contact center is to build simple web interface for operators. VoxImplant Web SDK has all required capabilities for that. To specify current operator status we will be using setOperatorACDStatus function, where we should pass one of the statuses from VoxImplant.OperatorACDStatuses. When ACD status set to VoxImplant.OperatorACDStatuses.Ready incoming calls from a queue will be forwarded to the operator. Here is the UI of our simple call center user agent app:
User Agent
You can download the code of the web app from our GitHub account. Don’t forget to specify your account name in the code of the app (see ACCNAME variable).

Comments