Adding Components
Learn how to create and register static display components with Hydra AI.
Let's create the basic components that our CRM assistant will use to display customer notes and emails.
1. Defining Schemas
First, let's define our component schemas with Zod.
What's happening here:
- Define schemas and types first
- Use inferred types in components
- Register components with their schemas
- Schemas are used to generate type-safe props for the component
- They are also used to help the AI understand when to use the component
2. Creating Components
Now let's create our static display components using the inferred types:
3. Registering Components
Now let's register our components with Hydra.
What's happening here:
- Define schemas and types first
- Use inferred types in components
- Register components with their schemas
- Schemas are used to generate type-safe props for the component
- They are alos used to understand when and how to use the component
- Description are added to help the AI understand when and how to use the component
Adding to the Message Thread
Components will appear in the message thread when the AI decides to use them.
These are static display components that the AI will use to show generated notes and email drafts. They are read-only and don't include any interactive features.
What's happening here:
- Messages can contain an optional
component
of typeHydraComponent
HydraComponent
now includes the actual Component directly- Props are passed directly to the component
- No need to look up components in the registry at render time
What you have now?
- Your AI assistant can now display static components in the chat interface!
- Type-safe props and validation through Zod schemas
- Clear component descriptions to help the AI use them appropriately
Next Step
We'll add tools to fetch and manage lead data to provide context for our notes and emails.