AI-powered spam call detection and call screening agent for India. This LiveKit voice agent answers unknown callers, keeps suspected telemarketers talking for 38 seconds, transcribes the call with Sarvam STT, classifies the transcript with Gemini or OpenAI, and sends a Telegram spam alert with evidence and an optional TRAI DND complaint handoff.
Built for Indian spam-call workflows: credit card calls, loan offers, insurance sales, KYC/OTP phishing, fake bank calls, real estate promotions, and unsolicited commercial communication (UCC) reporting through TRAI 1909.
This project is a personal AI call-screening system for unknown and suspected spam callers in India. It combines LiveKit telephony, Sarvam speech models, Gemini/OpenAI language models, and Telegram notifications to create a voice agent that answers calls, gathers evidence, classifies spam, and prepares TRAI DND complaint drafts for user-approved reporting.
The goal is to reduce interruption from telemarketing and phishing calls while keeping the user in control. The agent does not silently report callers or send SMS messages; it provides a compact explanation, transcript evidence, caller number when available, and a confirmation path for sending a TRAI 1909 complaint.
AI spam call detection, spam call blocker, India DND app, TRAI DND, TRAI spam complaint, LiveKit voice agent, SIP call screening, Sarvam AI STT, Sarvam TTS, Gemini spam classifier, Telegram bot alerts, UCC complaint, phone scam detection, OTP phishing detection, telemarketing call filter.
- LiveKit Agents - Voice call runtime
- Sarvam
saaras:v3- Speech-to-text (STT) - Gemini
gemini-3.1-flash-lite- Development LLM and spam classification - Sarvam
bulbul:v3- Text-to-speech (TTS) - Telegram Bot API - Spam alerts with evidence
- AI call screening for unknown or forwarded phone calls
- 38-second stalling conversation to collect enough caller evidence
- India-specific spam detection for OTP phishing, credit card offers, loans, insurance, KYC, UPI/payment requests, real estate, and telemarketing
- Sarvam STT/TTS for India-friendly speech recognition and voice output
- LiveKit Telephony/SIP support for real inbound phone calls
- Telegram spam alerts with caller number, confidence, reason, evidence, and transcript snippet
- TRAI DND complaint draft in
Reason, caller-or-sender, dd/mm/yyformat - Report to TRAI button that opens a confirmation page and prefilled SMS to
1909 - User confirmation before reporting so the system does not silently send SMS
- Screen unknown phone calls before you answer them
- Detect Indian spam calls and telemarketing pitches
- Collect evidence from suspected phishing calls
- Prepare TRAI DND/UCC complaint drafts
- Build a personal AI call assistant with LiveKit, Sarvam, Gemini/OpenAI, and Telegram
- Prototype an Android companion app for unknown-number filtering
- Call comes in - Agent answers with "Hello."
- Stall phase (38s) - Agent keeps the caller talking with short filler responses
- Call ends - After 38 seconds, the agent disconnects
- Classification - Full transcript is sent to LLM for spam classification
- Telegram alert - You receive a formatted message with:
- Spam/Legitimate verdict
- Confidence score
- Reason
- Exact transcript lines that indicate spam (highlighted)
- Full transcript for reference
Development config uses the Gemini API free tier for both stalling conversation and spam classification:
LLM_PROVIDER=gemini
SPAM_CLASSIFIER_PROVIDER=gemini
GEMINI_API_KEY=your_gemini_api_key
SPAM_CLASSIFICATION_MODEL=gemini-3.1-flash-liteYou can switch back to OpenAI by setting both providers to openai and adding OPENAI_API_KEY.
You can override the default spam classification model:
SPAM_CLASSIFICATION_MODEL=custom-model-namesrc/agent.py- LiveKit worker entrypoint with spam detection pipelinesrc/spam_classifier.py- Provider-selecting transcript classifiersrc/gemini_llm.py- Gemini API adapter for development LLM/classificationsrc/telegram_notifier.py- Telegram alert sender with formatted messagessrc/trai_report.py- TRAI complaint draft and SMS handoff helperssrc/report_server.py- Optional confirmation page for Telegram report buttonssrc/config.py- Centralized configuration managementsrc/openai_classifier.py- OpenAI spam classification implementationsrc/classification_result.py- Spam classification result modelexceptions.py- Structured error handlingconfigs/agent_config.toml- Runtime settings for STT, LLM, TTS, voice, and spam detectiondocs/agent_instructions.md- Prompt for the stalling voice agent
- Install dependencies:
uv sync- Create your env file:
cp .env.example .env-
Fill in credentials (see below for Telegram and Gemini setup).
-
Start the worker:
uv run python -m src.agent start- Create a bot via @BotFather on Telegram
- Send
/newbot, follow prompts, copy the bot token - Start a chat with your new bot and send it any message
- Visit
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdatesto find yourchat_id(it's a number like123456789) - Add both to your
.env:
TELEGRAM_BOT_TOKEN=1234567890:ABCdef...
TELEGRAM_CHAT_ID=123456789
For spam calls, Telegram alerts now include a TRAI complaint draft in the SMS format:
Reason, caller-or-sender, dd/mm/yy
The user still reviews and sends the SMS to 1909; the backend does not silently send SMS from a SIM.
To show a Telegram Report to TRAI button, expose the optional confirmation server over HTTPS and set TRAI_REPORT_CONFIRM_URL:
uv run python -m src.report_serverTRAI_REPORT_CONFIRM_URL=https://your-public-domain.example/reportThe button opens the confirmation page, which then opens the phone SMS composer with 1909 and the complaint draft prefilled. A future Android companion app can replace this confirmation server/SMS handoff without changing the classifier.
LIVEKIT_URL=wss://your-project.livekit.cloud
LIVEKIT_API_KEY=your_livekit_api_key
LIVEKIT_API_SECRET=your_livekit_api_secret
SARVAM_API_KEY=your_sarvam_api_key
LLM_PROVIDER=gemini
SPAM_CLASSIFIER_PROVIDER=gemini
GEMINI_API_KEY=your_gemini_api_key
SPAM_CLASSIFICATION_MODEL=gemini-3.1-flash-lite
SPAM_CLASSIFICATION_MODEL=custom-model-name
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
TELEGRAM_CHAT_ID=your_telegram_chat_id
TRAI_REPORT_CONFIRM_URL=https://your-public-domain.example/report
TRAI_REPORT_SERVER_HOST=127.0.0.1
TRAI_REPORT_SERVER_PORT=8787
configs/agent_config.toml- Tune STT, LLM, TTS, voice behavior, and spam detection settings[spam_detection].call_duration_seconds- How long to keep the caller talking (default: 38)[spam_detection].max_transcript_length- Maximum transcript length in characters (default: 100000)[spam_detection].llm_timeout- LLM API timeout in seconds (default: 30.0)
docs/agent_instructions.md- Change the stalling agent behavior
To receive actual phone calls, route a phone number into LiveKit Telephony. Options include:
- LiveKit's included US local phone number on supported plans
- Third-party SIP providers such as Twilio, Exotel, Plivo, or Telnyx
- Conditional call forwarding from your mobile carrier to the LiveKit/SIP number
LiveKit creates a room for each inbound call and dispatches the spambuster-agent worker into that room. See LiveKit SIP docs for detailed setup.
docker build -t spam-detection-agent .The development config uses Gemini for text-to-text LLM calls:
Incoming Call
↓
LiveKit Room
↓
VoiceAgent (src/agent.py)
├─→ STT (Sarvam/Mock) → Transcript
├─→ LLM (Gemini or OpenAI) → Stalling responses
└─→ TTS (Sarvam/Mock) → Audio output
↓
After 38s timeout
↓
Extract Transcript
↓
SpamClassifier (spam_classifier.py)
├─→ Config (config.py)
├─→ GeminiClassifier or OpenAIClassifier
│ └─→ classify transcript
└─→ ClassificationResult
↓
TelegramNotifier (telegram_notifier.py)
├─→ Build HTML Message
├─→ Send to Telegram API
└─→ Return success/failure
↓
User receives alert
Run the test suite:
uv run pytest tests/ -vRun specific test categories:
# Classifier tests
uv run pytest tests/test_openai_classifier.py -v
# Integration tests
uv run pytest tests/integration/ -v
# All tests with coverage
uv run pytest tests/ --cov=src --cov-report=html