> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pipecat.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Daily WebRTC Transport

> DailyTransport for the Pipecat JavaScript SDK: WebRTC audio and video on Daily's infrastructure, wrapping a Daily-JS call client.

The DailyTransport class provides a WebRTC transport layer using [Daily.co's](https://daily.co) 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](https://docs.daily.co/reference/daily-js).

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](https://docs.pipecat.ai/api-reference/server/services/transport/daily) implementation.

## Usage

### Basic Setup

```javascript theme={null}
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({
  url: "https://your-domain.daily.co/room",
  token: "your-daily-token", // Optional, if your room requires authentication
});
```

## API Reference

### Constructor Options

```typescript theme={null}
interface DailyTransportConstructorOptions extends DailyFactoryOptions {
  bufferLocalAudioUntilBotReady?: boolean;
}
```

**bufferLocalAudioUntilBotReady** `boolean` (default: false)

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](https://docs.daily.co/reference/daily-js/daily-call-client/properties) for a complete list of options. `dailyConfig.useDevicePreferenceCookies` defaults to `true` unless you set it.

> [!NOTE]
>
> 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 with `startBot()` or directly as part of `connect()`. See below.

### TransportConnectionParams

On `connect()`, the `DailyTransport` optionally takes a set of [`DailyCallOptions`](https://docs.daily.co/reference/daily-js/daily-call-client/properties) to connect to a Daily room. This can be provided directly to the `PipecatClient`'s `connect()` method or via a starting endpoint passed to the `PipecatClient`'s `startBotAndConnect()` method. If using an endpoint, your endpoint should return a JSON object matching the `DailyCallOptions` type. The transport also accepts `room_url` or `dailyRoom` in place of `url`, and `dailyToken` in place of `token`. See the [client connect()](https://docs.pipecat.ai/api-reference/client/js/client-methods.md#connect) documentation for more information.

```typescript client theme={null}
pcClient.connect({
  url: 'https://your.daily.co/room'
});
// OR...
pcClient.startBotAndConnect({
  endpoint: '/api/start', // Your server endpoint to start the bot
});
```

```python server theme={null}
import os
import subprocess

@app.post("/api/start")
async def start(request: Request) -> Dict[Any, Any]:
    print("Creating room and token for RTVI connection")
    room_url, token = await create_room_and_token()

    # Start the bot process
    print("Starting bot subprocess")
    try:
        subprocess.Popen(
            [f"python3 bot.py -u {room_url} -t {token}"],
            shell=True,
            bufsize=1,
            cwd=os.path.dirname(os.path.abspath(__file__)),
        )
    except Exception as e:
        raise HTTPException(status_code=500, detail=f"Failed to start subprocess: {e}")

    # Return the Daily call options in format expected by DailyTransport/Daily Call Object
    return {"url": room_url, "token": token}
```

### 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()`

  Gathers information about the Daily room before connecting. As a Daily-specific action, it is not exposed through the `PipecatClient`. Call it before `connect()` with the same `url` and `token` (optional) that you will use on `connect()`. The options you pass replace the constructor options that the transport later passes to Daily's `startCamera()` and `join()`, including the `startAudioOff` and `startVideoOff` values derived from `enableMic` and `enableCam`, so include any of those you still need.

  ```typescript theme={null}
  const transport = pcClient.transport as DailyTransport;
  await transport.preAuth({
    url: "https://your.daily.co/room",
    token: "your_token",
  });
  const roomInfo = await transport.dailyCallClient.room();
  ```

* `getSessionInfo()`

  Returns the Daily call client's `meetingSessionSummary()` for the current session.

  ```typescript theme={null}
  const sessionInfo = (pcClient.transport as DailyTransport).getSessionInfo();
  ```

## Media Support

`DailyTransport` carries the microphone, camera, screen share, bot audio, and bot video. `screenShare` is `true` only where the browser supports screen capture. See [`mediaSupport`](https://docs.pipecat.ai/api-reference/client/js/client-methods#mediasupport).

## Events

The transport implements the various [`PipecatClient` event handlers](https://docs.pipecat.ai/api-reference/client/js/callbacks). 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](https://docs.daily.co/reference/daily-js/events).

```typescript theme={null}
(pcClient.transport as DailyTransport).dailyCallClient.on(
  "recording-started",
  (ev) => {
    // ...
  },
);
```

`DailyTransport` also calls two callbacks of its own. Pass them in the `PipecatClient` `callbacks` option; in TypeScript, type that object as the exported `DailyEventCallbacks`:

| Callback | Description |
| - | - |
| `onAudioBufferingStarted` | Called when the transport starts buffering local audio (`bufferLocalAudioUntilBotReady`). |
| `onAudioBufferingStopped` | Called when buffering stops: once the transport sends its ready message, or on disconnect. |

## 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.

```javascript theme={null}
const dailyCall = pcClient.transport.dailyCallClient;
```

> [!NOTE]
>
> 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

> [card] [Demo](https://github.com/pipecat-ai/pipecat-examples/tree/main/simple-chatbot)
>
> Simple Chatbot Demo

> [card] [Source](https://github.com/pipecat-ai/pipecat-client-web-transports/tree/main/transports/daily)
>
> `DailyTransport`

> [card] [Package](https://www.npmjs.com/package/@pipecat-ai/daily-transport)
>
> `@pipecat-ai/daily-transport`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.