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

# Rabel Bell

> RabelBellUserTurnStrategies: user turn strategies that start the bot's reply early on Bell's guess at how the user's turn will end

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

## Overview

`RabelBellUserTurnStrategies` work like Pipecat's
[eager turn strategies](https://docs.pipecat.ai/api-reference/server/utilities/turn-management/user-turn-strategies.md), plus Bell. The words
transcribed so far go to Bell, a hosted model from [Rabel Labs](https://rabellabs.com), which may answer with one guess at
how the turn will end.
The stop strategy starts the LLM on the guess with `start_user_turn_speculation()` while the user is still speaking.
Pipecat keeps that reply only if the final transcript matches the guess, and otherwise answers the final words.

Bell is in beta. It works best on agents whose callers come for the same few things, like a bank's phone line or a
booking desk. Where callers talk freely, Bell has little to guess and mostly stays quiet, and the call runs as it would
without it. It learns each agent's callers from that agent's finished calls, so a new agent gets no guesses at first.
The demo agent `demo-bank` is already trained and never learns, so a first call shows a kept early reply. If Bell is slow
or unreachable, the turn goes as without it and one line is logged.

On recorded, scripted bank calls in English, transcribed by Deepgram Flux, Bell started the reply 170 ms a turn sooner
\[159, 182] than Pipecat 1.16.0 with no early start, at 0.07 more LLM calls a turn. That is when the LLM starts. Pipecat holds an early
reply until the turn ends, so the caller hears less of it: in one reading with Claude Haiku 5.5, the first audio came 133 ms
a turn sooner \[125, 142]. Bell had learned 1,070 calls and was
measured on 28 callers it had not heard, with Flux's eager end of turn off and no local VAD. The [benchmark](https://github.com/rabellabs/bell-benchmark) has the method, the other rows and the limits.

> [card] [Source Repository](https://github.com/rabellabs/pipecat-rabel)
>
> Source code, example bot, tests and issues for pipecat-rabel

> [card] [Rabel Docs](https://rabellabs.com/docs)
>
> API keys, pricing, each agent's status and what Rabel keeps

## Installation

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

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

## Prerequisites

* **Pipecat 1.16.0 or later** and Python 3.11 or later
* **A Rabel API key** in `RABEL_API_KEY`, from [rabellabs.com](https://rabellabs.com). The first 10,000 minutes are free.
* **A speech-to-text service that sends interim transcriptions and ends the turn**, such as Deepgram Flux

> [!NOTE]
>
> Like Pipecat's eager turn strategies, these take the place of Smart Turn. A
> bot that relies on Smart Turn switches it off to use Bell.

## Configuration

```python theme={null}
from pipecat_rabel import RabelBellUserTurnStrategies
```

### RabelBellUserTurnStrategies

The stop strategy is `strategies.bell`. It and `RabelBellUserTurnStrategies` both take Pipecat's eager `match_policy` and `speculation_timeout`.

**api\_key** `str | None` (default: None)

Rabel API key. `None` reads `RABEL_API_KEY`. With no key, Bell stays off and
the strategy is Pipecat's eager one.

**agent** `str` (default: default)

The agent Bell learns for: 1 to 64 lower-case letters, digits, `-` and `_`.
Calls that share an agent name share what Bell learns. Give each voice agent
you run its own name, such as `front-desk` or `billing`, and keep all of that
agent's calls under it.

**min\_chance** `float` (default: 0.7)

How sure Bell must be before it guesses, from 0.67 to 0.99. Higher means fewer
guesses and fewer wrong ones. Values out of range are clamped.

**learn** `bool` (default: True)

`False` means this call teaches Bell nothing.

**report** `bool` (default: True)

Reports at each turn's end whether the guess was kept or dropped, so the
agent's status can show it. No words are sent with the report.

**user** `str | None` (default: None)

An id you choose for the person on the call, up to 128 characters. Bell does
not use it yet. Never a name, a phone number or an address.

**vendor** `str | None` (default: None)

The speech-to-text in use, for example `"deepgram/flux-general-en"`. Used for
usage reports only.

**connect\_timeout** `float` (default: 2.0)

Seconds allowed to open a conversation with the API.

**answer\_timeout** `float` (default: 0.5)

Seconds after the words it answers within which a guess is still used. A later
guess is dropped.

**url** `str | None` (default: None)

The API's address. `None` reads `RABEL_API_URL`, then uses Rabel's API.

## Usage

Give the strategies to the user aggregator:

```python theme={null}
import os

from pipecat.pipeline.pipeline import Pipeline
from pipecat.processors.aggregators.llm_context import LLMContext
from pipecat.processors.aggregators.llm_response_universal import (
    LLMContextAggregatorPair,
    LLMUserAggregatorParams,
)
from pipecat.services.deepgram.flux.stt import DeepgramFluxSTTService
from pipecat_rabel import RabelBellUserTurnStrategies

stt = DeepgramFluxSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))

context = LLMContext()
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
    context,
    user_params=LLMUserAggregatorParams(
        user_turn_strategies=RabelBellUserTurnStrategies(agent="demo-bank"),
    ),
)

pipeline = Pipeline(
    [
        transport.input(),
        stt,
        user_aggregator,
        llm,
        tts,
        transport.output(),
        assistant_aggregator,
    ]
)
```

[`examples/bank_call.py`](https://github.com/rabellabs/pipecat-rabel/blob/main/examples/bank_call.py) is a complete
bot on `demo-bank`. Say "I need to reset my password" and the log shows the guess and the head start.

## Notes

* **Tool calls**: A reply started on a guess never runs a tool call.
* **Ending the turn**: Let these turn strategies end the turn. If your app or a processor ahead of the user aggregator,
  such as `UserTurnProcessor`, pushes `UserStoppedSpeakingFrame` itself, Pipecat releases the early reply before it checks
  the final transcript, and the user can hear both replies.
* **Local VAD**: With a local VAD in the pipeline, a pause followed by more speech withdraws the early reply. That guess
  costs one LLM call and gains nothing.
* **Flux's eager end of turn**: With Flux's `enable_eager_end_of_turn=True`, Pipecat also answers early on Flux's own
  ends of turn.
* **What is sent**: Only transcript text goes to Rabel's API, never audio. What Rabel keeps and how to delete it is in
  its [notice](https://rabellabs.com/api-privacy).

## Event Handlers

| Event | Description |
| - | - |
| `on_ready` | The conversation with Bell opens. Arguments: `strategy, ready`. |
| `on_guess` | An early reply starts on Bell's guess. Arguments: `strategy, text, chance`. |
| `on_turn_end` | A turn sent to Bell ends on its final transcript. Arguments: `strategy, final, guess, right`. |

Register handlers on `strategies.bell`:

```python theme={null}
from loguru import logger

strategies = RabelBellUserTurnStrategies(agent="demo-bank")


@strategies.bell.event_handler("on_turn_end")
async def on_turn_end(strategy, final, guess, right):
    logger.info(f"Final words: {final!r}. Bell's guess: {guess!r}. Right: {right}")
```

`strategy.stats` counts turns, guesses received, started, dropped and right, and failures by kind.

## Compatibility

Last tested with Pipecat v1.17.0.


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