Custom UI Components
Display rich UI components in your AI responses
Custom UI components are currently only supported in the React version of the widget. If you’re using another framework, you’ll need to use the React widget to enable this functionality.
Instead of plain text responses, your AI can render custom React components to display:
- Interactive forms
- Data visualizations
- Product cards
- Settings controls
- Any custom UI you build
Quick Example
Let’s create a simple weather card component that displays temperature and wind data.
Create an Action
Create a new action called getWeather
that fetches weather data. You can do this either:
- Through the dashboard UI (see Taking Actions guide)
- Via the API (see API Reference)
For this example, we’ll create an action with these parameters:
The action name (getWeather
) is what you’ll use to link your component to this action later.
Create Your Component
Make a new file WeatherCard.tsx
:
Register the Component
Add the component to your widget setup:
How It Works
- When your AI needs to show weather data, it calls the
getWeather
action - The action returns weather data from the API
- The widget finds the matching component (
WeatherCard
) - Your component renders with the action’s data
That’s it! Now when users ask about weather, they’ll see your custom card component instead of plain text.
Component Props
Your components receive these props:
Best Practices
- Use descriptive component and action names
- Handle loading and error states
- Use shadcn/ui components for consistent styling
- Keep components focused and reusable
- Type your action response data
Examples
You can build UI components for:
- Product catalogs
- Booking forms
- Data dashboards
- Settings panels
- File uploads
- And much more!
Need more examples? Check our GitHub repo.
Remember to: - Match component key
with action name - Handle the expected
data structure - Test with loading/error states
Was this page helpful?