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 agent owner wants more flexibility with the action code, or wants to send an API request on behalf of the user, from the client side.Make sure to load the popup chat
script before setting up client
actions.
registerTools()
Create client action, load the ChatNode script and call the registerTools
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 client action page.
Method Parameters
Each custom action method receives one parameters:args
: Contains all the arguments defined in your custom client action configuration
Response Format
Custom client 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
:
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 ChatNode in-app chat, as these environments don’t support client-side code execution.