This project registers a Python SIP client as an extension in Asterisk/FreePBX and connects calls to OpenAI Voice Agent in real-time using WebSocket.
- Asterisk/FreePBX server with a configured SIP extension
- Docker and Docker Compose
- OpenAI API Key and Voice Agent ID
docker-compose.yml: Sets up the containerDockerfile: Builds Python environmentapp/agent.py: Python SIP client code.env: Configuration for SIP and OpenAI
- Edit
.env:
SIP_DOMAIN=your.asterisk.ip.or.domain
SIP_USER=1001
SIP_PASS=yourpassword
OPENAI_API_KEY=sk-...
AGENT_ID=va_...- Build and Run:
docker compose up --build- Check Logs:
Make sure the SIP client registers and waits for incoming calls.
- Registers as a SIP extension
- Answers incoming calls
- Streams audio to OpenAI's Voice Agent
- Sends replies back to the caller in real time
Call the extension you configured in FreePBX and start a conversation with your AI assistant ποΈ
- Basic SIP client implementation
- OpenAI Voice API integration
- Docker containerization
- Multi-stage Docker build for optimized image size
- Improved error handling and logging
- Added port exposures for SIP and RTP
- Added monitoring interface
- Enhanced call state management
- Token usage tracking
Contributions are welcome! Here's how you can help improve this project:
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name
- Commit your changes:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature/your-feature-name
- Open a Pull Request
- Follow PEP 8 style guide for Python code
- Document new functions and classes
- Add appropriate error handling
- Write tests for new features when possible
Made with β€οΈ for real-time AI voice interaction.