Open, close, inject prompts
Programmatic control
Go beyond the floating button. The useYak hook gives you full control to open the chat, inject context-aware prompts, and subscribe to tool events—build help buttons, onboarding flows, or error assistance.
What you get
- open(), close(), and openWithPrompt() methods
- Read widget state with isOpen, isReady, and chatLoading
- Subscribe to tool-completion events for cache invalidation
- Build context-sensitive help buttons
- Create keyboard shortcuts and help menus
How it works
Wrap your app and grab the handle
Mount the Yak provider, then call useYak() (or your framework's equivalent composable or service) anywhere to get open(), close(), openWithPrompt(prompt), state flags, and subscribeToToolEvents().
Wire it to your own UI
Drive your own buttons, keyboard shortcuts, and error boundaries—openWithPrompt() opens the panel and sends a tailored prompt, queuing it automatically if the iframe isn't ready yet.
React to what the assistant does
Subscribe to tool-call completion events (name, args, ok, result or error) to invalidate caches or refresh the page after the assistant modifies data on the user's behalf.
Frequently asked questions
Related features
Ship programmatic control with yak
Add an AI assistant that matches your product—then turn on the features your users need.