useTransferCall

useTransferCall

Puts the caller through to a number from your own code (Human handoff).

import { useTransferCall } from "curb";

function useTransferCall(): (request: TransferCallRequest) => Promise<TransferOutcome>;

Options

OptionTypeDefaultWhat it does
tostringThe number in international format
ringTimeoutSecondsnumber30How long it rings, 10 to 60 seconds
announcestringnoneSaid to the caller before it dials
onEndeddecision or functionthe agent takes the call backWhat happens when the person hangs up and the caller stays (When the person hangs up)

Returns

outcome is answered, no_answer, busy, failed or refused, beside code, message and transferId. It never rejects for an outcome, and throws TypeError for a bad request.

Example

function ReachSales() {
  const transfer = useTransferCall();
  return (
    <Tool
      name="reach_sales"
      description="The caller asks for sales."
      onCall={async () => {
        const { outcome } = await transfer({ to: "+493012345678", announce: "One moment." });
        return { ok: outcome === "answered", message: outcome };
      }}
    />
  );
}

Version history

VersionChanges
v1.15.0onEnded added
v1.9.0useTransferCall introduced