JavaScript API
Control the widget programmatically after the script loads. window.zdAgent exposes the following methods:
zdAgent.send('How do I reset my password?')
zdAgent.open()
zdAgent.close()
zdAgent.toggle()
zdAgent.themeToggle('light')
zdAgent.clearHistory()
zdAgent.pulse()
zdAgent.destroy()
| Method | Description |
|---|---|
send(message) |
Opens the widget and sends the specified message |
open() |
Opens the widget |
close() |
Closes the widget |
toggle() |
Toggles the widget open/closed state |
themeToggle(theme) |
Switches theme ('light' or 'dark') |
clearHistory() |
Clears the chat history for the current session |
pulse() |
Triggers a visual pulse animation on the widget |
destroy() |
Removes the widget from the page |
The API is available after the script loads. For session management, see Resetting Agent Session.