How It Works
- You define tools with a schema (what arguments the tool accepts)
- You provide an
endpointconfiguration (where ThunderPhone calls your API) - 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
Tool Schema
Each tool follows this structure:Function Definition
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique identifier for the tool |
description | string | Yes | Explains to the AI when to use this tool |
parameters | object | Yes | JSON Schema for tool arguments |
Endpoint Configuration
| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Your API endpoint URL |
method | string | No | HTTP method (default: POST) |
headers | object | No | Custom headers to include |
The
endpoint configuration is not sent to the AI model—it’s only used by ThunderPhone to execute the tool call.Tool Call Execution
When the AI invokes a tool, ThunderPhone sends a request to your endpoint:Request Headers
endpoint.headers are included, plus:
X-ThunderPhone-Signature— HMAC-SHA256 of the request bodyX-ThunderPhone-Call-ID— The current call ID
Request Body
The body contains only the tool arguments (no wrapper):Response
Return a JSON response with the tool result:Signature Verification
Tool calls are signed the same way as webhooks:- HMAC-SHA256 of the JSON request body
- Uses your org webhook secret
- Payload serialized with sorted keys, no extra whitespace
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.