Skip to main content
This widget is being rolled out. Interfaces on this page may change before general availability. The engineering documentation site, which tracks the current build, is at webchat.connectly.ai/docs.
Which API you get depends on which integration you chose.
  • The script tag publishes a page global, window.ConnectlyWebchat.
  • The npm package publishes none โ€” the element itself is the API. Reach it from outside your component tree with document.querySelector('connectly-webchat').

window.ConnectlyWebchat โ€” script tag only

The global is published when the widget bundle executes, so it exists in any tag that runs after the bundleโ€™s โ€” a defer or type="module" tag โ€” and not in a plain inline script. A plain inline script runs during parsing, and the bundle carries defer, so the inline one runs first no matter where on the page you put it. Where you cannot rely on tag order, register a connectly-webchat:ready listener on document (the event bubbles, and fires when the launcher renders โ€” it is not replayed for a listener added later) and use the global from inside that, or place <connectly-webchat> declaratively and skip the global entirely.
init(options) accepts: Calling init() twice does not create a second widget. It returns the existing element and applies any new options to it โ€” except clientKey, which cannot be changed on a live widget. Remove the old integration first if you need a different key. isMounted() asks whether the widget is on the page at all (true from shortly after init() until destroy()); isOpen() asks whether the panel is showing. isOpen() is almost always the one you want, paired with onOpenChange.

<connectly-webchat> โ€” both integrations

The element is registered by the script tag and by the packageโ€™s import alike, and it is the whole API on the npm path. See Configure for the attribute list.
In React, prefer the declarative open / onOpenChange props over reaching for the element โ€” the wrapperโ€™s onOpenChange is exactly the elementโ€™s :open and :close events on its own node.

Opening and closing the panel

The names differ by path โ€” open() / close() exist only on the script tagโ€™s page global, and the elementโ€™s methods are openPanel() / closePanel() โ€” but they are equivalent: the global delegates to the element.

Events

Events are dispatched on the element and are bubbles / composed, so a page-level listener works without holding a reference to the element:
Payloads are on event.detail โ€” see WebchatElementEventDetail in the packageโ€™s types.

Version

WEBCHAT_ELEMENT_VERSION (exported from the package, carried on the ready event, and available as window.ConnectlyWebchat.version on the script-tag path) identifies the widget code. It is the first thing Connectly support will ask for. The npm package carries its own version, on its own schedule; the two are not expected to match.