Class: Salemove

Overview

Examples:

Getting the JS SDK as an instance of Salemove

sm.getApi({version: 'v1'}).then(function(salemove) {
  // Your code
});

Allow Visitors to queue for Engagements

var queueView = document.createElement('div');
document.body.appendChild(queueView);

var engagementView = document.createElement('div');
document.body.appendChild(engagementView);

sm.getApi({version: 'v1'}).then(function(salemove) {
  function onQueueStateUpdate(queueState) {
    if (queueState.state === queueState.QUEUE_STATES.CAN_QUEUE) {
      queueView.addEventListener('click', onClickToQueue);
      queueView.innerText = 'Click to queue.';
    } else if (queueState.state === queueState.QUEUE_STATES.QUEUED) {
      showWaitingView(queueState.ticket);
      salemove.getQueueWaitDuration()
        .then(showWaitingViewWithTimer(queueState.ticket));
    } else if (queueState.state === queueState.QUEUE_STATES.CANNOT_QUEUE) {
      queueView.removeEventListener('click', onClickToQueue);
      queueView.innerText = 'Cannot queue.';
    }
  }

  function onClickToQueue() {
    salemove.queueForEngagement('text').catch(showFailedToQueueView);
  }

  salemove.addEventListener(salemove.EVENTS.QUEUE_STATE_UPDATE, onQueueStateUpdate);
  salemove.addEventListener(salemove.EVENTS.ENGAGEMENT_START, showEngagedView);
  salemove.addEventListener(salemove.EVENTS.ENGAGEMENT_END, showNotEngagedView);
});

function showWaitingView(queueTicket) {
  queueView.innerText = 'Hang on.';
  queueView.appendChild(cancelButton(queueTicket));
}

function showWaitingViewWithTimer(queueTicket) {
  return function(waitDuration) {
    queueView.innerText = 'Hang on. This usually takes ' +
      waitDuration.averageDurationInSeconds + ' seconds.';
    queueView.appendChild(cancelButton(queueTicket));
  };
}

function showFailedToQueueView(error) {
  queueView.innerText = 'Failed to queue!';
}

function showEngagedView(engagement) {
  engagementView.innerText = 'Engaged with ' + engagement.operator.name + '!';
}

function showNotEngagedView(engagement) {
  engagementView.innerText = 'Not engaged.';
}

function cancelButton(queueTicket) {
  var button = document.createElement('span');
  button.innerText = ' Click here to cancel.';
  button.addEventListener('click', function() {
    queueTicket.cancel();
  });
  return button;
}

Different behavior depending on how many Operators are available.

var operators = [];

function onOperatorStatusChange(updatedOperator) {
  operators = operators.map(function(operator) {
    if (operator.id == updatedOperator.id) {
      return updatedOperator;
    } else {
      return operator;
    }
  });
  updateElementUI();
}

function onOperatorListChange(updatedOperators) {
  operators = updatedOperators;
  updateElementUI();
}

function updateElementUI() {
  var availableOperators = filterAvailableOperators(operators);
  if (availableOperators.length === 0) {
    alert("No operators are available.");
    // Update application to indicate that no operators are available
  } else {
    alert("At least one operator is now available.");
    // Update application to indicate that at least one operator is available
  }
}

function filterAvailableOperators(operators) {
  return operators.filter(function(operator) {
    return operator.state.available;
  });
}

sm.getApi({version: 'v1'}).then(function(salemove) {
  salemove.addEventListener(salemove.EVENTS.OPERATOR_LIST_UPDATE, onOperatorListChange);
  salemove.addEventListener(salemove.EVENTS.OPERATOR_STATUS_UPDATE, onOperatorStatusChange);
});

Events:

ENGAGEMENT_START

Triggered when an Engagement starts, regardless of whether it was initiated by the Visitor or the Operator. Also triggered when the Engagement is reestablished. The event listener will be called with an Engagement instance.

ENGAGEMENT_END

Triggered when an engagement has ended. The event listener will be called with an Engagement instance.

