VoxImplant. Blog

Voicemail detection

Voicemail IconThere is number of different scenarios when you would like to know if you’ve reached voicemail or live person during the call, and if voicemail was reached it’s a good thing to know when you can play a pre-recorded voice message to leave it in the inbox. Keeping in mind that VoxImplant is a perfect choice for building power dialer or predictive dialer app it makes a lot of sense to offer this functionality to our developers. We’ve implemented both voicemail detection and voicemail tone detection algorithms to let developer control the call flow on VoxEngine scenario level.

Voicemail detection is based on voice activity detection subsystem that analyzes callee’s audio stream, if system detected short phrase (after the call was connected) and pause after the phrase (the callee said “Hello”) we can consider that we’ve reached a live person, if the audio stream looks like pre-recorded audio message we can consider that we have reached a voicemail answering machine.

Power dialer

Let’s start with simpler scenario – agent calls customers using some call list and while he reaches voicemail he sends some pre-recorded mp3 message to the inbox. In terms of VoxEngine scenario this code will look like as follows:

  1. var call = VoxEngine.callPSTN('some_phone_number');
  2.  
  3. // Keeping in mind that some voicemail systems can work in pre-connected state (early media), it's better to use AudioStarted event
  4. call.addEventListener(CallEvents.AudioStarted, function(e) {
  5. // Enable voicemail tone detection
  6. call.detectVoicemailTone();
  7. });
  8. // Let's assume we will use sendMessage on Web SDK side to notify scenario that we've reached voicemail
  9. call.addEventListener(CallEvents.MessageReceived, function(e) {
  10. // Add event listener for voicemail tone event
  11. call.addEventListener(CallEvents.VoicemailToneDetected, function(e) {
  12. Logger.write("Voicemail tone detected freq "+e.frequency);
  13. call.startPlayback("URLtoMP3");
  14. // Hangup call after mp3 message was played to the inbox
  15. call.addEventListener(CallEvents.PlaybackFinished, function(e) {
  16. call.hangup();
  17. });
  18. });
  19. });

You can pass mp3 URL from WebSDK using sendMessage function.

Predictive Dialer

In case of predictive dialing we don’t rely on live person to detect voicemail, since it’s automated process and we don’t want to spend call center agent’s time. Since voicemail systems behave differently it’s not possible to offer 100% warranty in case of automated voicemail detection, but we made our best and implemented number of adjustable subsystems that help with the process. First of all, we will use the same detectVoicemailTone function as in Power dialer example, and will analyze audio stream in pre-connected state – some voicemail prompts can be played as early media. If voicemail tone detected we will assume that we’ve reached voicemail subsystem. Other types of voicemail systems start prompt playback after call was connected and in this case we will use another VoxEngine function called detectVoicemailPrompt – it analyzes audio stream to see if the callee behaves like live person (CallEvents.VoicemailPromptNotDetected will be fired) or not (CallEvents.VoicemailPromptDetected will be fired). You can see the code example below:

  1. var callconnected = false,
  2. voicemail = false;
  3.  
  4. var call = VoxEngine.callPSTN('some_phone_number');
  5. // Start from detecting voicemail tone in pre-connected state
  6. call.addEventListener(CallEvents.AudioStarted, function (e) {
  7. call.detectVoicemailTone();
  8. });
  9. // Found voicemail tone
  10. call.addEventListener(CallEvents.VoicemailToneDetected, function (e) {
  11. if (!callconnected) {
  12. Logger.write("Voicemail tone detected while earlyMedia. Freq " + e.frequency);
  13. voicemail = true;
  14. } else {
  15. Logger.write("Voicemail tone detected after call connected. Freq " + e.frequency);
  16. }
  17. });
  18. // No voicemail tone found
  19. call.addEventListener(CallEvents.VoicemailToneNotDetected, function (e) {
  20. if (!callconnected) {
  21. Logger.write("Voicemail tone wasn't detected while earlyMedia");
  22. } else {
  23. Logger.write("Voicemail tone wasn't detected after call connected");
  24. }
  25. });
  26.  
  27. // If we haven't detected voicemail yet start voicemail prompt detection algorithm
  28. call.addEventListener(CallEvents.Connected, function (e) {
  29. callconnected = true;
  30. if (!voicemail) call.detectVoicemailPrompt(5);
  31. });
  32. // Voicemail prompt detected
  33. call.addEventListener(CallEvents.VoicemailPromptDetected, function (e) {
  34. Logger.write("Voicemail prompt detected. Pattern: " + e.pattern);
  35. voicemail = true;
  36. // need to re-launch detectVoicemailTone here if we need to find the tone
  37. });
  38. // We can assume that we have reached a live person
  39. call.addEventListener(CallEvents.VoicemailPromptNotDetected, function (e) {
  40. Logger.write("Live person detected. Pattern: " + e.pattern);
  41. });

So in case when reached voicemail our voicemail variable will be set to true, otherwise it will be set to false. Developer can make a decision depending on the data while forwarding call to free operator using ACD and CallList modules for predictive dialing.

Comments