Class

Omnibrowse

Omnibrowse

Call Visualizer (former name: OmniBrowse) is a Glia module that allows operators to conduct CoBrowsing in case of phone-first engagements.

Phone-first engagements can be started by operators from anywhere that has the Call Visualizer embedded, such as CRM systems. The functions provided in this class can be used to handle the incoming and re-established phone-first engagements.

Methods

# getVisitorCode() → {Promise}

Gets the VisitorCode for current visitor.

A visitor code is displayed to the visitor when the visitor performs a certain action, usually pressing the Ctrl+Y key combination. The visitor can then inform the operator of their code and operator will use it to start a phone-first engagement with the visitor.

Each visitor code is generated on demand and is unique for every visitor on a particular site. Upon the first time this function is called for a visitor the code is generated and returned. For each successive call thereafter the same code will be returned as long as the code has not expired. The expiration time for visitor codes is 3 hours. During that time the code can be used to initiate an engagement. Once the operator uses the visitor code to initiate an engagement, the code will expire immediately. When the visitor code expires this function will return a new visitor code.

The expiration time is important to take note of if you plan on retrieving the code only once during the visitor's session. A new code should be requested once the initial one has expired. When the visitor provides an expired code to the operator, the operator will not be able to connect to the visitor.

An example use case is operator and visitor being in a phone call. The operator instructs the visitor to press some combination of keys (by default Ctrl+Y) which then causes the visitor code to be displayed to the visitor. The visitor then tells the operator what their code is. When the operator enters the code on their side they will be able to conduct a phone-first engagement with the visitor.

The visitor code is numeric and 5 digits long. It is returned as a String.

Fulfilled with VisitorCode or rejected with Error if the process fails for any reason. The Error may have one of the following causes:

  • INTERNAL_ERROR
  • NETWORK_TIMEOUT
Promise
Example

Showing the visitor code when visitor presses 'B'

  document.addEventListener('keypress', function(event) {
    if (event.code === 'KeyB') {
      sm.getApi({version: 'v1'}).then(function(salemove) {
        salemove.omnibrowse.getVisitorCode().then(showVisitorCode);
      });
    }
  });

  function showVisitorCode(visitorCodeResponse) {
    var visitorCodeContainer = document.createElement('div');
    visitorCodeContainer.textContent = visitorCodeResponse.code;
    document.body.appendChild(visitorCodeContainer);
    setTimeout(function() {
      document.body.removeChild(visitorCodeContainer);
    }, visitorCodeResponse.validDuration);
  }

# setEngagementReestablishHandler(_handler)

Sets the handler for re-establishing phone-first engagements. For usage example see Salemove#setEngagementReestablishHandler.

Parameters:
Name Type Description
_handler function

The handler to use when re-establishing a phone-first engagement. When engagement has been re-established, this handler will be called with a single argument. The argument is an Engagement.

# setIncomingEngagementRequestHandler(_handler)

Overwrites the handler for incoming engagement requests from operators using Call Visualizer. During these engagements Engagement#upgrade is not supported and initial media selection is restricted to 'text' option.
Parameters:
Name Type Description
_handler function

The handler to use for incoming phone-first engagement requests. When an operator using Call Visualizer sends a request, this handler will be called with a single argument. The argument is an IncomingEngagementRequest. See the documentation for IncomingEngagementRequest for instructions on using it.

Example

Handling an incoming phone-first engagement request

  sm.getApi({version: 'v1'}).then(function(salemove) {
    salemove.omnibrowse.setIncomingEngagementRequestHandler(function(request) {
      request.engagementPromise.then(function(engagement) {
        ...
      }).catch(function(error) {
        if (error.cause === salemove.ERRORS.TIMEOUT) {
          ...
        } else {
          ...
        }
      });
      request.accept();
      request.selectMedia('text');
    });
  });