DocumentationAPI ReferenceReact SDKRelease Notes
ScaleAI

Getting Started

OverviewInstallationQuick Start

Core

Provider & Setup

Hooks

AgentsOutbound CallsCall HistoryPhone NumbersIntegration CredentialsWebhooksKnowledge BasesFunction ToolsFunction Logs

Realtime

Realtime

UI

Components

Reference

TypesUtilities
Go to platform

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_typeWhat it does
custom_functionCalls your HTTP endpoint. config holds url, method, headers, and body template.
transfer_callTransfers the caller to a human agent or external number. config holds transfer_number.
end_callTerminates the call. config can include a farewell message.
sound_effectPlays an audio clip during the call.
check_slot_availabilityQueries a connected calendar for open time slots. Requires a calendar integration credential.
book_appointmentBooks a slot on a connected calendar. Requires a calendar integration credential.
agent_transferHands off the call to another agent within the same project.
schedule_callbackSchedules 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

ParameterTypeDescription
pagenumberPage index (1-based).
sizenumberResults per page.
searchstringFull-text search on tool name.
function_typeAgentFunctionTypeFilter by tool type.
is_activebooleanFilter active/inactive tools.
sort_bystringSort 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

ParameterTypeDescription
toolIdstringID of the tool to fetch.
enabledbooleanSet 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

FieldTypeRequiredDescription
namestring✓Unique tool name (used as the function name the agent invokes).
function_typeAgentFunctionType✓Tool category. Determines the shape of config.
promptstringNatural-language instruction for when and how the agent should use this tool.
configRecord<string, unknown>Tool configuration. Shape depends on function_type (see config shapes).
integration_credential_idstringRequired for check_slot_availability and book_appointment.
is_activebooleanWhether 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

FieldTypeDescription
functionToolIdstringID of the tool to update.
dataUpdateFunctionToolRequestPartial 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

Knowledge Bases

Ingest documents and crawl websites to give your AI agents a searchable knowledge base using the ScaleAI React SDK.

Function Logs

Query tool invocation logs to debug, monitor, and audit function calls made by agents during calls.

On this page

OverviewTool typesHooksuseGetFunctionToolsuseFunctionToolDetailsuseCreateFunctionTooluseUpdateFunctionToolTypesFunctionToolAgentFunctionTypeConfig shapescustom_functiontransfer_callend_callcheck_slot_availability / book_appointmentWriting effective promptsInactive toolsCache keysRelated pages