Class

VisitorApp

VisitorApp

Interface to Visitor App functionality. Used to trigger UI flows programmatically.

Methods

# setChatMessageRenderer(chatMessageRenderer)

Instructs Visitor App to set custom renderer function for chat messages.

Custom rendering function, called with OperatorMessage and must return a HTMLElement or false. When the rendering function returns false value, Visitor App renders the message using default rendering behavior. The custom rendering function will be called with every message in the system.

Throws a NOT_SUPPORTED Error if the site does not have a Visitor App configured.

Parameters:
Name Type Description
chatMessageRenderer function Function to be used to render chat messages.
Example
sm.getApi({version: 'v1'}).then(glia => {
    glia.visitorApp.setChatMessageRenderer(function(message) {
      if(message.metadata && message.metadata.policy_number) {
        var element = document.createElement('div');
        element.innerHTML = 'Your policy number is ' + message.metadata.policy_number;

        return element;
      }
      return false;
    });
  });

# setPhoneNumberDefaultCountry(countryCode)

Changes the default country of Visitor App phone number input.

In case of invalid argument, INVALID_INPUT Error is thrown.

Parameters:
Name Type Description
countryCode string ISO 3166-1 alpha-2 country code (e.g. 'us' or 'uk') of the desired phone number default country.
Example
sm.getApi({version: 'v1'}).then(glia => {
    glia.visitorApp.setPhoneNumberDefaultCountry('ee');
  });

# triggerQueueMediaSelection(queue)

After the visitor selects a medium, the visitor will be queued in the provided Queue.

Throws a NOT_SUPPORTED Error if the site does not have a Visitor App configured or if the Visitor App does not support opening queue media selection.

Parameters:
Name Type Description
queue Queue The queue that is targeted for media selection.