A self-hosted PBX with AI call screening using VoIP/WebRTC with zero carrier costs.
This service provides intelligent call routing and screening using AI. It integrates with Asterisk for SIP/VoIP handling and uses AI models for call analysis and decision making.
Caller (SIP/WebRTC)
↓
SIP Server (Asterisk)
↓
Media (RTP)
↓
STT (Whisper)
↓
Ollama (Decision Engine)
↓
Action Router
├── Forward (SIP)
├── Voicemail (Record)
└── Ask Question (TTS)
- SIP/WebRTC Integration: Handle incoming calls via Asterisk
- Speech-to-Text: Transcribe caller speech using OpenAI Whisper
- AI Decision Engine: Analyze calls using Ollama for intelligent routing
- Action Router: Three routing options:
- Forward: Route calls to specific extensions/numbers
- Voicemail: Record messages
- Ask Question: Interactive TTS-based conversation
- Python 3.8+
- Asterisk PBX (for production SIP handling)
- Ollama (for AI decision engine)
- FFmpeg (for audio processing)
- Clone the repository:
git clone https://github.com/DaddyFilth/ai-service.git
cd ai-service- Install dependencies:
pip install -r requirements.txt-
Configure environment variables. Edit
.envwith your configuration if needed. -
Install and start Ollama:
# Follow instructions at https://ollama.ai
ollama pull llama2Edit .env file with your settings:
ASTERISK_HOST: Your Asterisk server addressASTERISK_PORT: SIP port (default: 5060)OLLAMA_HOST: Ollama server URL (default: http://localhost:11434)OLLAMA_MODEL: AI model to use (default: llama2)SERVICE_PORT: API server port (default: 8000)MIN_FREE_SPACE_MB: Minimum free disk space for recordings (default: 100 MB)
python main.pypython api.pyGenerate Asterisk configuration files automatically:
# Generate configuration files
python asterisk_config_generator.py
# Install the generated configurations
cd asterisk-configs
sudo bash install_configs.shThe auto-config generator creates:
ari.conf- REST API configurationhttp.conf- HTTP server settingsextensions.conf- Call routing dialplanpjsip.conf- SIP endpoint configuration- Installation script with automatic backup
- Automatic Password Validation: Passwords are validated for strength at startup.
- Auto-generated passwords: Secure random generation for passwords.
- Never hardcoded: All passwords stored in
.envfile (excluded from git). .envfile permissions automatically set to 600 (owner-only).- Generated Asterisk configs use placeholders, never actual passwords.
MIT License
Contributions are welcome! Please open an issue or submit a pull request.