# SDK reference This section provides descriptions of the events and methods you can use with the ZVA web SDK. ## Events | Event | Emits when . . . | | -------------------- | ---------------------------------------------------------------------------------------------------------------------- | | `open` | The user clicks 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. | ## Methods | 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 invitation(s), 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 invitation(s), 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. |