Member Junction
    Preparing search index...

    The minimal Vonage client surface VonageCallSdk drives. A production deployment implements this over the real @vonage/server-sdk (Voice API) + a websocket media handler; this package never imports @vonage/server-sdk so it builds and tests with no network. When no bindings are supplied, VonageCallSdk throws the explicit "bind the real Vonage client" error from every operation.

    The shapes are intentionally tiny and provider-neutral at the value level (strings / byte buffers) so the Vonage SDK's types do not leak into the bridge package.

    interface IVonageClientBindings {
        acceptInbound(callUuid: string): Promise<void>;
        createCall(
            toNumber: string,
            fromNumber: string,
            args?: Record<string, unknown>,
        ): Promise<string>;
        flushOutbound(callUuid: string): void;
        hangupCall(callUuid: string): Promise<void>;
        onCallStatus(callUuid: string, cb: () => void): void;
        onDigits(callUuid: string, cb: (digits: string) => void): void;
        onWebsocketAudio(callUuid: string, cb: (pcm: ArrayBuffer) => void): void;
        playDigits(callUuid: string, digits: string): Promise<void>;
        pushWebsocketAudio(callUuid: string, pcm: ArrayBuffer): void;
        transferCall(callUuid: string, toNumber: string): Promise<void>;
    }

    Implemented by

    Index

    Methods

    • Accepts the websocket media leg for an inbound call already delivered by the answer webhook.

      Parameters

      • callUuid: string

        The inbound call UUID from the webhook.

      Returns Promise<void>

    • Places an outbound call via the Vonage Voice API (POST /v1/calls) with an NCCO that connects a bidirectional websocket to the agent's media leg.

      Parameters

      • toNumber: string

        Destination number (E.164).

      • fromNumber: string

        The agent's Vonage number / verified caller-id the call originates from.

      • Optionalargs: Record<string, unknown>

        Provider-specific options (event-webhook URL, websocket media URL, recording flags, …).

      Returns Promise<string>

      The created call UUID.

    • Discards the audio Vonage has QUEUED on the media leg (sends the {"action":"clear"} websocket command). Called on barge-in so the agent's not-yet-played voice is dropped instead of draining Vonage's deep (~60s) playback queue over the caller's new turn.

      Parameters

      • callUuid: string

        The call UUID whose queued outbound audio to flush.

      Returns void

    • Ends the call (Voice API PUT /v1/calls/:uuid with { action: 'hangup' }).

      Parameters

      • callUuid: string

        The call UUID to hang up.

      Returns Promise<void>

    • Registers the call-ended callback (event-webhook completed/failed/rejected/cancelled or the websocket close event).

      Parameters

      • callUuid: string

        The call UUID.

      • cb: () => void

        Invoked when the call ends.

      Returns void

    • Registers the inbound DTMF callback (NCCO input/dtmf results delivered to the event webhook).

      Parameters

      • callUuid: string

        The call UUID.

      • cb: (digits: string) => void

        Invoked with each received DTMF digit string.

      Returns void

    • Registers the inbound websocket audio callback for the call (what the agent hears).

      Parameters

      • callUuid: string

        The call UUID whose inbound media to subscribe to.

      • cb: (pcm: ArrayBuffer) => void

        Invoked with each inbound PCM audio frame.

      Returns void

    • Sends DTMF digits on the call (Voice API PUT /v1/calls/:uuid/dtmf with { digits }).

      Parameters

      • callUuid: string

        The call UUID.

      • digits: string

        The DTMF digit string.

      Returns Promise<void>

    • Pushes one outbound audio payload onto the call's websocket media leg (the agent's voice).

      Parameters

      • callUuid: string

        The call UUID whose media leg to write to.

      • pcm: ArrayBuffer

        The audio bytes (the adapter encodes to the websocket media frame).

      Returns void

    • Transfers the live call (Voice API PUT /v1/calls/:uuid with { action: 'transfer', destination: { type: 'ncco', ncco: [...] } }).

      Parameters

      • callUuid: string

        The call UUID to redirect.

      • toNumber: string

        The transfer destination.

      Returns Promise<void>