NAV Navbar
javascript

.switchWidget()

var newWidgetId = "1234-5678-91011-1213-1415";
var switchCallback = function() {
    // do something
};

SnapEngage.switchWidget(newWidgetId, switchCallback);

Enable switching between two widgets.

We have deprecated the setWidgetId() API to provide a better solution for switching between two widgets and returning a more accurate status to help with your business needs. Additionally, we now offer an optional callback parameter so you can do more when the new status is returned. Here we do not differentiate between online and offline status, however, you can use the getAgentStatusAsync API to call different methods based on the new status.

Parameters

Parameter Type Description
newWidgetId String Required. Must be a valid SnapEngage Widget ID (‘xxxx-xxxx-xxxx-xxx-xxxx’). The new WidgetID you would like to activate. Learn how to set that up here.
switchCallback Anonymous Function A predefined function that will get called after our system completes checking the newWidgetId status.

Returns

Type Description
Boolean Will return false with console warning ONLY if the newWidgetId parameter is not provided. Otherwise no return value provided.

Example switchWidget() Usage

// Setup required parameters
var newWidgetId = "1234-5678-91011-1213-1415";
var switchCallback = function() {
    SnapEngage.getAgentStatusAsync(function(online) {
        if (online) {
            console.log("Chat available");
        } else {
            console.log("Chat offline");
        }
    });
};

// Now call the API
SnapEngage.switchWidget(newWidgetId, switchCallback);