Widget JavaScript API & Controls
When the widget script loads on your page, it automatically registers a global `window.ToolsWalletWidget` controller object, enabling full programmatic control from your custom buttons, menus, or checkout workflows.
1. Global window.ToolsWalletWidget API
Once widget.js is loaded on your page, you can interact with the widget directly from any script tag or UI component.
2. Available JavaScript Methods
The following methods are available on the global controller object:
| Method | Parameters | Description |
|---|---|---|
| window.ToolsWalletWidget.open() | None | Opens the chat window and focuses the message input. |
| window.ToolsWalletWidget.close() | None | Minimizes and closes the active chat window. |
| window.ToolsWalletWidget.toggle() | None | Toggles between open and minimized chat states. |
| window.ToolsWalletWidget.send(text) | string | Pre-fills and automatically submits a question to the assistant. |