Events and lifecycle

Coordinate application code with the Assistant ready callback and DOM connection event.

Two lifecycle hooks are publicly documented: the ready command callback and the tdAssistantConnected DOM event.

Ready callback

Use ready for SDK commands that require the Assistant to be initialized.

Assistant('ready', () => {
  Assistant('identify', currentCustomer);
  Assistant('open');
});

DOM connection event

Use tdAssistantConnected when code needs the rendered <thrivedesk-assistant> element or its Shadow DOM.

document.addEventListener('tdAssistantConnected', (event) => {
  const assistantElement = event.target;
  console.log('Assistant element connected', assistantElement);
});

Register the listener before initialization so a fast load cannot race past it.

Event availability

Public documentation does not currently define open, close, or message sent event contracts. Do not depend on similarly named browser events unless ThriveDesk documents them here.