The DailyTransport class provides a WebRTC transport layer using Daily.co’s infrastructure. It wraps a Daily-JS call client to handle audio/video device management, WebRTC connections, and real-time communication between clients and bots. For complete documentation on Daily’s API, see the Daily API Reference.

This transport is designed for production use cases, leveraging Daily’s global infrastructure for low-latency, high-quality audio and video streaming. It expects your Pipecat server to include the corresponding DailyTransport server-side implementation.

Usage

Basic Setup

import { PipecatClient } from "@pipecat-ai/client-js";
import { DailyTransport } from "@pipecat-ai/daily-transport";

const pcClient = new PipecatClient({
    transport: new DailyTransport ({
      // DailyTransport constructor options
      bufferLocalAudioUntilBotReady: true, // Optional, defaults to false
      inputSettings: { video: { processor: {type: 'background-blur'}  } },
    }),
    enableCam: false,  // Default camera off
    enableMic: true,   // Default microphone on
    callbacks: {
      // Event handlers
    },
    // ...
});

await pcClient.connect({
    endpoint: 'https://your-server/connect',
});

API Reference

Constructor Options

interface DailyTransportConstructorOptions extends DailyFactoryOptions {
  bufferLocalAudioUntilBotReady?: boolean;
}
bufferLocalAudioUntilBotReady
boolean
default:"false"
required

If set to true, the transport will buffer local audio until the bot is ready. This is useful for ensuring that bot gets any audio from the user that started before the bot is ready to process it.

DailyFactoryOptions

The DailyTransportConstructorOptions extends the DailyFactoryOptions type that is accepted by the underlying Daily instance. These options are passed directly through to the Daily constructor. See the Daily API Reference for a complete list of options.

While you can provide the room url and optional token as part of your constructor options, the typical pattern is to provide them via a connection endpoint or directly as part of connect(). See below.

TransportConnectionParams

On connect(), the DailyTransport optionally takes a set of DailyCallOptions to connect to a Daily room. This can be provided directly or via a connection endpoint passed to the PipecatClient’s connect method. If using an endpoint, your endpoint should return a JSON object matching the DailyCallOptions type. See the client connect() documentation for more information.

pcClient.connect({
  url: 'https://your.daily.co/room'
});
// OR...
pcClient.connect({
  endpoint: 'https://your-server/connect',
});

Methods

For most operations, you will not interact with the transport directly. Most methods have an equivalent in the PipecatClient and should be called from the PipecatClient. However, there are a few transport-specific methods that you may need to call directly. When doing so, be sure to access your transport via the transport property of the PipecatClient instance.

  • preAuth()

    This is the one method meant to be called directly, which is used to allow you to gather information about the Daily room prior to connecting. As a Daily-specific action, it is not exposed through the PipecatClient. This method must be called prior to connect() and use the same room_url and token (optional) as what will be returned by your connection endpoint/eventually used on connect().

    pcClient.transport.preAuth({
      url: 'https://your.daily.co/room',
      token: 'your_token'
    });
    const roomInfo = pcClient.transport.dailyCallClient.room();
    

Events

The transport implements the various PipecatClient event handlers. For Daily-specific events, you can attach listeners to the underlying Daily call client. For a list of available events, see the Daily API Reference.

pcClient.transport.dailyCallClient.on('recording-started', (ev) => {...});

Advanced

Accessing the Daily Call

For advanced use cases, where you may need to work with the Daily call client directly, you can access it via the dailyCallClient property.

const dailyCall = pcClient.transport.dailyCallClient;

The Daily call client returned is safe-guarded to not allow you to call functions which affect the call’s lifecycle and will redirect you to use either a Transport method or the PipecatClient to perform the equivalent action.

More Information

Package

@pipecat-ai/daily-transport