Adding Tools
Learn how to add tools that help your AI assistant work with your data.
Now that we have our note and email components set up, let's add tools that help your AI assistant work with your CRM data. Tools are how your components get the data they need to be useful.
Why associate tools with components?
- Helps provide context to the AI when choosing a component
- Helps the AI generate or fill in the props for the component
1. Define Tool Schemas
First, let's define the schemas for our CRM tools.
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
2. Create Tool Registry
Now let's register our tools using these schemas.
What's happening here:
- Tool definitions specify the schema and description for each tool
- Tool implementations are registered separately with type-safe handlers
- Return types are properly typed to match the expected response schemas
3. Connecting Tools to Components
Now connect these tools to your note and email components.
What's happening here:
- Component registry is generic over the tool registry type
- Props schemas are properly typed to match component props
- Associated tools are type-checked against available tool names
Next Steps
We'll see how to make these components interactive!