- Text input
- Number input
- Date input
- Dropdown
- Checkbox
- Radio buttons
- Textarea
- Slider
- Switches
Manual form generation
Sometimes, you might want to generate a form with a specific set of fields or input options. For example, if you want to generate a form for a trip planning application, you can use the following system prompt:Automatic form generation
In most cases, you don’t need to manually specify a prompt for the form. A better approach is to pass in the tool call for the action you want the agent to perform and let C1 automtically render the form based on the JSON schema of the tool call input parameters. For example if you want to create a AI Jira copilot, rather than manually specifying the form fields, you can pass in the tool call specification for creating a Jira issue and let C1 automatically render the form based on the JSON schema of the tool call input parameters.src/api/route.ts
Handling form submissions
Form submissions can be handled in the same way as general interactivity is handled. When the user fills out the form and clicks on the submit button, theonAction
callback will be called with the form data.
In this case, Thesys SDK will automatically fill the llmFriendlyMessage
with the form data and the action
such that
the appropriate tool call is made to the backend.
Note: If you are building a chatbot, this is already handled for you in the <C1Chat>
component.
Persisting form data
Sometime, you might want to persist the form data in the Generative UI application so that when the user refreshes the page, the form data is not lost. Field data is automatically kept in sync with the user’s input within the context of the same ‘response’ object. Whenever the user updates the form, theupdateMessage
callback will be called with the updated form data merged with
the rest of the response object. Simply pass in a function to the updateMessage
prop that can be used to persist the
entire reponse and form persistence should be handled automatically.
src/app/page.tsx