Skip to main content
Client-side tools let your AI assistant invoke functions that run directly in the browser or client application during a voice or chat conversation. Unlike webhook tools — which make HTTP requests to your backend — client-side tools execute JavaScript code on the client, with direct access to browser state, local data, and any API the page is authenticated to call.

How they work

  1. You define a tool in the Portal with a name, description, and JSON Schema for parameters — the same way you configure other tool types.
  2. The assistant decides when to call it based on the conversation context and the tool’s description.
  3. Your client-side handler runs in the browser, receiving the parsed arguments from the assistant.
  4. The return value is sent back to the assistant so it can continue the conversation naturally.
This flow uses the Voice SDK Proxy WebSocket to relay tool invocations and results between the assistant and your client code — no HTTP webhook required.
Client-side tools are available for WebRTC-based conversations (voice and chat) using the @telnyx/ai-agent-lib JavaScript/React library. They are not available for SIP/phone-call-based conversations.

When to use client-side tools

Configure a client-side tool in the Portal

  1. Open AI Assistants in the Telnyx Portal.
  2. Select an assistant and scroll to the Tools section.
  3. Click Add Tool and select Client-Side Tool.
  4. Fill in the fields:
  1. Click Create & Add to Assistant.
You can also create client-side tools in the Tools Library and share them across multiple assistants.
The Parameters schema uses the same JSON Schema format as webhook tool body parameters. The visual editor supports string, number, integer, boolean, enum, and array types. If your schema uses keywords the visual editor doesn’t support (like minimum, pattern, or default), it will be displayed in Advanced mode as raw JSON to preserve those keywords.

Implement client-side tool handlers

Install the Telnyx AI Agent library:
Client-side tools require @telnyx/ai-agent-lib version 0.5.0 or later.

Register tools at construction time

Register tools at runtime

Use with React

Handler contract

  • The return value is serialized and sent back as the tool output. Strings are sent verbatim; anything else is JSON-stringified.
  • Handlers may be async. Each runs with its tool’s Timeout configured in the Portal, falling back to clientToolTimeoutMs for tools that have none. If the handler exceeds it, a { "error": "timeout" } output is returned to the assistant.
  • The library handles the call_id round-trip — you don’t need to manage that yourself.

Error handling

The library always returns a result to the assistant so the conversation never hangs: Your handler should handle its own errors gracefully. If you want the assistant to know about a failure (e.g., an API returned 404), return an error object rather than throwing:

Observe tool lifecycle events

Tool arguments and outputs are never logged — they may contain customer data. Only safe correlation fields (callId, tool name) appear in debug logs.

Client-side tools vs. webhook tools

Use cases

  • E-commerce: Look up cart contents, check order status from the browser session, apply a promo code
  • Scheduling: Read the user’s calendar from the page, open a booking modal
  • Customer support: Fetch user details from the client session, trigger a screen share
  • IoT dashboards: Read device state from the dashboard, toggle a device on/off

Learn more