Methods

Reference for the JavaScript methods available on the Glassix agent widget client

This page documents the JavaScript methods available to programmatically control the Glassix agent widget after initialization, including retrieving its iframe URI, logging out the current agent, and switching the active ticket.

Overview

Before you can trigger any programmatic actions on the Glassix agent widget, the core initialization script must be completely loaded on your website. Once loaded, the widget client instance is available agentClient and ready to receive method calls.

getIframeUri

Returns a promise that resolves to the URI to use as the iframe source. Use this method if you want to embed the agent widget in your own iframe instead of the default widget.

agentClient.getIframeUri().then(function (uri) {
  var iframe = document.getElementsByTagName("glassix-agent-iframe")[0];
  iframe.src = uri;
});
🚧

This method does not support the destroy and attach methods. If you are embedding the widget via iframe using getIframeUri, you do not need to call destroy() or attach() on it.

destroy

Removes the widget instance from both the DOM and memory.

agentClient.destroy();

attach

Attaches the widget to the DOM. This method is called automatically after the script is loaded; you do not need to call it explicitly.

agentClient.attach();

logout

Logs the currently signed-in agent out of the widget.

agentClient.logout();

A common use case is calling this method when an agent logs out of your internal system, so the widget's session stays in sync with your application's authentication state.

setCurrentTicket

Sets the currently active ticket in the widget, identified by the ticket ID and department ID.

agentClient.setCurrentTicket(ticketId, departmentId);

This is useful if you want to deep-link an agent directly into a specific conversation, for example, opening the widget already focused on a ticket referenced elsewhere in your internal tools.