Skip to content

DaddyFilth/ai-service

Repository files navigation

AI Call Service

A self-hosted PBX with AI call screening using VoIP/WebRTC with zero carrier costs.

Overview

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.

Architecture

Caller (SIP/WebRTC)
        ↓
   SIP Server (Asterisk)
        ↓
   Media (RTP)
        ↓
   STT (Whisper)
        ↓
   Ollama (Decision Engine)
        ↓
   Action Router
   ├── Forward (SIP)
   ├── Voicemail (Record)
   └── Ask Question (TTS)

Features

  • 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

Requirements

  • Python 3.8+
  • Asterisk PBX (for production SIP handling)
  • Ollama (for AI decision engine)
  • FFmpeg (for audio processing)

Installation

  1. Clone the repository:
git clone https://github.com/DaddyFilth/ai-service.git
cd ai-service
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure environment variables. Edit .env with your configuration if needed.

  2. Install and start Ollama:

# Follow instructions at https://ollama.ai
ollama pull llama2

Configuration

Edit .env file with your settings:

  • ASTERISK_HOST: Your Asterisk server address
  • ASTERISK_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)

Running the Service

As a standalone script:

python main.py

As a web API:

python api.py

Integration with Asterisk

Generate Asterisk configuration files automatically:

# Generate configuration files
python asterisk_config_generator.py

# Install the generated configurations
cd asterisk-configs
sudo bash install_configs.sh

The auto-config generator creates:

  • ari.conf - REST API configuration
  • http.conf - HTTP server settings
  • extensions.conf - Call routing dialplan
  • pjsip.conf - SIP endpoint configuration
  • Installation script with automatic backup

Security

  • Automatic Password Validation: Passwords are validated for strength at startup.
  • Auto-generated passwords: Secure random generation for passwords.
  • Never hardcoded: All passwords stored in .env file (excluded from git).
  • .env file permissions automatically set to 600 (owner-only).
  • Generated Asterisk configs use placeholders, never actual passwords.

License

MIT License

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

About

A self-hosted PBX With AI call screening Using VoIP / WebRTC With zero carrier costs

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors