Class: WidgetMediaUpgradeRequest

Overview

Examples:

Allowing both 'phone' and 'audio' upgrades on 'audio' request

function chooseMedia(requestedMedias) {
  return Promise.resolve(requestedMedias[0]);
}
function askVisitorsPhoneNumber() {
  return Promise.resolve('+12058675309');
}
function getUpgradeOptions(requestedMedias) {
  chooseMedia(requestedMedias).then(function(media) {
    if (media === 'phone') {
      return askVisitorsPhoneNumber().then(function(phoneNumber) {
        return {
          media: 'phone',
          options: {phoneNumber: phoneNumber}
        };
      });
    } else {
      return Promise.resolve({media: media});
    }
  });
}

var engagementRequest = salemove.requestEngagement('text');
engagementRequest.engagementPromise.then(function(engagement) {
  var handleWidgetMediaUpgradeRequests = function(request) {
    getUpgradeOptions(request.medias).then(function(args) {
      return engagement.upgrade(args.media, args.options);
    }).catch(function(error) {
      // Handle error
    });
  };

  engagement.addEventListener(
    engagement.EVENTS.WIDGET_MEDIA_UPGRADE_REQUEST,
    handleWidgetMediaUpgradeRequests
  );
});

Property Summary

(Array) medias

An array of medias requested by the Visitor from the sm-engaged-visitor widget. The possible values are: 'audio', 'phone', 'video'.

(string) media Deprecated

The media requested by the Visitor from the sm-engaged-visitor widget. Is one of: 'audio', 'video'.

Deprecated. Use medias instead.

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: