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

Outbound Calls

Initiate telephony and SIP calls, handle dynamic variables, and recall existing sessions.

The call-initiation hooks are TanStack Query mutations. Each returns a call session object and automatically invalidates the call-history list on success. Use mutateAsync when you need to read the response — for example, to capture the session ID for live transcript streaming.

Telephony vs. SIP

ScaleAI supports two outbound call transports:

TransportHookWhen to use
TelephonyuseInitiateTelephonyCallManaged provider numbers (Twilio, Plivo, Exotel). The platform owns the DID.
SIPuseOriginateSipCallYour own SIP trunk. You supply a registered caller_id from your project's numbers.

Initiate a telephony call

useInitiateTelephonyCall() places a call through a managed telephony provider. The platform selects (or uses your specified) from-number and routes the call through the provider.

import { useInitiateTelephonyCall } from "@scalereal/sr-voice-engine-react-sdk/hooks";

export function StartCallButton({ agentId }: { agentId: string }) {
  const { mutate, isPending } = useInitiateTelephonyCall();

  return (
    <button
      type="button"
      disabled={isPending}
      onClick={() =>
        mutate({
          agent_id: agentId,
          destination_number: "+14155552671",
          telephony_provider: "twilio",
        })
      }
    >
      {isPending ? "Calling…" : "Start call"}
    </button>
  );
}

Reading the session ID

Use mutateAsync to await the session ID and immediately open a live transcript:

import {
  useInitiateTelephonyCall,
  useCallTranscript,
} from "@scalereal/sr-voice-engine-react-sdk/hooks";

export function CallWithTranscript({ agentId }: { agentId: string }) {
  const initiateCall = useInitiateTelephonyCall();
  const transcript = useCallTranscript({ onCallEnded: () => console.info("ended") });

  const handleCall = async () => {
    const session = await initiateCall.mutateAsync({
      agent_id: agentId,
      destination_number: "+14155552671",
      telephony_provider: "twilio",
    });

    // session.id is now available — open the live transcript immediately
    transcript.startTranscriptSession(session.id);
  };

  return (
    <button type="button" disabled={initiateCall.isPending} onClick={handleCall}>
      Call and stream transcript
    </button>
  );
}

Parameters — InitiateTelephonyCallRequest

ParameterTypeRequiredDescription
agent_idstring✓The agent to run on the call.
destination_numberstring✓Callee number in E.164 format (e.g. "+14155552671").
telephony_providerstring✓Provider identifier — "twilio", "plivo", "exotel", etc.
from_numberstringCaller ID in E.164. Required when is_platform_number is false.
is_platform_numberbooleanWhen true, the platform selects an available number from its pool.
dynamic_variablesRecord<string, string>Values to fill {{variable_name}} placeholders in the agent's prompt at call time.
override_availabilitybooleanWhen true, bypasses the agent's configured availability windows.

Response

{
  id: string;           // Call session ID — use with useCallTranscript / usePostCallSse
  agent_id: string;
  user_id: string;
  workspace_id: string;
  project_id: string;
  status: string;       // e.g. "initiated"
}

Dynamic variables

Dynamic variables let you inject caller-specific context into the agent's prompt at call time without modifying the agent itself. Any {{variable_name}} placeholder in the prompt is replaced with the value you supply.

Dynamic variables are resolved at call time and are not stored on the agent. To persist reusable variable templates, use useAgentPromptVariables.

mutate({
  agent_id: "agent-id",
  destination_number: "+14155552671",
  telephony_provider: "twilio",
  dynamic_variables: {
    customer_name: "Jane Smith",
    account_tier: "enterprise",
    outstanding_balance: "$320.00",
  },
});

If the agent's prompt contains Hello, {{customer_name}}!, the agent will greet the caller as Hello, Jane Smith! on this specific call.


Originate a SIP call

useOriginateSipCall() places a call through your own SIP trunk. You must provide a caller_id that is registered as a SIP number in your project.

import { useOriginateSipCall } from "@scalereal/sr-voice-engine-react-sdk/hooks";

export function SipCallButton({ agentId }: { agentId: string }) {
  const { mutate, isPending } = useOriginateSipCall();

  return (
    <button
      type="button"
      disabled={isPending}
      onClick={() =>
        mutate({
          agent_id: agentId,
          destination_number: "+14155552671",
          caller_id: "+14155550000",
        })
      }
    >
      {isPending ? "Calling…" : "Call via SIP"}
    </button>
  );
}

Parameters — OriginateSipCallRequest

ParameterTypeRequiredDescription
agent_idstring✓The agent to run on the call.
destination_numberstring✓Callee number in E.164 format.
caller_idstring✓An E.164 SIP number registered in your project. Used as the call's caller ID.
timeoutnumberSeconds to wait for the callee to answer before abandoning.
variablesRecord<string, string>Dynamic prompt variable values, same semantics as dynamic_variables above.
override_availabilitybooleanWhen true, bypasses the agent's configured availability windows.

Response

{
  id: string;          // Call session ID
  status: string;
  destination: string;
  created_at: string;
}

Recall a call

useRecallCall() requests a redial of an existing call session. This is useful for "call again" flows in a call history UI.

import { useRecallCall } from "@scalereal/sr-voice-engine-react-sdk/hooks";

export function RecallButton({ callSessionId }: { callSessionId: string }) {
  const { mutate, isPending, data } = useRecallCall();

  return (
    <button
      type="button"
      disabled={isPending}
      onClick={() => mutate({ callSessionId })}
    >
      {isPending ? "Redialing…" : "Recall"}
    </button>
  );
}

Parameters

ParameterTypeRequiredDescription
callSessionIdstring✓The session to redial.

Response — RecallCallResponse

FieldTypeDescription
idstring | nullNew call session ID, or null when the recall was skipped.
statusstring"initiated" when a new call starts; "skipped" when recall is disabled.
destinationstring | nullThe number that was dialed.
recalled_fromstring | nullThe original session ID that triggered the recall.

A status of "skipped" means the original call session has recall disabled — for example, because it was a manually-ended test call. No error is thrown; check status in the response to distinguish the two outcomes.


Override availability

All three call hooks support override_availability. When set to true, the call proceeds regardless of the agent's scheduled availability windows. Use this for programmatic or administrative calls that must not be gated by operating hours.

mutate({
  agent_id: "agent-id",
  destination_number: "+14155552671",
  telephony_provider: "twilio",
  override_availability: true,
});

Related pages

  • Realtime — Stream live transcripts and post-call processing updates using the call session ID.
  • Call History — Query past sessions and track the new call.
  • Phone Numbers — Review project numbers and provider sync.
  • Agents — Configure the agent that runs on the call.

Agents

Query, create, update, publish, version, and generate prompts for AI voice agents using the React SDK.

Call History

Query, filter, inspect, and export call history with the React SDK.

On this page

Telephony vs. SIPInitiate a telephony callReading the session IDParameters — InitiateTelephonyCallRequestResponseDynamic variablesOriginate a SIP callParameters — OriginateSipCallRequestResponseRecall a callParametersResponse — RecallCallResponseOverride availabilityRelated pages