React
Defining the component
AccountBalanceComponent.tsx
WidgetComponentProps
type makes it easy to type your component. It accepts a generic type that describes the shape of the data that will be passed to the component.
The shape of the data is the response of the called action. For example, if you have a getAccountBalance
action which calls your backend, you would know that your backend responds with this shape: { balance: number, currency: string }
, so you can inject this shape into the WidgetComponentProps
generic type, giving you type safety.
Injection
WidgetWrapper.tsx
Headless
Whether you’re doing a Vanilla JavaScript/TypeScript implementation or a headless React implementation, injecting custom components can be done when rendering the AI Agent’s message, it would look like so in React:AIAgentMessage.tsx