VISITOR_STATUS_UPDATE

Triggered when the Visitor's status changes. Called with a VisitorStatus instance.

Visitor can have multiple concurrent sessions browsing the application. ENGAGEMENT_START and ENGAGEMENT_END events are only triggered in the browser session where the engagement was started. These events are not triggered in any other browser session.

Other browser sessions may want to hide some parts of the application to avoid Visitor from trying to start an engagement. Only one concurrent engagement is allowed between a Visitor and an Operator on one site. Attempting to establish more than one engagement will fail.

ENGAGEMENT_REQUEST

Triggered when an Operator has requested to start an engagement with the current Visitor.

OPERATOR_LIST_UPDATE

Triggered when any of the Operators either comes online or goes offline. Also triggered for every listener immediately when the listener is added. The event listener will be called with an array of up to date online Operator instances.

Operator is considered online whenever they are logged into the system. Thus Operator can be unavailable (on a break, engaged with another Visitor) while still being online.

OPERATOR_STATUS_UPDATE

Triggered when any of the Operators' state (availability, media) changes. The event listener will be called with an updated Operator instance.

CONNECTION_STATUS_UPDATE

Triggered when the client either loses or regains the connection to SaleMove services which are required for operation. The event listener will be called with a ConnectionStatus instance.

QUEUE_STATE_UPDATE

Visitor is not always able to join the queue. For instance, there might be cases when there are no Operators available or the queue is full (it reached the maximum length). Therefore Visitor needs to be aware of the state of the queue to take the corresponding action. For more information about the queue states see AggregateQueueState.

The event is triggered whenever the state of the queue changes. Also triggered for every listener immediately when the listener is added. The event listener will be called with a AggregateQueueState instance.

Property Summary

(VisitorApp) visitorApp

An object that exposes VisitorApp functionality. Can be used to trigger UI flows programmatically. Note that if no Visitor App is configured for the Site, all VisitorApp methods throw a NOT_SUPPORTED Error.

(Omnibrowse) omnibrowse

An object with Omnibrowse specific functionality.

(Omnicall) omnicall

An object with Omnicall specific functionality.

(Overseer) overseer

An object with Overseer specific functionality.

(Config) config

An object with Config specific properties.

Variables Summary

ERRORS =
{
  INVALID_INPUT: 'invalid input',
  OPERATOR_UNAVAILABLE: 'operator unavailable',
  INTERNAL_ERROR: 'internal error',
  RESOURCE_NOT_FOUND: 'not found',
  OPERATOR_DECLINED: 'operator declined',
  DECLINE: 'decline',
  CANCEL: 'cancel',
  TIMEOUT: 'timeout',
  NETWORK_TIMEOUT: 'network timeout',
  CONNECTION_LOST: 'connection lost',
  TOO_MANY_REQUESTS: 'too many requests',
  FORBIDDEN: 'forbidden',
  NOT_SUPPORTED: 'not supported',
  DISABLED: 'disabled',
  ALREADY_QUEUED: 'already queued',
  ALREADY_ENGAGED: 'already engaged',
  CONFLICT: 'conflict'
}
EVENTS =
{
  ENGAGEMENT_END: 'sm:engagement:end',
  ENGAGEMENT_START: 'sm:engagement:start',
  VISITOR_STATUS_UPDATE: 'sm:visitor_status:update',
  ENGAGEMENT_REQUEST: 'sm:engagement:request',
  OPERATOR_LIST_UPDATE: 'sm:operator_list:update',
  OPERATOR_STATUS_UPDATE: 'sm:operator_status:update',
  CONNECTION_STATUS_UPDATE: 'sm:connection_status:update',
  QUEUE_STATE_UPDATE: 'sm:queue:update'
}

Instance Method Summary

Instance Method Details

# (void) addEventListener(type, listener)

This method allows registration of event listeners on the API.

