# Pipecat integration

Source: https://docs.autessa.com/docs/integrations/pipecat

> Add the Autessa AI Application Firewall, SecurePass full-call redaction, and Autessa phone numbers to a Pipecat voice agent.

# Pipecat integration

(Preview)

These packages are in private preview. Names are final; details may change before release.

Three Pipecat packages. The firewall processor checks what the caller says and what your bot answers. The redaction processor records both sides of the call, then SecurePass redacts the full recording when the call ends. The phone transport answers an Autessa phone number with your pipeline.

Tested with Pipecat v1.15.0. Python 3.10 or later.

## Install

```bash
pip install pipecat-autessa-firewall pipecat-autessa-redact pipecat-autessa-phone
export AUTESSA_API_KEY="<keyId>:<secret>"
```

Install only the ones you need. Each one works on its own.

During the private preview, install from GitHub, Autessa packages first. For the firewall:

```bash
pip install "autessa-core @ git+https://github.com/Autessa-Inc/autessa-python#subdirectory=packages/autessa-core"
pip install "autessa-firewall @ git+https://github.com/Autessa-Inc/autessa-python#subdirectory=packages/autessa-firewall"
pip install "pipecat-autessa-firewall @ git+https://github.com/Autessa-Inc/pipecat-autessa#subdirectory=packages/pipecat-autessa-firewall"
```

For redaction or the phone transport, swap in `autessa-redact` and `pipecat-autessa-redact`, or `autessa-phone` and `pipecat-autessa-phone`.

## Minimal example

```python
import os

from pipecat.pipeline.pipeline import Pipeline
from pipecat.services.anthropic.llm import AnthropicLLMService

from pipecat_autessa_firewall import AutessaFirewallProcessor
from pipecat_autessa_redact import AutessaRedactionProcessor

llm = AnthropicLLMService(api_key=os.environ["ANTHROPIC_API_KEY"], model="claude-opus-5-5")

# Both read AUTESSA_API_KEY. Use the same session_id for both firewall instances.
check_user = AutessaFirewallProcessor(session_id="call-42", check="input")
check_bot = AutessaFirewallProcessor(session_id="call-42", check="output")

recorder = AutessaRedactionProcessor(
    external_id="call-42",
    types=["CARD_NUMBER", "CARD_CVV"],
    on_result=lambda result: print(result.status, result.redacted_audio_url),
)

@check_user.event_handler("on_blocked")
async def on_blocked(processor, phase, result):
    print("Blocked", phase, result.reasons)

pipeline = Pipeline([
    transport.input(),
    stt,
    check_user,         # checks the caller's words before the LLM sees them
    aggregators.user(),
    llm,
    check_bot,          # checks the bot's whole reply before it is spoken
    tts,
    transport.output(),
    recorder,           # after the output, so it hears both sides
    aggregators.assistant(),
])
```

`transport`, `stt`, `tts`, and `aggregators` are your usual Pipecat parts.

## How it works

- **Firewall input:** with `check="input"`, each final `TranscriptionFrame` is checked as `USER_INPUT`. A blocked message is dropped, and the bot says `blocked_message` instead.
- **Firewall output:** with `check="output"`, the bot's whole reply for the turn is checked as `FINAL_RESPONSE`. A blocked reply is replaced with `blocked_message`. The reply is held until the LLM finishes the turn, so it can be checked as a whole. The default, `check="both"`, does both in one processor.
- **Challenges:** when the policy asks for proof of identity, the bot reads the challenge prompt. The caller's next answer is checked, and the original message goes on only if it passes.
- **Approvals:** a message that needs a person's approval is held back, and the bot says `approval_message`.
- **Duress:** never shown to the caller. The conversation carries on, and the `on_duress` event fires so you can alert your team.
- **Monitor mode:** when the policy only monitors, everything passes, and `on_result` still reports what would have happened.
- **Voice check:** set `voice=True` to also check each caller turn's audio as `VOICE`, for cloned voices.
- **Tool definitions (Preview):** pass `tools` to check tool definitions at start, and each changed `LLMSetToolsFrame`, as `TOOL_DEFINITIONS`. A blocked tools frame is dropped.
- **Redaction:** nothing changes during the call, and redaction never runs live. The caller is channel 0 and the bot is channel 1, so place the processor after `transport.output()`.
- **Chunked upload (Preview):** audio is uploaded every `chunk_seconds`, so long calls are not held in memory.
- **End of call:** end the call with `queue_frame(EndFrame())`. On `EndFrame` or `CancelFrame` the processor finalizes the upload, and SecurePass redacts the full recording. Then it emits an `AutessaRedactionResult` with `status`, `redacted_audio_url`, `spans`, and, with `fetch_transcript=True`, the redacted `transcript`.
- **Failures never break the call:** firewall and upload errors go upstream as an `ErrorFrame`.

