window.ASTERLIO_API
The widget exposes a global window.ASTERLIO_API. Most integrations should use Commands (window.postMessage). The API below is provided for advanced control.
Interface
interface ASTERLIO_API {
init: (clientId: string) => void
config: { domain: string; version: string }
sendToButton?: (data: any) => void
sendToChat?: (data: any) => void
sendToCta?: (data: any) => void
}
init(clientId)
Initialize the widget programmatically.
// after the loader script is on the page
window.ASTERLIO_API?.init('YOUR_CLIENT_ID')
sendToButton(data)
Post a message to the button iframe.
// toggle button state (advanced)
window.ASTERLIO_API?.sendToButton?.({
type: 'UPDATE_STATE',
payload: { isChatOpen: true }
})
sendToChat(data)
Post a message to the chat iframe.
// forward a command to the chat iframe (advanced)
window.ASTERLIO_API?.sendToChat?.({
type: 'WIDGET_MINIMIZE'
})
sendToCta(data)
Post a message to the CTA iframe.
// show the CTA hover (advanced)
window.ASTERLIO_API?.sendToCta?.({ type: 'BUTTON_HOVER_OPEN' })
config
Read-only metadata about the widget build.
// read widget config
console.log(window.ASTERLIO_API?.config) // { domain, version }
Note: Prefer window.postMessage commands for stability. Direct iframe methods may change, but commands will remain stable.