If a listener is added while the API 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:

  • type ( string ) The event type for which the user is registering. Must be one of Salemove.EVENTS.
  • listener ( function ) The listener function that will be called when the event occurs.

# (void) removeEventListener(type, listener)

This method allows the removal of event listeners from the API.

If an event listener is removed while the API 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:

  • type ( string ) The event type for the listener being removed.
  • listener ( function ) The event listener to be removed.

# (Object) getRequestHeaders()

Returns a hash of the headers and values that are required for the Visitor to authenticate with the API.

Examples:

Making an XHR request with required headers

sm.getApi({version: 'v1'}).then(function(salemove) {
  var xhr = new XMLHttpRequest();
  xhr.open('GET', 'https://api.salemove.com/visitor');

  var requestHeaders = salemove.getRequestHeaders();
  Object.keys(requestHeaders).forEach(function(key) {
    xhr.setRequestHeader(key, requestHeaders[key]);
  });

  xhr.onload = function() {
    if (xhr.status >= 200 && xhr.status < 300) {
      // Handle success
    } else {
      // Handle negative response from server
    }
  };
  xhr.onerror = function() {
    // Handle failure
  };
  xhr.send();
});

Returns:

  • Object

# (String) getSessionContext()

Returns a string representing the Visitor and the current tab.

This function should be used to obtain the Visitor session when a Visitor navigates within your domain(s) and SaleMove is unable to restore the Visitor's session after navigation. This can occur when Visitor is redirected from one URL to another and has 3rd party cookies disabled.

This function should only be used to re-establish across navigations, re-establishing the context works in a limited timeframe from the moment it was acquired.

To re-establish a session, the String acquired from this function must be specified as 'session_context' query parameter in the SaleMove integration script.

This value is specific to the browser tab that it was acquired from. It must be used in the same tab or in a new tab given that the previous tab has closed. Having the same context in multiple tabs results in the previous tab disconnecting from SaleMove.

Examples:

Acquiring session context and re-establishing a session

sm.getApi({version: 'v1'}).then(function(salemove) {
  var sessionContext = salemove.getSessionContext();

  // The sessionContext value must be carried through your system and
  // tied to the same Visitor tab.
  postFormThatNavigatesVisitor(yourFormData, sessionContext);
});

// When including SaleMove integration script for the same Visitor on a new page:

<head>
  <script async src="//api.salemove.com/salemove_integration.js?session_context=SESSION_CONTEXT_FROM_PREVIOUS_PAGE />
</head>

Returns:

  • ( String ) — Opaque string containing Visitor session context

# (void) setupContactOperatorButton(args)

Deprecated. Use Salemove#requestEngagement in conjunction with OPERATOR_LIST_UPDATE event to create a custom solution.

Sets up a custom buttons for contacting an Operator.

Parameters:

  • args ( Object )

Options Hash: (args):

  • withOperatorsHtml ( string ) The HTML to use to override the default button visuals when there is at least one Operator available. If an empty string is provided then nothing will be shown.
  • withoutOperatorsHtml ( string ) The HTML to use to override the default button visuals when there are no Operators available. If an empty string is provided then nothing will be shown.
  • withoutOperatorsCallback ( function ) The function to call when the button is clicked while there are no Operators available.

# (EngagementRequest) requestEngagement(media, options)

Sends an engagement request.

Examples:

Requesting a 'text' engagement

sm.getApi({version: 'v1'}).then(function(salemove) {
  var engagementRequest = salemove.requestEngagement('text');
  engagementRequest.engagementPromise.then(function(engagement) {
    ...
  }).catch(function(error) {
    if (error.cause === salemove.ERRORS.OPERATOR_DECLINED) {
      ...
    } else {
      ...
    }
  });
});

Parameters:

  • media ( string ) The starting media for the Engagement. Must be one of Engagement.MEDIA_TYPES.
  • options ( Object )

