diff --git a/api-reference/server/services/community-integrations.mdx b/api-reference/server/services/community-integrations.mdx index 5ac40f39..a8ff7661 100644 --- a/api-reference/server/services/community-integrations.mdx +++ b/api-reference/server/services/community-integrations.mdx @@ -66,6 +66,7 @@ Serializers convert between frames and media streams, enabling real-time communi | Service | Repository | Maintainer(s) | | -------------------------------- | ------------------------------------------ | ------------------------------------- | +| [Asterisk](https://www.asterisk.org/) | https://github.com/NikolayShakin/pipecat-asterisk | [Nikolai Shakin](https://github.com/NikolayShakin) | | [AwaazAI](https://www.awaaz.ai/) | https://github.com/awaazde/pipecat-awaazai | [AwaazAI](https://github.com/awaazde) | | [Wavix](https://wavix.com/) | https://github.com/wavix/pipecat-wavix | [Wavix](https://github.com/wavix) | diff --git a/pipecat/telephony/asterisk-websocket.mdx b/pipecat/telephony/asterisk-websocket.mdx new file mode 100644 index 00000000..3cbc8951 --- /dev/null +++ b/pipecat/telephony/asterisk-websocket.mdx @@ -0,0 +1,83 @@ +--- +title: "Asterisk Websocket Channel" +description: "Complete guide to Asterisk integration" +--- + +## Things you'll need + +- Asterisk (version >= 22.8.2) installed +- Pipecat (version >= 1.1.0) +- At least configured sip profile configured both on Asteriks and your sip-devece/softphone +- API key for Gemini + +## Simplest setup +- Install Docker +- Clone the [project](https://github.com/NikolayShakin/pipecat-asterisk) +- Add your API key for Germini in `.env` +- Run container with asterisk `cd examples/pipecat_asterisk && docker-compose up -d` +- Run pipecat app `uv run examples/pipecat_asterisk/ws_server.py` +- Register your sip-phone on 127.0.0.1:5060, Dial 24 + +## Custom setup with your Asterisk instance +### Asterisk configuration + +``` +extensions.conf +exten = 8,1,Dial(WebSocket/pipecat/c(slin)) ; Sampling rate 8kHz +;; Optionally +exten = 12,1,Dial(WebSocket/pipecat/c(slin12)) ; Sampling rate 8kHz +... +exten = 192,1,Dial(WebSocket/pipecat/c(slin192)) ; Sampling rate 192kHz +``` + +``` +websocket_client.conf +[pipecat] +type = websocket_client +uri = ws://127.0.0.1:7860/ws ; Assuming pipecat running on the same host. Adjust the address if needed +protocols = media +connection_type = per_call_config +connection_timeout = 100 +reconnect_interval = 50 +reconnect_attempts = 3 +tls_enabled = no +``` +### Pipecat configuration +Create and run your pipeline using `AsteriskWebsocketTransport` like this: +``` +from fastapi import FastAPI, WebSocket +from pipecat.pipeline.pipeline import Pipeline +from pipecat.pipeline.task import PipelineTask +from pipecat_asterisk import AsteriskWebsocketTransport + +app = FastAPI() + +@app.websocket("/ws") +async def websocket_endpoint(websocket: WebSocket): + await websocket.accept() + + # Initialize the Asterisk Transport + ws_transport = AsteriskWebsocketTransport(websocket=websocket) + + # Build your Pipecat pipeline + pipeline = Pipeline([ + ws_transport.input(), + # ... other pipeline components (VAD, LLM, TTS, etc.) + ws_transport.output(), + ]) + + task = PipelineTask(pipeline) + + # Run the pipeline + # ... +``` +`uv run your_pipeline.py` + +### Dial +Configure your sip-phone to work with asterisk and dial `8` or any other configured extension if you want to test different sampling rates. + + +## Next Steps + +- Explore the [example](https://github.com/pipecat-ai/pipecat/tree/main/examples) +- Learn about [Asterisk websocket channel](https://docs.asterisk.org/Configuration/Channel-Drivers/WebSocket/)