Skip to main content
Function tools allow your AI agents to invoke external APIs during phone calls. Use them to look up customer data, check availability, book appointments, or perform any action your backend supports.

How It Works

  1. You define tools with a schema (what arguments the tool accepts)
  2. You provide an endpoint configuration (where ThunderPhone calls your API) — or leave it off to receive tool calls on your org webhook
  3. During a call, the AI decides when to use a tool based on the conversation
  4. ThunderPhone calls your endpoint with the tool arguments
  5. Your API response is fed back to the AI to continue the conversation
Function tools are the bring-your-own-API path. ThunderPhone also ships platform-managed tools that need no endpoint: app connections (HubSpot, Salesforce, Slack, Google Calendar, Google Sheets, Cal.com), API connections, and MCP servers.

Tool Schema

Each tool follows this structure:

Function Definition

Endpoint Configuration

The endpoint configuration is not sent to the AI model—it’s only used by ThunderPhone to execute the tool call.

Two invocation paths

Which request your server receives depends on whether the tool has an endpoint: Both paths are blocking — the AI is waiting mid-sentence for the result — with a 20 s timeout. Keep handlers fast. A mix is fine: on a call whose org has a webhook URL, tools with an endpoint are called directly and the rest fall back to the webhook.

Direct endpoint calls

When the AI invokes a tool that has an endpoint, ThunderPhone sends a request to your URL:

Request Headers

Custom headers from your endpoint.headers are always included verbatim, plus two ThunderPhone-namespaced headers:
  • X-ThunderPhone-Signature — HMAC-SHA256 of the exact request-body bytes, keyed with your org webhook secret
  • X-ThunderPhone-Call-ID — The current call ID
Content-Type: application/json is set unless your endpoint.headers override it — a custom Content-Type wins.
The signature is keyed with the org-level webhook secret from GET /v1/webhook. If your org has never configured the legacy webhook, there is no secret and tool calls carry only X-ThunderPhone-Call-ID — a handler that hard-fails on a missing signature would reject them. Either configure the legacy webhook to get a secret, or put your own shared secret in endpoint.headers.

Request Body

For POST / PUT / PATCH, the body contains only the tool arguments (no wrapper), serialized canonically (sorted keys, compact separators):
For GET / DELETE, the arguments are sent as query parameters and the body is empty — the signature is then computed over the empty byte string. See Verify webhook signatures.

Response

Return a JSON response with the tool result:
The response is formatted and provided to the AI to continue the conversation. Non-JSON responses are wrapped as {"data": "<text>"}; timeouts and connection failures are reported to the AI as errors, so the agent can apologize and move on rather than stall.

Webhook-mode dispatch

Tools without an endpoint are dispatched to your org’s legacy webhook URL as a signed telephony.tool (phone calls) or web.tool (web calls) request. Unlike the audit notifications delivered to webhook endpoints after execution, this request is the execution — your HTTP response is the tool result.
web.tool carries origin_domain instead of from_number / to_number. Respond with the tool result as JSON — the same response contract as direct endpoint calls. The request is signed with the org webhook secret over the raw body, like every other webhook.
Subscribed webhook endpoints additionally receive a non-blocking telephony.tool / web.tool notification after each tool executes (whichever path ran it), including the tool’s response — useful for audit trails. See the events catalog.

Signature Verification

Direct tool calls are signed the same way as webhooks:
  • HMAC-SHA256 over the exact request-body bytes (the canonical JSON — sorted keys, no extra whitespace)
  • Keyed with your org webhook secret
  • GET / DELETE tools sign the empty byte string
Full recipes — including the empty-body case and the no-secret caveat — are in Verify webhook signatures.

Example: Complete Booking Flow

Here’s a set of tools for a complete appointment booking system:

Best Practices

The description field helps the AI understand when to use the tool. Be specific about what it does and when it’s appropriate.
Return error messages the AI can understand: {"error": "No slots available for that date"} rather than generic 500 errors.
Return only what the AI needs to continue the conversation. Large payloads slow down response times.
Mark fields as required only when truly necessary. The AI will ask the user for required information before calling the tool.

App connections

Platform-managed tools for HubSpot, Salesforce, Slack, Google Calendar, Google Sheets, and Cal.com — no endpoint required.

MCP servers

Attach an MCP server and let the agent call its tools.

API connections

Reusable REST integrations you can attach to agents.

Verify webhook signatures

One verification helper for webhooks and tool calls.