Options Hash: (options):

  • phoneNumber ( ?string ) The Visitor's phone number in E.164 format to use when starting media is 'phone'.
  • oneWay ( ?boolean ) When set to true, only the Operator will have the requested media, while the Visitor's media will be 'text'. This option is invalid if the specified media is 'text' or 'phone'. See also: One-Way.
  • operatorId ( ?string ) The ID of the Operator to engage.

Returns:

# (Promise) queueForEngagement(media, options)

Enqueues the Visitor for Engagement.

On high-traffic Sites, Visitors looking for Engagements can greatly outnumber the available Operators. To be able to still provide best possible user experience under these circumstances, SaleMove provides a way for Visitors to queue for Engagements. Visitors who have entered the queue will, in turn, be Engaged with an appropriate Operator as soon as one becomes available.

See the Allow Visitors to queue for Engagements example above to see how to use this method in combination with the QUEUE_STATE_UPDATE events to build a complete flow.

The returned Promise will be rejected with cause DISABLED if queuing is disabled for the current Site. Whether queuing is enabled can be checked from Config.queuingEnabled.

Parameters:

Options Hash: (options):

  • phoneNumber ( ?string ) The Visitor's phone number in E.164 format to use when starting media is 'phone'.
  • oneWay ( ?boolean ) When true, only the Operator will have the requested media, while the Visitor's media will be 'text'. This option is invalid if the specified media is 'text' or 'phone'. See also: One-Way.
  • queueId ( ?string ) When given an ID representing an existing Queue for the current Site the Visitor will be queued in the specified Queue. This is useful when a Site has several Queues staffed by different Teams. The media parameter provided must be one of the media types available for the provided Queue ID. The promise will be rejected with AlreadyQueuedError if consecutive requests differ in the provided Queue ID or media selection.

Returns:

  • ( Promise ) — Fulfilled with an empty object or rejected with an Error if the process fails for any reason. The Error may have one of the following causes: INVALID_INPUT, DISABLED, INTERNAL_ERROR, ALREADY_QUEUED, NETWORK_TIMEOUT, FORBIDDEN

# (Promise) getQueueWaitDuration()

Gets information about the expected wait time for queued Visitors.

This information gives Visitors an idea of how long they will likely have to wait after queuing for Engagement before they will be Engaged with an Operator.

The returned Promise will be rejected with cause DISABLED if queuing is disabled for the current Site. Whether queuing is enabled can be checked from Config.queuingEnabled.

Returns:

  • ( Promise ) — Fulfilled with a QueueWaitDuration instance or rejected with an Error if the process fails for any reason. The Error may have one of the following causes: DISABLED, INTERNAL_ERROR, NETWORK_TIMEOUT

# (Promise) getQueues()

Gets a list of all Queues.

This information can be used to subscribe to Queue state updates using Salemove#subscribeToQueueStateUpdates or to enqueue by Queue ID using Salemove#queueForEngagement.

The returned Promise will be rejected with cause DISABLED if queuing is disabled for the current Site. Whether queuing is enabled can be checked from Config.queuingEnabled.

Returns:

  • ( Promise ) — Fulfilled with an array of Queue instances or rejected with an Error if the process fails for any reason. The Error may have one of the following causes: DISABLED, FORBIDDEN, INTERNAL_ERROR, NETWORK_TIMEOUT

# (void) subscribeToQueueStateUpdates(queueIds, listener)

Subscribes to state updates of one or multiple Queues.

Compared to QUEUE_STATE_UPDATE event, which provides AggregateQueueState updates, this allows to subscribe to Queue state updates of a specific Queue. This can be useful when there is a need to have multiple integration points, for example buttons, corresponding to different Queues.

Examples:

Subscribing to all Queues state updates

salemove.getQueues().then(function(queues) {
  var queueIds = queues.map(function(queue) {
    return queue.id;
  });
  salemove.subscribeToQueueStateUpdates(queueIds, function(queue) {
    var button = findButtonByQueue(queue.id);
    if (queue.state.status === queue.state.STATUSES.OPEN) {
      updateQueueButtonMedia(queue.state.medias);
      showQueueButton(button);
    } else {
      hideQueueButton(button);
    }
  })
});

