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

# Asterisk Frame Serializer

> AsteriskFrameSerializer converts between Pipecat frames and an Asterisk server's media stream for self-hosted telephony.

> [!NOTE]
>
> **Community-maintained integration.** This service is built and
> maintained by
> [NikolayShakin](https://github.com/NikolayShakin)
> . Pipecat does not test or officially support it. Please report issues and
> request changes on the
> [source repository](https://github.com/NikolayShakin/pipecat-asterisk)
> . Learn more about
> [community integrations](https://docs.pipecat.ai/api-reference/server/services/community-integrations.md)
> .

## Overview

`AsteriskFrameSerializer` converts between Pipecat frames and the media stream
of an [Asterisk](https://www.asterisk.org/) WebSocket channel. It translates the
channel's JSON or plain-text events and raw audio payloads into Pipecat frames
(and vice versa), so a Pipecat pipeline can handle telephony calls bridged
through Asterisk. The serializer is designed to be used with Pipecat's
`FastAPIWebsocketTransport`.

> [card] [Source Repository](https://github.com/NikolayShakin/pipecat-asterisk)
>
> Source code, examples, and issues for the Asterisk integration

> [card] [PyPI Package](https://pypi.org/project/pipecat-asterisk/)
>
> The `pipecat-asterisk` package on PyPI

> [card] [Asterisk](https://www.asterisk.org/)
>
> Learn more about the Asterisk open-source telephony platform

> [card] [WebSocket Channel Docs](https://docs.asterisk.org/Configuration/Channel-Drivers/WebSocket/)
>
> Asterisk WebSocket channel driver documentation

## Installation

This is a community-maintained package distributed separately from `pipecat-ai`:

```bash theme={null}
uv add pipecat-asterisk
```

Or use `pip install pipecat-asterisk` if you manage dependencies with `pip`.

## Prerequisites

Asterisk is a self-hosted, open-source telephony platform, so there is no
provider account or API key to configure. You need:

1. **An Asterisk server** with a WebSocket channel configured. The serializer
   and transport are based on the
   [Asterisk WebSocket channel](https://docs.asterisk.org/Configuration/Channel-Drivers/WebSocket/).
2. **`slin`-encoded audio**: The serializer works with `slin` audio, since
   Asterisk natively supports all flavors of `slin` and Pipecat audio frames
   must be `slin`-encoded. Transcode on the Asterisk side if you need a
   different codec.

The repository includes an example `docker-compose.yml` and Asterisk
configuration files under `examples/pipecat_asterisk/` to spin up a local
testing environment. See the
[source repository](https://github.com/NikolayShakin/pipecat-asterisk) for
details.

## Configuration

`AsteriskFrameSerializer` is constructed with a single optional parameter:

**sample\_rate** `int` (default: 0)

Sample rate in kHz used by the Asterisk channel. When left at `0`, it is
populated during setup or from the Asterisk `MEDIA_START` event. Supported
`slin` sample rates are `12, 16, 24, 32, 44, 48, 96, 192, 128` kHz.

> [!NOTE]
>
> This serializer does not use the Pipecat Settings dataclass pattern. See the
> [source repository](https://github.com/NikolayShakin/pipecat-asterisk) for the
> authoritative, up-to-date implementation.

## Usage

Pass the serializer to a `FastAPIWebsocketTransport` through
`FastAPIWebsocketParams`, then build your pipeline as usual:

```python theme={null}
from fastapi import WebSocket
from pipecat.pipeline.pipeline import Pipeline
from pipecat.pipeline.worker import PipelineWorker
from pipecat.transports.websocket.fastapi import (
    FastAPIWebsocketTransport,
    FastAPIWebsocketParams,
)
from pipecat_asterisk import AsteriskFrameSerializer


async def run_bot(websocket: WebSocket):
    transport = FastAPIWebsocketTransport(
        websocket=websocket,
        params=FastAPIWebsocketParams(
            serializer=AsteriskFrameSerializer(),
            audio_in_enabled=True,
            audio_out_enabled=True,
        ),
    )

    pipeline = Pipeline(
        [
            transport.input(),
            # ... VAD, STT, LLM, TTS, etc.
            transport.output(),
        ]
    )

    worker = PipelineWorker(pipeline)
    # ... run the pipeline
```

> [!TIP]
>
> The package also ships an `AsteriskWebsocketTransport`, which wraps this
> serializer together with flow-control logic for managing buffer utilization
> between Pipecat and Asterisk. See the [source
> repository](https://github.com/NikolayShakin/pipecat-asterisk) for the full
> example.

## Compatibility

Tested with Pipecat v1.1.0 and Python 3.12+. Check the
[source
repository](https://github.com/NikolayShakin/pipecat-asterisk) for the latest
tested version and changelog.


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