Skip to content

@cloudflare/voice-twilio: outbound agent audio dropped when messages arrive as Blob #2260

Description

@randreu28

Package

@cloudflare/voice-twilio@0.1.0 (TwilioAdapter) with agents@0.23.0

Description

Even after the agent WebSocket is connected, callers often hear nothing (or only silence) from the agent.

The voice agent sends binary audio as Blob over the WebSocket. The Twilio adapter's outbound handler only forwards ArrayBuffer:

else if (event.data instanceof ArrayBuffer) {
  // convert / send to Twilio
}

Blob frames are ignored, so TTS audio never reaches Twilio.

Expected

Any binary audio from the agent (ArrayBuffer or Blob) is forwarded to Twilio as Media Streams media events.

Actual

Blob audio is dropped → silent call after connect / greeting never plays.

Workaround

Before accepting the agent socket:

agent.binaryType = "arraybuffer";
agent.accept();

Or handle both:

if (event.data instanceof ArrayBuffer) { /* ... */ }
else if (event.data instanceof Blob) {
  const buf = await event.data.arrayBuffer();
  /* ... */
}

Notes

This is independent of TTS codec choice. Even with ElevenLabs ulaw_8000 / PCM16, frames never leave the adapter if they arrive as Blob.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions