How to do it
- 01
Install the generated script once. Keep defer for a normal HTML embed. Duplicate executions for the same RelayDesk origin and widget ID reuse the existing instance.
- 02
For your own support button, call window.RelayDesk.open() from its click handler after the SDK is available. Use close() or toggle() to change the panel; show() and hide() control the whole widget. Hiding is a visual choice and does not disable tracking or networking.
- 03
Listen for relaydesk:ready on window before loading the script, or check window.RelayDesk if it already loaded. This event means the website API is available. relaydesk:loaded means the initial widget configuration has arrived. Neither event proves inbox delivery or server availability.
- 04
Use getState() for widget ID, runtime version, configuration-loaded, open, visible and destroyed flags. Window events relaydesk:open, relaydesk:close, relaydesk:visibility and relaydesk:destroy contain the widget ID and RelayDesk origin, without visitor credentials or message content.
- 05
For a launcher hidden initially, add data-start-hidden="true" to the script, then call open() from your own support button. To disable automatic page tracking, use data-track-pages="false". If consent must precede every RelayDesk request, delay loading the script until your consent manager permits it.
- 06
Keep one mounted widget across ordinary SPA route changes and use the existing trackPage() API when appropriate. Call destroy() only when removing the integration; it closes connections and removes listeners and the launcher. Reload the script to mount again. Destroy does not erase saved visitor history.
- 07
Use each relaydesk-chat element’s relaydesk property for multiple widgets. The window.RelayDesk shortcut points to the first available instance. Keep signed identity generation on your server; never put signing secrets in the embed code.