How It Works
- You define tools with a schema (what arguments the tool accepts)
- You provide an
endpointconfiguration (where ThunderPhone calls your API) — or leave it off to receive tool calls on your org webhook - During a call, the AI decides when to use a tool based on the conversation
- ThunderPhone calls your endpoint with the tool arguments
- 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 anendpoint:
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 anendpoint, ThunderPhone sends
a request to your URL:
Request Headers
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 secretX-ThunderPhone-Call-ID— The current call ID
Content-Type: application/json is set unless your endpoint.headers
override it — a custom Content-Type wins.
Request Body
ForPOST / PUT / PATCH, the body contains only the tool
arguments (no wrapper), serialized canonically (sorted keys, compact
separators):
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:{"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 anendpoint 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/DELETEtools sign the empty byte string
Example: Complete Booking Flow
Here’s a set of tools for a complete appointment booking system:Best Practices
Write clear descriptions
Write clear descriptions
The
description field helps the AI understand when to use the tool. Be specific about what it does and when it’s appropriate.Handle errors gracefully
Handle errors gracefully
Return error messages the AI can understand:
{"error": "No slots available for that date"} rather than generic 500 errors.Keep responses concise
Keep responses concise
Return only what the AI needs to continue the conversation. Large payloads slow down response times.
Use required fields wisely
Use required fields wisely
Mark fields as
required only when truly necessary. The AI will ask the user for required information before calling the tool.Related
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.