Overview
Client-side custom forms enable you to create dynamic, interactive forms that run directly in the user’s browser.Server-side custom form configuration is not currently available. All custom forms must be configured using client-side JavaScript.
Key Benefits
- Real-time validation: Instant feedback as users fill out forms
- Enhanced UX: Smooth interactions without server round trips
- Full customization: Complete control over form appearance and behavior
Prerequisites
A website with the Chatbase embed script already installed and working.
New to Chatbase? Check out Your First Agent to get started with the embed script first.
Setup Guide
1
Create your custom form action
Set up the form configuration in your Chatbase dashboard:

- Navigate to Actions → Create action → Custom form

Creating a new custom form action in the dashboard
- Enter a unique name for your form.
- Configure the form when to use.
- Click on the Save and Continue button.
- Enable the action.

Configuring the form name and when to use
Environment Limitations: Client-side custom forms will not function in:
- Chatbase Playground environment
- Action Preview mode
- Compare features
2
Register your form schema
On your website, register your form schema by calling the
registerFormSchema
method anywhere in your JavaScript code, with the name of the action you created in the dashboard.Register the form in a root page of your website, or in a component that is loaded on every page.
Multiple Registration Override: Calling
registerFormSchema
multiple times will completely replace all previously registered forms. Always include all your forms in a single registration call.Your custom form is now ready to use! The chatbot will automatically display your form when the corresponding action is triggered.
3
Webhooks (Optional)
You can also configure webhooks to receive real-time notifications when users submit your custom forms. For detailed configuration instructions, see Webhooks Integration.

Function Parameters
Each custom form function receives two parameters that provide context and data:Contains all the arguments defined in your custom form configuration. These are the values the ai agent generated and passed from the AI action when the form is triggered.

Contains user information that varies depending on your identity verification setup.
The anonymous IDs (
anon_user_id
and chatbase_anon_id
) are internal identifiers used by Chatbase and can be safely ignored in your custom form implementations.Complete Example
Here’s a comprehensive example showing a user profile form with various field types and validation rules:The function name in your JavaScript code (e.g.,
userProfileForm
) must exactly match the name you assign to your AI Action in the Chatbase dashboard.userProfileForm.js

Example of how the form appears to users
API Reference
Form Schema
TheregisterFormSchema
function returns a schema object that defines your form’s structure and behavior:
Array of form field definitions. Each field must conform to the Field Schema specifications below.
Text displayed on the form’s submit button.
Controls whether field labels are displayed above form inputs.
Message shown to users when the form is successfully submitted.
Message displayed when form submission fails.
Field Schema
Each field in thefields
array supports the following properties:
Unique identifier for the form field. This name is used to reference the field’s value in form submissions.
Specifies the input type. Must be one of the supported field types listed below.
Display text shown to users for this field.
Placeholder text displayed inside the input field. If not provided, the label text is used as placeholder.
Pre-filled value for the field. Type depends on the field type (string for text, number for numeric fields, etc.).
Whether the field should be read-only and non-interactive.
Validation rules for the field. See Validation Rules section below for detailed specifications.
Required for selection fields (
select
, multiselect
, groupselect
, groupmultiselect
).Field Types
Text Input Fields
Text Input Fields
text
- Single-line text input- Supports:
required
,minLength
,maxLength
,pattern
validation - Best for: Names, titles, short descriptions
textarea
- Multi-line text input- Supports:
required
,minLength
,maxLength
validation - Best for: Comments, descriptions, long-form text
email
- Email address input with built-in format validation- Supports:
required
,pattern
validation - Automatically validates email format
phone
- Phone number input- Must follow format:
+[country code][number]
(e.g., +1234567890) - Supports:
required
,pattern
validation - Built-in international format validation
Numeric Fields
Numeric Fields
number
- Numeric input- Supports:
required
,min
,max
validation - Only accepts numeric values
- Best for: Ages, quantities, prices
Selection Fields
Selection Fields
select
- Single selection dropdown- Requires:
options
array with{ value, label }
objects - Supports:
required
validation - Best for: Categories, single choice selections
multiselect
- Multiple selection dropdown- Requires:
options
array with{ value, label }
objects - Supports:
required
validation - Best for: Tags, multiple choice selections
groupselect
- Grouped single selection dropdown- Requires:
options
object with group names as keys - Each group contains array of
{ value, label }
objects - Supports:
required
validation - Best for: Categorized options (e.g., locations by region)
groupmultiselect
- Grouped multiple selection dropdown- Requires:
options
object with group names as keys - Each group contains array of
{ value, label }
objects - Supports:
required
validation - Best for: Multiple selections from categorized options
File Upload Fields
File Upload Fields
image
- Image file upload with drag & drop- Accepts: JPEG, JPG, PNG, GIF, WebP formats
- Maximum size: 2MB per file
- Supports:
required
validation - Features: Drag & drop, preview, format validation
Validation Rules
Each validation rule is defined as an object withvalue
and message
properties:
Basic Validation
Basic Validation
required
- Makes field mandatorypattern
- Regex pattern validationLength Validation
Length Validation
minLength
- Minimum character countmaxLength
- Maximum character countNumeric Validation
Numeric Validation
min
- Minimum numeric valuemax
- Maximum numeric valueError Handling
Error Handling
defaultErrorMessage
- Fallback error messageAdvanced Configuration
Webhooks Integration
Configure webhooks to receive real-time notifications when users submit your custom forms:1
Access action settings
- In the action settings, click on the Webhooks tab.
- Write the webhook URL and click on the Create Wbhook button.

2
Configure webhook endpoint

webhook-handler.js
Troubleshooting
Form not appearing in chatbot
Form not appearing in chatbot
Possible causes:
- Function name mismatch between dashboard and code
- Chatbase script not loaded before
registerFormSchema
call - JavaScript errors preventing form registration
- Verify the function name matches exactly (case-sensitive)
- Ensure proper script loading order
- Check browser console for JavaScript errors
Validation not working properly
Validation not working properly
Possible causes:
- Incorrect validation rule syntax
- Missing required properties in validation objects
- Ensure validation rules have both
value
andmessage
properties - Check field type compatibility with validation rules
- Verify regex patterns are valid JavaScript regex strings
Options not displaying for select fields
Options not displaying for select fields
Possible causes:
- Incorrect options format
- Missing
options
property
- Ensure options follow the correct format for your field type
- Verify all option objects have both
value
andlabel
properties - For grouped selections, check the nested object structure
Best Practices:
- Test your forms thoroughly in your actual website environment
- Keep form schemas simple and focused on specific use cases
- Use clear, descriptive field names and validation messages
- Implement proper error handling for form submissions