Skip to navigation

JavaScript API

View as Markdown

The web SDK exposes window.zorvia after its script loads.

init(config)

Initializes and mounts Messenger. It returns a promise.

await window.zorvia.init({
workspaceUrl: "https://{workspace}.zorvia.io",
livechatKey: "YOUR_PUBLIC_MESSENGER_KEY",
});

Required configuration:

OptionTypeDescription
workspaceUrlstringYour Zorvia workspace URL, such as https://{workspace}.zorvia.io.
livechatKeystringThe channel’s public messenger key.

open() and close()

Programmatically control the Messenger panel:

window.zorvia.open();
window.zorvia.close();

identify(data)

Associates the active visitor session with a server-signed identity. It returns a promise. Follow the visitor identification flow to create the signed payload.

destroy()

Disconnects real-time updates, unmounts Messenger, and removes its container:

window.zorvia.destroy();

Errors

Rejected init() and identify() promises use a ZorviaError with code, operation, and an optional statusCode.

  • configuration_error — A required SDK configuration value is missing or invalid.
  • authentication_error — The public messenger key could not be authenticated. The status code is 401.
  • forbidden — The current domain is not allowed to use the Zorvia Messenger channel. The status code is 403.
  • validation_error — The request sent by the SDK failed validation. The status code is 422.
  • network_error — The SDK could not reach Zorvia, or Zorvia returned a server error.
  • initialization_failed — Zorvia Messenger could not initialize.
  • identification_failed — The SDK could not identify the visitor.
  • unknown_error — An unexpected error occurred.