<Handoff>

<Handoff>

Hands the caller to a person: put through to a number within the hours, a callback request otherwise. It also hands off on its own when something is not working, and, when you ask for it, when the caller’s requests keep failing (Human handoff).

import { Handoff } from "curb";

function Handoff(props: HandoffProps): ReactNode;

Props

PropTypeDefaultWhat it does
tostringThe number a person answers, international format, like +493012345678
hoursOpeningHours or (now: Date) => boolean | Promise<boolean>alwaysWhen someone is there: { timeZone, open: { "mon-fri": "08:00-17:00", sat: ["09:00-12:00"] } }
afterErrorsnumber or false3Hand off on its own when something is not working: after this many tool calls in a row threw, or this many turns in a row got no reply, 1 to 10; false never
afterFailedAttemptsnumber or falsefalseHand off on its own when nothing is broken but the agent gets nowhere: after this many tool calls in a row answered ok: false (“That slot is taken”), 1 to 10; false leaves it to the model
ringTimeoutSecondsnumber30How long it rings, 10 to 60 seconds
onEndeddecision or functionthe agent takes the call backWhat happens when the person hangs up and the caller stays (When the person hangs up)
onCallbackRequest(request: CallbackRequest) => void | Promise<void>noneWhere a callback request goes; it is in the call’s record either way
namestringhandoffThe handoff tool’s name
callbackNamestringrequest_callbackThe callback tool’s name, offered only after a handoff reached nobody

CallbackRequest is { name, phone, reason, summary }. reason is caller_requested, agent_stuck or agent_failure.

afterFailures is the old name of afterErrors and still sets it when afterErrors is not given.

Example

<GlobalTools>
  <Handoff
    to="+493012345678"
    hours={{ timeZone: "Europe/Berlin", open: { "mon-fri": "08:00-17:00" } }}
    onCallbackRequest={(request) => tickets.create(request)}
  />
</GlobalTools>

Version history

VersionChanges
v1.22.0afterFailures renamed afterErrors, and a tool result with ok: false no longer counts toward it; afterFailedAttempts added
v1.21.0<Handoff> introduced