Making Components Interactive
Learn how to add AI-powered UI components to your chat interface.
Why would we want to make our note components interactive?
- Show interactive components in the message thread
- Share that state with the AI backend to make followup messages more accurate
Previous sections:
We'll use the same note components from the previous section, but make them interactive.
Creating Interactive Components
1. Update the Note Component to Use Hydra State
Use useHydraState
is a hook provided by Hydra to manage the state of the component. It works just like React's useState
hook, but it's synced with the AI backend.
What's happening here:
- Use the
useHydraState
hook to manage the state of the component - State is automatically synced with the AI backend through Hydra's context
We should also make the email component interactive, but we'll save that for you to try out on your own.
What you have now?
- Interactive Note component that can be used in the chat interface
- Now all your message threads will maintain any state changes made by the user!
- State is synced with the AI backend for followup messages
Next Steps
We'll see how to add advanced features.