Class

Omnicall

Omnicall

Omnicall provides numbers that are valid phone numbers unique for every Visitor. Calling the number will automatically start an engagement for the Visitor granted there are any Operators available and they accept the engagement. When the engagement starts, audio from the Visitor's phone will be connected to the engagement and will be audible for the Operator. Replacing more general phone numbers in the application with phone number received from a Omnicall#event:PHONE_NUMBER_AVAILABLE event will allow quickly identifying Visitors calling in for support.
Deprecated:
  • Omnicall module has been deprecated and will be removed

Members

object

# EVENTS

Properties:
Name Type Description
ENGAGEMENT_REQUEST string
PHONE_NUMBER_AVAILABLE string

Methods

# addEventListener(_type, _listener)

This method allows registration of event listeners on Omnicall. If a listener is added while Omnicall is processing an event, it will be not triggered with the current event. If multiple identical listeners are registered on the same event type the duplicate instances are discarded. They do not cause the listener to be called twice and do not need to be removed with the removeEventListener method.
Parameters:
Name Type Description
_type string The event type for which the user is registering. Must be one of Omnicall#EVENTS.
_listener function The listener function that will be called when the event occurs.

# removeEventListener(_type, _listener)

This method allows the removal of event listeners from Omnicall. If an event listener is removed while Omnicall is processing an event, it will not be triggered with the current event. An event listener is never invoked after being removed. Calling removeEventListener with arguments which do not identify any currently registered listener has no effect.
Parameters:
Name Type Description
_type string The event type for the listener being removed.
_listener function The event listener to be removed.

Events

# ENGAGEMENT_REQUEST

Triggered when the Visitor calls a phone number provided by a PHONE_NUMBER_AVAILABLE event. Omnicall will automatically create an EngagementRequest on behalf of the Visitor. The event listener will be called with that EngagementRequest instance.
Example

Add an sm-engaged-operator widget onto the page after Omnicall initiated engagement request was accepted

    salemove.omnicall.addEventListener(
      salemove.omnicall.EVENTS.ENGAGEMENT_REQUEST,
      function(engagementRequest) {
        engagementRequest.engagementPromise.then(function(engagement) {
          var operatorWidget = document.createElement('sm-engaged-operator');
          document.body.appendChild(operatorWidget);
        }).catch(function(error) {
          if (error.cause === salemove.ERRORS.OPERATOR_DECLINED) {
            // Your code
          } else {
            // Your code
          }
        });
      }
    );

# PHONE_NUMBER_AVAILABLE

Triggered when Omnicall provides a phone number to show to the Visitor. The event listener will be called with an OmnicallPhoneNumber instance.
Example

Replace an Omnicall phone number on a page

    function replacePhoneNumberOnPage(from, to) {
      // Your code
    }

    salemove.omnicall.addEventListener(
      salemove.omnicall.EVENTS.PHONE_NUMBER_AVAILABLE,
      function(number) {
        var replacementNumber = number.toString();
        var baseNumber = number.getBaseNumber();

        replacePhoneNumberOnPage(baseNumber, replacementNumber);
        number.addEventListener(number.EVENTS.PHONE_NUMBER_RELEASED, function() {
          replacePhoneNumberOnPage(replacementNumber, baseNumber);
        });
      }
    );