How My Google Voice AI Agent Knows When to Talk: Call-State Detection, Groq and TTS A developer built the Google Voice Dispatch Agent, an MIT-licensed outbound AI calling console for Windows that drives Google Voice inside a real Chrome window via Selenium rather than a telephony API. The project's core is a conservative call-state gate in src/google_voice.py that enforces a minimum ring time before accepting connected, ended or voicemail transitions and logs every decision, after which a conversation loop handles VAD-based audio capture, Groq-backed replies and Edge TTS playback with caching and a pyttsx3 fallback. 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 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 https://mafzalkalwardev.github.io/ hire-me GitHub: https://github.com/mafzalkalwardev https://github.com/mafzalkalwardev WhatsApp: +92 307 9670503 — https://wa.me/923079670503 https://wa.me/923079670503