## Phone transport

(Preview)

`pipecat-autessa-phone` lets an Autessa phone number call into your Pipecat pipeline. Autessa answers the call and streams the audio to your server. Your pipeline is the brain.

```python
import os

from fastapi import FastAPI, WebSocket
from pipecat_autessa_phone import AutessaPhoneTransport, read_start

app = FastAPI()

@app.websocket("/call")
async def call(websocket: WebSocket):
    await websocket.accept()
    started = await read_start(websocket, auth_secret=os.environ["AGENT_WS_SECRET"])
    transport = AutessaPhoneTransport(websocket, started)
    print("Call from", started.from_number)
    ...  # build and run your pipeline with transport.input() and transport.output()
```

- `read_start` returns an `AutessaCall` with `call_id`, `number_id`, `from_number`, `to_number`, and `sample_rate`. With `auth_secret`, a call whose secret doesn't match raises `AutessaCallError`.
- Run the pipeline with `PipelineParams(audio_in_sample_rate=8000, audio_out_sample_rate=8000)`, and use the number's `AUDIO` mode.
- Push `transfer_frame("+15555550199")`, `mark_frame("name")`, or `hangup_frame()` to control the call.

See [Phone](/docs/features/phone.md) for routing a number to your own agent.

## Options

| Option | Package | What it does |
| --- | --- | --- |
| `session_id` | firewall | Your call id. Use the same one for both instances. |
| `check` | firewall | `input`, `output`, or `both` (default). |
| `subject_id` | firewall | Your stable id for the caller. |
| `policy_name` | firewall | Use a named firewall policy instead of the company policy. |
| `blocked_message` | firewall | What the bot says instead. Default: "Sorry, I can't help with that." |
| `drop_blocked` | firewall | Say nothing instead. |
| `voice` | firewall | Also run the voice check on caller audio. |
| `tools`, `tool_server` | firewall | Tool definitions to check at start, and where they come from. Preview. |
| `fail_open` | firewall | If a check can't be done (the firewall can't be reached, errors, or takes longer than `timeout`), let messages through. Default: treat them as blocked. |
| `timeout` | firewall | Seconds to wait for each check. Default 3. Longer counts as a failed check. `None` waits as long as the client does. |
| `external_id` | redact | Your id for the call. |
| `types` | redact | What to redact, for example `["CARD_NUMBER", "SSN"]`. Default: company settings. |
| `language` | redact | `en`, `es`, or `auto`. |
| `sample_rate` | redact | The rate the recording is stored at. Default 16000. |
| `chunk_seconds` | redact | How often to upload audio. Default 10. |
| `wait` | redact | Wait for redaction to finish before the result is sent. Default true. |
| `fetch_transcript` | redact | Put the redacted transcript in `result.transcript`. |
| `on_result` | redact | Callback with the `AutessaRedactionResult`. |
| `webhook_url` | redact | We POST the finished result here. |

Firewall events: `on_result(processor, phase, result)`, `on_blocked(processor, phase, result)`, `on_duress(processor, result)`. The redaction processor also fires `on_redaction_result`.

## Example

[pipecat-payment-line](https://github.com/Autessa-Inc/autessa-examples/tree/main/examples/pipecat-payment-line): a voice bot that takes a card payment from a recorded call. The firewall checks the caller and the bot, and SecurePass removes the card number from the full recording after the call.

## Related

- [AI Application Firewall](/docs/features/ai-application-firewall.md)
- [SecurePass call redaction](/docs/features/securepass.md)
- [Phone](/docs/features/phone.md)
- [Firewall API](/docs/reference/firewall.md)
- [SecurePass API](/docs/reference/securepass.md)
- [LiveKit integration](/docs/integrations/livekit.md)

