Skip to content

Client tools

A client tool runs in the visitor’s browser, on your page. The model calls it like any other tool; the widget hands the call to a handler your page registered and sends the result back, and the assistant continues its answer. Nothing leaves the browser except the result you return.

Use client tools when the action needs the visitor’s own session or the page itself: open a screen in your app, read what is on it, fill a form, create something through your app’s own API with the visitor’s permissions. For server-to-server calls use Remote tools.

Settings → Client tools, or with the API:

PATCH /v1/admin/tenant
{
"clientTools": [{
"name": "navigate",
"description": "Open a screen of the app for the visitor. Use the paths from the screen list.",
"inputSchema": {
"type": "object",
"properties": { "path": { "type": "string" } },
"required": ["path"],
"additionalProperties": false
},
"needsApproval": false,
"requiresAuth": false,
"timeoutMs": 15000,
"enabled": true
}]
}
  • name must match ^[a-zA-Z][a-zA-Z0-9_]{0,63}$; the model sees name and description.
  • inputSchema is JSON Schema. An empty schema means no input.
  • needsApproval: true shows an Approve / Not now card in the chat before the page runs the tool. Use it for anything that publishes, deletes, sends or pays.
  • requiresAuth: true offers the tool only to signed-in visitors.
  • timeoutMs (1,000–60,000, default 15,000) is how long the widget waits for your handler.

Your plan sets whether client tools are included and how many you can enable. The whole clientTools array is replaced on each PATCH.

window.Helpvane.registerTool('navigate', async ({ path }) => {
if (hasUnsavedChanges()) {
return { blocked: 'unsaved', message: 'The visitor has unsaved changes on this screen.' };
}
router.push(path);
return { ok: true, path };
});

registerTools({ name: fn, … }) registers several at once; unregisterTool(name) stops serving one. With the embed mount() call or the React component, pass tools: { navigate: fn } instead.

A handler receives the model’s input (validated against your schema by the model, not by the widget: validate it again) and { toolCallId, toolName }. Return any JSON-serialisable value; it is forwarded to the model and cut at 16 KB. A thrown error, a rejected promise or a timeout is reported to the model as a failure, so it can explain or try something else. A tool nobody registered answers “This page has no handler for the tool”.

Send what the visitor is looking at as context, so the model knows where it is before it calls anything:

window.Helpvane.setContext({ path: location.pathname, screen: 'page-editor', entityId: '42', dirty: false });

Context is sent with every message (max 8 KB). For signed-in visitors the keys you signed into the token win; page context can only add keys.

  1. The model calls the tool; the assistant’s turn pauses and the widget shows “Working on it…” (or the approval card).
  2. Your handler runs; the widget posts the result to POST /v1/public/chat as toolResults and the turn resumes with the same conversation.
  3. The call, its input and the result are stored with the conversation and replayed to the model in later turns.

The tool event (window.Helpvane.on('tool', fn) or helpvane:tool on window) fires after every call with { toolName, toolCallId, input, status: 'done' | 'failed' | 'denied' | 'unhandled', result?, error?, durationMs }, useful for logging.

Settings → Max tool steps per reply caps how many tool rounds one answer may take (default 12). Raise it for assistants that drive an app screen by screen.

  • Treat the input as untrusted: it comes from the model, which page content and the visitor can influence. Validate it and run the action with the visitor’s own permissions, never with a privileged key.
  • Mark destructive tools needsApproval; the visitor approves before anything runs. The tool description is written for the model, so the card never shows it (see below).
  • The widget never gets a credential from you. If your handler calls your backend, use the session the visitor already has (cookies, your own token).

By default the approval card says “The assistant wants to: ” and keeps the raw input behind a collapsed Details toggle. Pass describeApproval to mount() (or the React component) to word it for the visitor, in their language:

HelpvaneWidget.mount({
// …
describeApproval: ({ toolName, input, locale }) =>
toolName === 'publishPage'
? { title: locale?.startsWith('tr') ? 'Bu sayfayı yayımla' : 'Publish this page', detail: 'The draft goes live.' }
: undefined,
});

Return a string (the title), { title, detail? } (plain text), or nothing to fall back to the default card. The script-tag embed has no data attribute for it; mount programmatically when you need it.