AgentStack Docs

Listen for widget events

Measure and coordinate the embedded chat experience without scraping it.

Widget events let the host page observe supported moments in an embedded conversation without reading private widget state or scraping rendered messages. Register listeners during the same lifecycle that creates the embed, and remove them when the page or component is torn down. This avoids duplicate analytics when a single-page app navigates or remounts its chat launcher.

Use events for host-page concerns such as opening a support panel, recording an interaction in your own analytics system, or adjusting the surrounding layout. Keep the event handler small and resilient: it should tolerate repeated notifications, late arrival after navigation, and an unavailable analytics provider. Do not infer answer quality, user identity, or a completed business action from a visual event alone.

For durable conversation data, use the REST API or an approved MCP integration after the appropriate server-side authorization. Widget event payloads are not a substitute for API credentials, and the embed must never become a path for exposing an organization API key in browser JavaScript.