Interactables
Special components that can be modified through natural language conversation.
Interactables are special components that can be attached to a thread and modified through natural language conversation. They enable real-time updates to component state based on user messages in a thread.
When a user says something like "add a row to the table" or "update the chart title", Hydra will automatically identify which interactable they're referring to and update its state accordingly.
Core Concepts
- Interactable Components: Regular components with additional capabilities for state management through conversation
- Thread Attachment: Can be attached to specific messages in a thread
- State Management: Maintains state that can be updated via natural language
- Multiple Instances: Multiple interactables can exist in a single thread
- Mode Transitions: Components can transition between message and interactable modes
Registration
Register an interactable component by adding the isInteractable
flag. This tells Hydra that this component can be updated through conversation:
Attaching to Thread
Attach an interactable as message context. Each interactable needs a unique ID that will be used to reference it in conversations and state updates:
Managing State
Access and update interactable state. The state updates automatically when users modify it through conversation, but you can also update it programmatically:
Managing Mode Transitions
Provider-Based Transition
Start a component in interactable mode using the provider:
Programmatic Transition
Or transition to interactable mode from within the component:
State Management
The useHydraMessage
hook provides unified state management:
Example Flow
- Component starts in message mode
- Transition to interactable mode
- State is preserved during transition (if configured)
- Component continues to work with same API
- State updates now persist independently
Interactive-Only Mode
Sometimes you want to restrict a thread to only handle component interactions, without generating new content. This is useful for focused UI interactions or when building interactive dashboards.
You can create a thread in interactive-only mode:
You can also toggle interactive-only mode for existing threads:
For individual messages, you can restrict them to only update interactables:
Custom Presentation (Canvas Example)
Interactables can be used within your own presentation layer. Here's an example of implementing a Canvas UI that manages layout while letting Hydra handle component state: