Function Tools
Create and manage the tools your voice agents can invoke during a call — from HTTP endpoints to calendar bookings.
Overview
Function tools extend your agent's capabilities beyond conversation. During a live call, the agent decides autonomously — guided by each tool's prompt — when and how to invoke a tool. The platform executes the tool, returns the result to the agent, and the agent continues the conversation.
Tools are created independently and then attached to agents via the agent's configuration. A tool must have is_active: true to be available to agents at runtime.
Tool types
function_type | What it does |
|---|---|
custom_function | Calls your HTTP endpoint. config holds url, method, headers, and body template. |
transfer_call | Transfers the caller to a human agent or external number. config holds transfer_number. |
end_call | Terminates the call. config can include a farewell message. |
sound_effect | Plays an audio clip during the call. |
check_slot_availability | Queries a connected calendar for open time slots. Requires a calendar integration credential. |
book_appointment | Books a slot on a connected calendar. Requires a calendar integration credential. |
agent_transfer | Hands off the call to another agent within the same project. |
schedule_callback | Schedules a callback for the caller at a later time. |
Hooks
useGetFunctionTools
Fetches a paginated list of function tools.
import { useGetFunctionTools } from "@scalereal/sr-voice-engine-react-sdk/hooks";
function ToolList() {
const { data, isLoading } = useGetFunctionTools({
page: 1,
size: 20,
is_active: true,
function_type: "custom_function",
});
if (isLoading) return <p>Loading…</p>;
return (
<ul>
{data?.results.map((tool) => (
<li key={tool.id}>
{tool.name} — {tool.function_type}
</li>
))}
</ul>
);
}Parameters
| Parameter | Type | Description |
|---|---|---|
page | number | Page index (1-based). |
size | number | Results per page. |
search | string | Full-text search on tool name. |
function_type | AgentFunctionType | Filter by tool type. |
is_active | boolean | Filter active/inactive tools. |
sort_by | string | Sort field. Supports "created_at" and "-created_at" (descending). |
useFunctionToolDetails
Fetches a single function tool by ID.
import { useFunctionToolDetails } from "@scalereal/sr-voice-engine-react-sdk/hooks";
function ToolDetail({ toolId }: { toolId: string }) {
const { data } = useFunctionToolDetails(toolId);
return (
<div>
<h2>{data?.name}</h2>
<p>{data?.prompt}</p>
<pre>{JSON.stringify(data?.config, null, 2)}</pre>
</div>
);
}Parameters
| Parameter | Type | Description |
|---|---|---|
toolId | string | ID of the tool to fetch. |
enabled | boolean | Set to false to skip the query (default: true). |
useCreateFunctionTool
Creates a new function tool.
import { useCreateFunctionTool } from "@scalereal/sr-voice-engine-react-sdk/hooks";
function CreateCustomFunctionTool() {
const { mutate, isPending } = useCreateFunctionTool();
const handleCreate = () => {
mutate({
name: "lookup_order_status",
function_type: "custom_function",
prompt:
"Call this tool when the caller asks about the status of their order. Pass the order ID they provide.",
is_active: true,
config: {
url: "https://api.example.com/orders/status",
method: "POST",
headers: { "X-Api-Key": "{{secret}}" },
},
});
};
return (
<button onClick={handleCreate} disabled={isPending}>
Create Tool
</button>
);
}Mutation body: CreateFunctionToolRequest
| Field | Type | Required | Description |
|---|---|---|---|
name | string | ✓ | Unique tool name (used as the function name the agent invokes). |
function_type | AgentFunctionType | ✓ | Tool category. Determines the shape of config. |
prompt | string | Natural-language instruction for when and how the agent should use this tool. | |
config | Record<string, unknown> | Tool configuration. Shape depends on function_type (see config shapes). | |
integration_credential_id | string | Required for check_slot_availability and book_appointment. | |
is_active | boolean | Whether the tool is available to agents (default: true). |
useUpdateFunctionTool
Partially updates an existing tool (PATCH semantics — all data fields optional).
import { useUpdateFunctionTool } from "@scalereal/sr-voice-engine-react-sdk/hooks";
function DisableTool({ functionToolId }: { functionToolId: string }) {
const { mutate } = useUpdateFunctionTool();
return (
<button onClick={() => mutate({ functionToolId, data: { is_active: false } })}>
Disable Tool
</button>
);
}Mutation body
| Field | Type | Description |
|---|---|---|
functionToolId | string | ID of the tool to update. |
data | UpdateFunctionToolRequest | Partial fields from CreateFunctionToolRequest. |
Types
FunctionTool
interface FunctionTool {
id: string;
name: string;
function_type: AgentFunctionType;
prompt: string;
is_active: boolean;
config?: Record<string, unknown>;
integration_credential_id: string;
created_at: string;
}AgentFunctionType
type AgentFunctionType =
| "custom_function"
| "transfer_call"
| "end_call"
| "sound_effect"
| "check_slot_availability"
| "book_appointment"
| "agent_transfer"
| "schedule_callback";Config shapes
The config field structure depends on function_type. Below are the common shapes:
custom_function
{
url: string; // Endpoint to call
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
headers?: Record<string, string>;
// Additional body template fields may be included
}transfer_call
{
transfer_number: string; // E.164 number to transfer the caller to
}end_call
{
farewell_message?: string; // Optional message to speak before ending
}check_slot_availability / book_appointment
These tools require an integration_credential_id pointing to a calendar integration credential. The config shape is determined by the calendar provider (Google Calendar, Calendly, etc.).
Writing effective prompts
The prompt field is the natural-language instruction that the agent uses to decide when to call the tool and what parameters to pass. A well-written prompt dramatically improves tool invocation accuracy.
Good prompt example:
Call this tool when the caller requests to book an appointment or schedule a meeting.
Ask the caller for their preferred date and time before invoking the tool.
Pass the date in ISO 8601 format (YYYY-MM-DDTHH:mm:ss) and the caller's name.Poor prompt example:
Book appointment.Prompts are interpreted by the agent's underlying LLM. Be explicit about preconditions (what to ask before calling), parameter formats, and what to do if the tool returns an error.
Inactive tools
Setting is_active: false on a tool removes it from the agent's available tool set at runtime, even if the tool is still attached to an agent in configuration. Use this to temporarily disable a tool without removing it from all agents.
Inactive tools are silently excluded — the agent will not attempt to use them, and no error is returned. Verify tool status if an agent stops invoking expected functions.
Cache keys
import { functionToolKeys } from "@scalereal/sr-voice-engine-react-sdk/hooks";
// Invalidate all tool queries
queryClient.invalidateQueries({ queryKey: functionToolKeys.all });
// Invalidate a specific tool
queryClient.invalidateQueries({ queryKey: functionToolKeys.detail(toolId) });Related pages
- Function Logs — inspect tool invocations during calls
- Integration Credentials — calendar and custom credentials
- Agents — attach tools to agents via agent configuration