Skip to main content
LobbyStack is an MIT-licensed TypeScript monorepo that you can fork, self-host and resell. This page explains which runtime does what, how a call and a chat run through the code, and which package to change for each kind of work. To run LobbyStack first, follow the self-hosting quickstart.

Runtimes and packages

Two apps run in production. The packages hold the code they share: The repository’s AGENTS.md lists the commands and the rules each package follows.

Where data lives

PostgreSQL holds every durable record. Each runtime connects as one of four database roles: lobbystack_app, lobbystack_auth, lobbystack_worker or lobbystack_dispatcher. Tenant queries run inside withBusinessTransaction, which sets the business for row-level security before your query runs, so the policies limit the query to that business’s rows. Redis runs the BullMQ job queues, rate limits and realtime updates. S3-compatible storage holds recordings and uploaded documents, and a local directory stands in for it during development. Side effects that must survive a crash go into a PostgreSQL outbox in the same transaction as the change, and the worker dispatches them.

One agent for every channel

createConversationAgent in packages/agent-core builds an AI SDK ToolLoopAgent for one conversation. Each channel calls it from its own runtime: agentCapabilities in packages/agent-core/src/capabilities.ts decides which tools a conversation gets, from the business’s settings and the channel. A browser call has no trusted caller number, for example, so it gets no tool that cancels an appointment. The agent’s instructions and GPT-Live’s instructions both read that one decision, so GPT-Live offers callers only what the agent can do. The agent starts from a business snapshot: the business’s hours, closures, services, employees, rules and common answers, compiled ahead of time and cached. A call reads it once when it starts, instead of querying the database on each turn. ADR 0004 records that decision.

How a phone call runs

OpenAI hosts the call audio, so LobbyStack never relays it. The admin starts the call and the worker runs it:
1

The carrier sends the call to OpenAI

A Twilio Elastic SIP trunk or a Telnyx FQDN connection sends the call to your OpenAI project’s SIP address.
2

The admin accepts it

OpenAI sends a live.transport.incoming webhook to /api/webhooks/openai/live. The admin finds the business from the dialled number, records the call, reserves minutes from its plan, and accepts the session with the agent’s voice and instructions.
3

The worker attaches

The admin asks the worker to attach. The worker opens a sideband WebSocket to the session and has GPT-Live greet the caller.
4

GPT-Live delegates what needs business data

GPT-Live answers from the snapshot it got at the start, such as the opening hours. It delegates the rest, such as a booking. The worker answers each request with the agent core, whose tools call packages/domain.
5

The worker finishes the call

After the call, the worker saves the transcript, the summary and the call’s outcome.
A browser call sends its WebRTC offer to /api/voice/live/session. The admin creates the GPT-Live session, returns OpenAI’s answer to the browser, and asks the worker to attach, as on a phone call. The voice runtime notes cover transfers, keypad PINs, greetings and calls the agent can’t take.

Models the agent runs on

Voice runs on OpenAI GPT-Live, which terminates the SIP and WebRTC connections. LobbyStack doesn’t support other voice models yet. ADR 0008 explains the choice. The agent core runs on any OpenAI-compatible endpoint. Three sets of variables choose its models: Endpoints other than OpenAI’s use chat completions. The environment variables reference describes each variable.

How partners fit in

A partner resells LobbyStack under its own brand, and each business belongs to the host or to one partner. The admin picks the partner’s brand from the hostname of each request. Partners sell packages to their businesses through their own Stripe accounts with Stripe Connect, and the host can sell partners tiers through Polar. The partner architecture notes define the modules, and Run white label on your own servers turns each part on.

Where to change what

Most changes belong in one package. Start from the job you want to do: