Skip to main content

Voice by aiConnected — A Developer’s Introduction

What This Document Is

This document explains Voice by aiConnected for developers who are new to voice AI, real-time systems, or this specific project. It covers what we’re building, how the pieces fit together, and what you need to understand to contribute effectively. If you’re joining this project and want to get up to speed quickly, start here.

What We’re Building

The One-Sentence Version

A platform that connects phone calls to AI agents that can have natural conversations, take actions, and transfer to humans when needed.

The One-Paragraph Version

Voice by aiConnected is a multi-tenant Voice AI platform. When someone calls a business using our service, the call is answered by an AI that listens (using speech-to-text), thinks (using a large language model), and responds (using text-to-speech). The AI has access to information about the business and can perform actions like scheduling appointments or updating CRM records. When the AI can’t handle something, it seamlessly transfers the call to a human.

The Visual Version


Core Concepts You Need to Understand

1. The Voice Pipeline

Voice AI is essentially a pipeline that transforms audio → text → response → audio:
Each step has latency, and latency is the enemy. If the AI takes too long to respond, the conversation feels unnatural. Our target is under 1 second from when the caller stops speaking to when they hear the AI’s response.

2. Streaming vs. Batch Processing

The key to achieving low latency is streaming. Instead of waiting for each stage to complete fully before starting the next, we stream data through the pipeline: Batch (slow):
Streaming (fast):
Every component in our stack supports streaming:
  • Deepgram provides interim transcription results
  • Claude streams tokens as they’re generated
  • Chatterbox synthesizes audio incrementally

3. WebRTC

WebRTC (Web Real-Time Communication) is a protocol for real-time audio/video over the internet. It’s what powers video calls in your browser. Key concepts:
  • Peer-to-peer — Direct connections between participants
  • SDP (Session Description Protocol) — How peers negotiate connection parameters
  • ICE (Interactive Connectivity Establishment) — How peers find a path to connect
  • Tracks — Individual audio or video streams
We use WebRTC to get audio from the phone system (GoToConnect) into our processing pipeline (LiveKit).

4. LiveKit

LiveKit is an open-source platform for real-time audio/video. Think of it as “Zoom/WebRTC infrastructure as a service.” Key concepts:
  • Rooms — Virtual spaces where participants connect
  • Participants — Entities in a room (could be users or AI agents)
  • Tracks — Audio or video streams published by participants
  • LiveKit Agents SDK — Framework for building AI agents that participate in rooms
In our system:
  • Each phone call creates a LiveKit room
  • The WebRTC bridge joins as one participant (representing the caller)
  • The AI agent joins as another participant
  • Audio flows between them through the room

5. State Machines

Phone calls have states: ringing, connected, on hold, transferred, ended. Managing these transitions correctly is crucial.
We use Redis to store call state because:
  • It’s fast (in-memory)
  • It’s ephemeral (call state doesn’t need to persist forever)
  • It supports pub/sub (for real-time notifications)

6. Multi-Tenancy

Multiple businesses (tenants) use the same platform. Each tenant has:
  • Their own phone numbers
  • Their own AI configuration (personality, knowledge base, tools)
  • Their own usage tracking and billing
  • Isolated data (Tenant A can’t see Tenant B’s calls)
This is implemented through:
  • Tenant IDs on all database records
  • Scoped API keys
  • Request-level tenant context

The Technology Stack

Languages & Frameworks

External Services

Databases & Storage

Infrastructure


Project Structure

Here’s how the codebase is organized:

Key Files You’ll Work With

WebRTC Bridge (services/webrtc-bridge/)

This is the trickiest part of the system. It:
  1. Receives calls from GoToConnect via WebRTC
  2. Extracts audio frames
  3. Publishes them to a LiveKit room
  4. Receives AI audio from LiveKit
  5. Sends it back to GoToConnect

AI Agent (services/agent-service/)

This is where the magic happens. The agent:
  1. Joins a LiveKit room
  2. Listens to the audio track from the bridge
  3. Transcribes it with Deepgram
  4. Generates a response with Claude
  5. Synthesizes speech with Chatterbox
  6. Publishes the audio back to the room

Call State Machine (shared/state/)

Manages the lifecycle of each call:

Development Workflow

Setting Up Your Environment

  1. Clone the repository
  1. Copy environment template
  1. Start local services
  1. Run migrations
  1. Start development servers

Testing a Call Locally

For local development, you’ll use test audio files instead of real phone calls:

Running Tests


Common Patterns You’ll See

1. Async Everything

Almost all our code is async because we’re dealing with I/O-bound operations (network calls, audio streaming). Get comfortable with:

2. Dependency Injection

We use FastAPI’s dependency injection for database sessions, authentication, tenant context:

3. Event-Driven Communication

Services communicate through events, not direct calls:

4. Circuit Breakers

External services can fail. We use circuit breakers to fail fast:

5. Graceful Degradation

When components fail, we degrade gracefully:

Key Challenges You’ll Face

1. Latency Optimization

Every millisecond matters. You’ll need to:
  • Profile everything
  • Avoid blocking operations
  • Stream wherever possible
  • Cache aggressively
  • Minimize network hops

2. Audio Quality

Telephone audio is 8kHz, muddy, and often has background noise. You’ll need to:
  • Handle different audio formats
  • Resample correctly
  • Understand codec differences
  • Deal with packet loss

3. Conversation Flow

Natural conversations have:
  • Interruptions (barge-in)
  • Pauses
  • Overlapping speech
  • Misunderstandings
The AI needs to handle all of these gracefully.

4. Error Recovery

Lots of things can fail:
  • Network issues
  • API rate limits
  • Audio dropout
  • Service outages
Your code needs to handle these without dropping calls.

5. Concurrency

Multiple calls happen simultaneously. You need to:
  • Avoid race conditions
  • Manage connection pools
  • Handle resource contention
  • Scale horizontally

Glossary


How to Get Help

Documentation

  1. This document — Start here for overview
  2. Master Project Task List — Overall project plan
  3. Individual specification documents — Deep dives into each component
  4. Skills folder — API reference for each provider

Code

  1. Read the tests — Tests show how things are supposed to work
  2. Read the types — Type hints document expected inputs/outputs
  3. Read the docstrings — Functions should explain what they do

People

  1. Ask questions — No question is too basic
  2. Review PRs — See how others solve problems
  3. Pair program — Learn by doing together

Your First Tasks

If you’re new to the project, here are good starting points:

Beginner

  1. Set up your local development environment
  2. Run the test suite and make sure everything passes
  3. Read through the API gateway routes to understand the API surface
  4. Add a simple new endpoint (e.g., health check with more details)

Intermediate

  1. Add a new tool that the AI can call (e.g., check business hours)
  2. Improve error messages in a service
  3. Add metrics/logging to an existing component
  4. Write integration tests for an existing feature

Advanced

  1. Implement a new call feature (e.g., call recording)
  2. Optimize latency in the voice pipeline
  3. Add a new STT/TTS provider as a fallback
  4. Implement a complex state machine transition

Final Thoughts

Voice AI is a fascinating intersection of several technologies:
  • Real-time systems
  • AI/ML
  • Telecommunications
  • Distributed systems
It’s challenging because everything happens in real-time. You can’t hide latency behind a loading spinner. You can’t ask the user to refresh the page. The conversation has to flow naturally, and if anything goes wrong, it’s immediately obvious. But when it works, it’s magical. A computer that you can talk to like a person, that understands you, that helps you — that’s the future we’re building. Welcome to the team.
Last updated: 2026-01-16