Overview
Custom actions can run on both the server, or on the client. It would be beneficial to run a custom action client-side if the chatbot owner wants more flexibility with the action code, or wants to send an API request on behalf of the user, from the client side.How to Set Up Client-Side Custom Actions
- Embed the Chatbot using the new Script:
- Visit the Chatbase Dashboard.
- Navigate to Connect > Embed.
- Copy the embed code and add it to your application.
Note: If you don’t need to verify the identity of logged-in users, you can skip the first script in the embed code and only use the chatbot embed script.Here’s an example of the embed code you’ll find on the dashboard:

- Create the Client-Side Custom Action:
- Visit the Chatbase Dashboard
- Navigate to Create custom action
- Fill in the required fields, while choosing the type of the action to be client-side.
-
Use the SDK
registerTools
method: Load the Chatbase script and call theregisterTools
method with all the actions and include all the logic that will run when each action is called. The action names must match that written in the custom action page.
Method Parameters
Each custom action method receives two parameters:args
: Contains all the arguments defined in your custom action configurationuser
: Contains the authenticated user information if identity verification is properly configured
Response Format
Custom actions should return responses in the following format:Success Response
When the action is successful, return both thedata
and status
:
Error Response
When an error occurs, return only thestatus
and error message
:
Important Notes
Multiple Registrations: CallingregisterTools
multiple times will override previous actions. Make sure to provide all desired actions in a single registerTools
call.
Environment Limitations: Client-side custom actions will not work in the Chatbase Playground or Compare features, as these environments don’t support client-side code execution.