Constructors

Methods

  • Initiate an outbound phone call.

    Creates a CallRecord in 'initiated' state, delegates to the provider to place the call, and returns the internal call ID.

    Parameters

    • params: {
          toNumber: string;
          fromNumber?: string;
          mode?: CallMode;
          message?: string;
          seedId?: string;
          providerName?: VoiceProviderName;
      }
      • toNumber: string
      • Optional fromNumber?: string
      • Optional mode?: CallMode
      • Optional message?: string
      • Optional seedId?: string
      • Optional providerName?: VoiceProviderName

    Returns Promise<CallRecord>

  • Hang up a call. Transitions to 'hangup-bot' terminal state.

    A call persisted with persistCall or read by processWebhookDurable ends in its store: the end, with any bot speech not yet committed, commits there before the carrier is asked to hang up, so the completion callback the hangup causes, like any callback after the commit, finds the call ended and changes nothing, whichever manager processes it. call:ended is emitted after the carrier request returns. The carrier is asked even when that commit fails, and the promise then rejects with the commit's error. A call the store already holds as ended keeps its stored outcome and emits nothing.

    Parameters

    • callId: string

    Returns Promise<void>

  • Add a bot speech entry to the transcript and transition to speaking.

    On a call persisted with persistCall or read by processWebhookDurable, the entry and the speaking state also commit to the call's store, after the manager's earlier store transactions; until one commits them, every later transaction for the call carries them, so a callback does not drop them from the manager's record. When another manager has ended the call in the store meanwhile, the entry still commits to its transcript and the call keeps its stored outcome. A failed commit is written to the console and left to the next transaction.

    Parameters

    • callId: string
    • text: string

    Returns void

  • Process a single normalized call event.

    With eventHandling: 'carrier' the event is matched to a call by its provider and call id (or its request id), bound to that call's carrier identity and applied once per record: a state the call has passed emits nothing, a call emits one terminal notification, and the record stays in the manager. This repairs transitions in process and adds no restart durability; see processWebhookDurable. Otherwise the original handling below applies.

    Parameters

    Returns void

  • Verifies, binds and applies callbacks in the store transaction. State and dedupe commit together. Unknown admission throws so the host returns a retryable response. Notifications happen only after commit and are best-effort; financial/external effects must consume durable records, not handlers. A call's bot speech not yet committed commits first, and the manager's record of each call becomes the committed one with the speech recorded since on top; the manager's store transactions run one at a time.

    Parameters

    Returns Promise<{
        accepted: boolean;
        applied: number;
    }>

  • Handle an inbound call based on the configured policy. Creates a CallRecord if the call is accepted.

    Parameters

    • params: {
          providerCallId: string;
          provider: VoiceProviderName;
          fromNumber: string;
          toNumber: string;
          seedId?: string;
      }
      • providerCallId: string
      • provider: VoiceProviderName
      • fromNumber: string
      • toNumber: string
      • Optional seedId?: string

    Returns null | CallRecord

  • Clean up all state (for shutdown).

    A store transaction already in flight still commits, and a hangup whose end is committing still asks its carrier, but neither changes the records of a disposed manager.

    Returns void