Vanilla Agent Demo
This page renders the widget two ways: once through the vanilla initializer and once as a floating launcher wired up to user actions.
The frontend proxy below lives at /api/chat/dispatch
and is powered by a Hono server.
Looking for other examples?
- Agent Editor (Style it visually)
- Directive / interactive form example
- Action middleware / e-commerce example
- Message Feedback Demo (Copy, Upvote, Downvote)
- Feedback Integration Demo
- Client Token Demo (Direct API)
- Client Token Feedback Demo (Automatic Feedback)
- Navigation Persistence Demo (Auto-open after navigation)
- Preview Mode Demo (Show widget only with URL param)
Programmatic Control
The widget controller returned by initAgentWidget provides methods to programmatically control the
widget:
const launcherController = initAgentWidget({
target: "#launcher-root",
config: { /* ... */ }
});
// Open the widget
launcherController.open();
// Close the widget
launcherController.close();
// Toggle the widget (open if closed, close if open)
launcherController.toggle();
You can use these methods with your own UI elements, event handlers, or any JavaScript code. The buttons above demonstrate this functionality.