Parameters:

  • non-empty ( string[] ) queue ID list of the Queues to subscribe to
  • listener ( function ) The listener function that is called when a Queue state update occurs. The listener is called with the updated Queue instance.

Throws:

  • ( Error ) — An Error with INPUT_ERROR cause is thrown if the provided params are invalid or undefined.

# (Promise) leaveMessage(args)

Leaves a message for the Operators.

This message will be included in inbox_message exports.

Either phone or email must be specified.

Parameters:

  • args ( Object )

Options Hash: (args):

  • name ( ?string ) A name to include in the message
  • phone ( ?string ) A phone number to include in the message
  • email ( ?string ) An email address to include in the message
  • message ( ?string ) The text body of the message

Returns:

  • ( Promise ) — Fulfilled with an empty object or rejected with an Error if the process fails for any reason. The Error may have one of the following causes: INVALID_INPUT, INTERNAL_ERROR, NETWORK_TIMEOUT.

# (Promise) leaveOperatorMessage(args)

Leaves a message for the Operator.

This message will be included in operator_message exports.

Operator ID and either phone or email must be specified.

Parameters:

  • args ( Object )

Options Hash: (args):

  • operatorId ( string ) The ID of the Operator who will receive the message
  • name ( ?string ) A name to include in the message
  • phone ( ?string ) A phone number to include in the message
  • email ( ?string ) An email address to include in the message
  • message ( ?string ) The text body of the message

Returns:

  • ( Promise ) — Fulfilled with an empty object or rejected with an Error if the process fails for any reason. The Error may have one of the following causes: INVALID_INPUT, INTERNAL_ERROR, NETWORK_TIMEOUT.

# (Promise) updateInformation(args)

Update current Visitor's information.

The information provided by this endpoint is available to all the Operators observing or interacting with the Visitor. This means that this endpoint can be used to provide additional context about the Visitor to the Operators. For example, if a Visitor is logged into the current site and their name and email are recorded on their profile, then taking the data from the profile and passing it into this endpoint helps the Operators see the real names and emails of every logged in Visitor even before they start a conversation.

In a similar manner custom attributes can be also be used to provide additional context. For example, if your site separates paying users from free users, then setting a custom attribute of 'user_type' with a value of either 'free' or 'paying' depending on the Visitor's account can help Operators prioritize different Visitors.

Examples:

Updating current Visitor's phone

sm.getApi({version: 'v1'}).then(function(salemove) {
  salemove.updateInformation({
    phone: '+10000000000'
  }).then(function() {
    ...
  }).catch(function(error) {
    if (error.cause == salemove.ERRORS.NETWORK_TIMEOUT) {
      ...
    } else {
      ...
    }
  });
});

Parameters:

  • args ( Object )

Options Hash: (args):

  • name ( ?string ) The Visitor's name
  • phone ( ?string ) The Visitor's phone number
  • email ( ?string ) The Visitor's email address
  • customAttributes ( ?Object ) An object with custom key-value pairs to be assigned to the Visitor. The server treats all keys and values as strings and also returns them as strings. Nested key-value pairs are not supported.
  • externalId ( ?string ) The Visitor's unique identifier in scope of the current Site. Valuable information about the current Visitor may often be available in CRMs and other systems external to SaleMove. This field allows matching the Visitor to their record in such CRMs and other external systems. For example, a Visitor can have an ID within Salesforce. By setting the 'external_id' to the current Visitor's Salesforce ID, they can easily be matched to their record within Salesforce.

Returns:

  • ( Promise ) — Fulfilled with an empty object or rejected with an Error if the process fails for any reason. The Error may have one of the following causes: INVALID_INPUT, TOO_MANY_REQUESTS, INTERNAL_ERROR, NETWORK_TIMEOUT.

# (boolean) isInEngagement()

This method allows to find out if the Visitor is currently in an engagement.

Returns:

  • ( boolean ) — true if the Visitor is in engagement, false otherwise

