Most AI voice demos start with a telephony API. You get webhooks, clean call events and an audio stream, and the interesting problem is the conversation.
My Google Voice Dispatch Agent doesn't get any of that. It drives Google Voice inside a real Chrome window, and that changes where the hard work is. The AI reply turned out to be the easy part. The hard part was knowing, with confidence, whether someone had actually picked up.
This post walks through how the agent is put together, based on what's in the repo.
Repo: https://github.com/mafzalkalwardev/google-voice-dispatch-agent (MIT licensed)
In short, it's an outbound AI calling console for Windows:
The README describes the flow in ten steps, and I'll keep it close to that:
.env, dialer_config.json, contacts and CRM data. detect_call_state() until connected, voicemail, no answer, ended or failed.
Step 4 is small but matters a lot. If you generate the greeting after someone says "hello", they hear dead air and hang up. Pre-generating it means the agent can talk the moment the call is confirmed.
Here's the thing about automating a web UI: the DOM is noisy. Buttons appear early, old "call ended" banners linger, and voicemail-looking cues can show up while the phone is still ringing. If you trust the first signal you see, the bot either talks over the ring tone or hangs up on a real person.
So the core of the project is a conservative gate in src/google_voice.py. The rules it enforces:
min_ring_seconds has to pass before connected, ended or voicemail transitions are accepted.max_ring_seconds ends the attempt as no answer only after the ring timeout.
Every decision is logged too: current state, elapsed ring time, DOM cues, answered controls, call-active status, voicemail cues, the audio classifier result and the timeout reason. When a call goes wrong, I can read exactly why the agent thought what it thought.
The design principles in the README sum it up:
Once the gate says "connected", conversation_loop.py takes over. The modules split up cleanly:
src/
google_voice.py Selenium Google Voice automation and call-state detection
call_session.py Call session model and CallState transitions
conversation_loop.py Realtime capture, VAD, STT, LLM, TTS, voicemail handoff
voicemail_detector.py Audio classifier for greeting/beep/live-call signals
ai_groq.py Groq-backed AI response behavior
realtime_tts.py Edge TTS playback and cache integration
audio_capture.py Input capture and VAD framing
audio_routing.py Windows audio-device discovery and playback routing
The loop works like this:
audio_capture.py captures the caller's audio and frames it for voice activity detection, so the agent knows when the person has started and stopped talking.ai_groq.py generates the reply.realtime_tts.py speaks it with Edge TTS, with caching, and pyttsx3 as a fallback.
Several knobs in dialer_config.json relate directly to this loop:
{
"min_ring_seconds": 2,
"max_ring_seconds": 45,
"voicemail_detect_seconds": 15,
"silence_does_not_end_call": true,
"call_cooldown_seconds": 10,
"tts_warmup": true,
"stt_retry_count": 2,
"vad_silence_frames": 12,
"vad_speech_frames": 2
}
silence_does_not_end_call is a nice example of a lesson baked into config: people go quiet on the phone, and that shouldn't be read as a hang-up.
The minimum VB-CABLE setup from the README:
CABLE Input
CABLE Output
For unattended runs, the README recommends separate routes for TTS and inbound capture, and warns against capturing the same speaker output that plays the agent's voice. Otherwise the agent can end up transcribing itself. CAPTURE_DEVICE=default uses Windows speaker loopback, which is fine for testing but less reliable for nonstop calling.
There are CLI helpers for checking this before going live:
python -m src.main --list-audio-devices
python -m src.main --audio-route-test
python -m src.main --preflight
The agent can also run more than one line. Each worker gets its own Chrome profile and pulls from one shared contact queue. The important safety rule: shared audio routes are rejected by default, "because one AI response would otherwise be broadcast into multiple calls." Each slot needs its own loopback and capture pair, like CABLE-A and CABLE-B.
Google Voice accounts can be managed from the console. Saved passwords are protected with Windows DPAPI and never returned by the web API, and MFA or CAPTCHA challenges still have to be completed by a human in the visible Chrome window.
And please: anything that dials real people needs consent, Do Not Call compliance and call-recording disclosure where required. The README also recommends keeping min_ring_seconds above zero, using a cooldown, and not rapid-firing failed numbers.
If you're working on voice agents on top of tools you already use, I'd like to hear what broke first for you.
Open to freelance & remote work
Portfolio: https://mafzalkalwardev.github.io/#hire-me
GitHub: https://github.com/mafzalkalwardev
WhatsApp: +92 307 9670503 — https://wa.me/923079670503