SDK reference
Use the Zoom Customer Experience SDK for web to control chat and video window behavior programmatically. For example, triggering the visibility of the interface based on user interactions.
Handling events
Use the on and off methods to handle SDK events.
// Listen for an event
window.zoomCampaignSdk.on("open", () => {
console.log("Campaign opened");
});
// Remove event listener - if only the event parameter is passed, it unsubscribes all callback functions from the event
window.zoomCampaignSdk.off("open");
// Remove specific event listener - if the event and callback function are passed, only that function will be unsubscribed for that event
window.zoomCampaignSdk.off("open", specificCallback);
Events reference
| Event | Emits when ... |
|---|---|
open | The user selects the invitation. It directly opens the chat engagement window or, if configured, the welcome screen. |
close | The user minimizes the chat engagement window. |
show | A campaign invitation appears either automatically by the system on page load, or when the show() method is called. |
hide | The campaign invitation is hidden. |
engagement_started | When the engagement starts. |
engagement_ended | When the engagement ends, the system evaluates the termination conditions and emits an engagement_ended event.Normal endings do not include a reason. Exceptional endings include a standardized reason value to explain why the engagement ended. There are three exception reasons that may be emitted.session_expired - Authentication or session authorization expired.session_inactivity - Engagement timed out due to consumer inactivity or agent ended before consumer closed the browser tab.server_error - Engagement terminated due to a server-side failure. |
Methods reference
| Method | Description |
|---|---|
ChangeCampaign(id, channel?) | Switches to the specified campaign.Parameters• id - campaign ID• channel? - optional channel |
close() | Closes the open chat engagement window.No parameters are required.The method applies when the user views the Welcome Screen or the actual chat engagement window. It also applies to whether a current open engagement exists or not.If the chat engagement window isn't open, then an error is thrown and no action is taken. |
endChat() | Ends an ongoing chat engagement.Users can choose Start a New Chat to start a new engagement.The chat engagement window should remain open.No parameters are required.If the method is called when an engagement is not currently open, the method throws an error and no action is taken. |
hide() | Hides all or specific campaign invitations, based on campaigns available on the page.If an engagement window is open, the method should throw an error and no action should be taken. |
show() | Shows all or specific campaign invitations, based on campaigns available on the page.If an engagement window is open, the method throws an error and no action is taken. |
updateUserContext() | Collects and updates user variables again.Used when the customer wants to refresh or update the variables during an active chat session. |
waitForInit() | Returns a Promise that waits for the SDK initialization to complete.This function, or property returning a function, resolves once the initialization process has finished. |
waitForReady() | Returns a Promise that waits for the SDK to be ready.Ensures your code doesn't call SDK methods before the SDK is fully initialized and operational. |