Skip to main content
The widget exposes a JavaScript API for advanced integrations. You can register tools the agent can invoke in the browser, subscribe to server-side tool results, customize how tools render in the chat, and update page context.

Page context

Tell the agent about the current page so it can give context-aware answers:
The context is sent with the next message. The widget also captures DOM context automatically (headings, buttons, links, form fields) within configured limits.
Automatic DOM capture limits: 80 links, 30 headings, 30 buttons, 20 form fields, 8000 characters of text content.

Registering client-side tools

Register JavaScript functions that the agent can invoke during a conversation. The agent calls these via the built-in invoke_client_tool bridge:
Each tool receives a single argument object with the parameters the agent provides. Return a JSON-serializable result.

Subscribing to tool results

Listen for server-side tool invocations (knowledge retrieval, custom actions, workflows):

Custom tool renderers

Override how specific tools appear in the chat UI:
The renderer receives the tool invocation and returns an object with a text property displayed as a status message in the chat.

API summary