Member Junction
    Preparing search index...

    Production ITwilioClientBindings over the real Twilio REST API + Media Streams, expressed against the injected ITwilioRestLike / ITwilioMediaPump surfaces so it builds and unit-tests with no twilio install and no network.

    • createCall → REST calls.create with the <Connect><Stream> TwiML.
    • acceptInbound → no REST call (the inbound webhook already returned the connect TwiML); the websocket for the delivered Call SID is what "accepting" means — handled by onStreamAudio.
    • completeCall / redirectCall / playDigits → REST calls(sid).update.
    • pushStreamAudio / onStreamAudio → Media-Streams frames, transcoded through the T0 codec.

    Implements

    Index

    Constructors

    Methods

    • Parameters

      • toNumber: string
      • fromNumber: string
      • Optionalargs: Record<string, unknown>

      Returns Promise<string>

      the per-call media token BEFORE the REST call (it rides in the TwiML the call executes), then registers it with the media pump under the returned Call SID so the Media-Streams socket can be authenticated when Twilio connects it.

    • Registers the inbound DTMF callback (<Gather> webhook results or Media-Streams dtmf events).

      Parameters

      • callSid: string

        The Call SID.

      • cb: (digits: string) => void

        Invoked with each received DTMF digit string.

      Returns void

    • Registers the inbound Media-Streams audio callback for the call (what the agent hears).

      Parameters

      • callSid: string

        The Call SID whose inbound stream to subscribe to.

      • cb: (pcm: ArrayBuffer) => void

        Invoked with each inbound PCM audio frame.

      Returns void

    • Parameters

      • callSid: string
      • digits: string

      Returns Promise<void>

      IN-BAND over the media stream as synthesized tones. The REST alternative (<Play digits>) replaces the call's TwiML, which ends <Connect><Stream> — the agent would lose the call's audio and the stream stop would tear the whole call down. Tones go out in 20 ms frames like any other agent audio, so they queue behind whatever the agent is already saying.

    • Pushes one outbound audio payload onto the call's Media-Streams websocket (the agent's voice).

      Parameters

      • callSid: string

        The Call SID whose stream to write to.

      • pcm: ArrayBuffer

        The audio bytes (the adapter encodes to the Media-Streams μ-law/PCM media frame).

      Returns void

    • Optional. Speaks message to the caller and then hangs up, in one carrier-side step (REST calls(sid).update({ twiml: '<Say>…</Say><Hangup/>' })). The call is ending anyway, so replacing its TwiML (which ends the media stream) is what we want here. When absent the SDK just completes the call.

      Parameters

      • callSid: string

        The Call SID.

      • message: string

        The text to speak.

      Returns Promise<void>