# (Promise) willNavigate() Bound

Notifies SaleMove platform of an upcoming navigation with intention to return.

SaleMove may lose connection with the browser for many reasons: the Visitor might lose their internet connection, they might close the browser tab or window, or they might navigate to another page. In some of these cases the Visitor might return shortly, for example when they're navigating to another page on the same website, but in other cases they will not be returning any time soon.

When the Visitor has left for good, the Operators would like to know immediately so that they wouldn't start observing Visitors who have already left or wouldn't be stuck in an engagement where the second party is not responding and will not be returning. On the other hand, when the Visitor will be returning shortly, the Operators would like to avoid seeing the Visitor popping in an out of their Visitor list or having their engagement drop during every navigation.

Because of these needs and because the reconnection delay may vary greatly for different Visitors, to guarantee a good user experience it is paramount to know immediately, at the time of navigation, whether the Visitor will be returning or not. SaleMove uses DOM interaction based heuristics to predict whether the Visitor will be returning. As most navigations happen right after the Visitor has interacted with the page, e.g. clicked a button or a hyperlink, the heuristics are good enough to get most predictions right. However, if the navigation happens after a significant delay or is invoked by less common triggers such as mouse gestures, for example, it can be impossible to predict without knowing more about the specific site's setup.

This endpoint is provided for exactly these scenarios. If in your application you notice engagements dropping often during a particular Visitor navigation then you can call this method right before invoking the navigation, to let the SaleMove platform know that the Visitor will likely be returning shortly. If for whatever reason the Visitor doesn't navigate right after a successful invocation of this endpoint, the behavior will be reset.

Examples:

Navigating user to a success page after processing a form that takes a long time to process

var button = document.querySelector('button.submit');
button.addEventListener('click', function() {
  processForm.then(function(resultURL) {
    sm.getApi({version: 'v1'}).then(function(salemove) {
      return salemove.willNavigate();
    }).then(function() {
      window.location.href = resultURL;
    });
  });
});

function processForm() {
  var form = document.querySelector('form');
  return new Promise(function(resolve, reject) {
    var xhr = new XMLHttpRequest();
    xhr.onload = function() {
      var resultURL = ...
      resolve(resultURL);
    };
    xhr.onerror = function() {
      reject();
    };
    xhr.open('POST', 'https://your.domain.com/form/processing');
    xhr.send(new FormData(form));
  });
}

Navigating after a mouse gesture

var gestureDetector = ... // Left as an exercise for the reader

gestureDetector.addEventListener('swipe_right', function() {
  var currentPageNumber = ...
  sm.getApi({version: 'v1'}).then(function(salemove) {
    return salemove.willNavigate();
  }).then(function() {
    window.location.href = '#page=' + (currentPageNumber + 1);
  });
});

gestureDetector.addEventListener('swipe_up', function() {
  sm.getApi({version: 'v1'}).then(function(salemove) {
    return salemove.willNavigate();
  }).then(function() {
    window.location.href = '..';
  });
});

Returns:

  • ( Promise ) — Fulfilled with an empty object or rejected with an Error if the process fails for any reason. The Error may have one of the following causes: INTERNAL_ERROR.

# (void) setIncomingEngagementRequestHandler(handler)

Overwrites the handler for incoming engagement requests.

Examples:

Handling an incoming request

sm.getApi({version: 'v1'}).then(function(salemove) {
  salemove.setIncomingEngagementRequestHandler(function(request) {
    promptUserToAcceptOrDeclineEngagement(request.timeout).then(function(accepted) {
      if accepted {
        return request.accept()
      } else {
        return request.decline().then(function() {
          return Promise.reject('User declined.');
        });
      }
    }).then(function() {
      return promptUserToSelectMedia();
    }).then(function(mediaSelection) {
      if mediaSelection.canceled {
        return request.decline().then(function() {
          return Promise.reject('User declined during media selection.');
        });
      } else {
        return request.selectMedia(mediaSelection.media, mediaSelection.options);
      }
    }).then(function() {
      return request.engagementPromise;
    }).then(function(engagement) {
      ...
    }).catch(function(error) {
      if (error.cause === salemove.ERRORS.TIMEOUT) {
        ...
      } else {
        ...
      }
    });
  });
});

function promptUserToAcceptOrDeclineEngagement(timeout) {
  var accepted = true;
  return Promise.resolve(accepted);
}

function promptUserToSelectMedia() {
  return Promise.resolve({
    canceled: false,
    media: 'phone',
    options: {
      phoneNumber: '+12168675309'
    }
  });
}

Parameters:

  • handler ( function ) The handler to use for incoming engagement requests. When an Operator 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.

# (void) setEngagementReestablishHandler(handler)

Sets the engagement reestablishing handler.

This method provides a way to control what happens when an engagement has been reestablished. It is suggested that this handler is set immediately on every page load. As engagements are always reestablished shortly after page load then setting this handler immediately helps ensure the correct behavior for every engagement reestablish.

The engagement will still be reestablished even if no handler is set. However, not setting an handler to give visual feedback to the Visitor about the ongoing engagement may create a bad user experience for the Visitor.

Examples:

Adding an sm-engaged-operator widget onto the page after an engagement has been reestablished

sm.getApi({version: 'v1'}).then(function(salemove) {
  salemove.setEngagementReestablishHandler(function(engagement) {
    var engagedOperator = document.createElement('sm-engaged-operator');
    document.body.appendChild(engagedOperator);
  });
});

Parameters:

  • handler ( function ) The handler to use when reestablishing engagement. When engagement has been reestablished, this handler will be called with a single argument. The argument is an Engagement.

# (void) changeElementAttributesForCobrowsing(element, changeElementAttributes)

Change element's attributes when element is mirrored to Operator during CoBrowsing.

Before the element is mirrored to the Operator and after every change to the element's attributes, changeElementAttributes will be called with the attributes of the element. The element that is mirrored in the Operator's CoBrowsing area will have the exactly the attributes of changeElementAttributes return value. The element's attributes will not be changed in the Visitor's browser.

Every element can only have one attribute change function associated with it. When this function is called multiple times with the same element, the attributes that were received from previous changeElementAttributes are discarded and the new changeElementAttributes return value is used instead. If this function is called during CoBrowsing, the changed element attributes are immediately propagated to the Operator's CoBrowsing area using the new function.

If an element no longer needs to be changed for CoBrowsing, the identity function can be passed as changeElementAttributes.

salemove.changeElementAttributesForCobrowsing(element, function(attributes) {
 return attributes;
});

Examples:

Display a placeholder iframe instead of a payment iframe in the Operator CoBrowsing area

sm.getApi({version: 'v1'}).then(function(salemove) {
  salemove.changeElementAttributesForCobrowsing(paymentIframe, function(attributes) {
    attributes.src = attributes.src.replace("payment.html", "payment-placeholder.html");
    return attributes;
  );
);

Parameters:

  • element ( Element ) A DOM Element which will be changed using changeElementAttributes when it gets mirrored to Operator browser.
  • changeElementAttributes ( function ) A function that is called when the element is mirrored to Operator's CoBrowsing area. This function is called with a single argument which is an ordinary JavaScript object which enumerates current attributes of the specified element. The return value of changeElementAttributes is used as the element attributes when the element is mirrored to Operator's CoBrowsing area.

# (void) setLocale(locale)

Set the locale for the Visitor Application provided by SaleMove.

Upon initialization the Visitor Application is set to the locale configured for the Site. This function can be used to change the locale of the Application at any time after initialization.

Parameters:

  • locale ( string ) The locale to which to switch the Visitor Application. The parameter provided needs to be a valid IETF language tag. For example 'en-US' for US English. Note that not all locales are supported.

Throws:

  • ( Error ) — An Error with INPUT_ERROR cause is thrown if the provided locale is not supported.

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: