Bridge Server Architecture & Session Management
Build a server that sits between MeetStream and your AI stack. The bridge receives real-time meeting audio, manages one session per MeetStream connection, routes audio through your processing pipeline, and sends responses (audio, chat, images) back into the meeting.
This is track 2 in Build tracks: an agent in the meeting on your own stack. Any speech-to-text, LLM and text-to-speech works, hosted or local. For free local options (for example whisper.cpp or Parakeet, Ollama, Piper or Kokoro), see Models that are free to run locally. You pay the bot price only: MeetStream charges no agent infrastructure and no model tokens. For a ready-made starting point, see the open-source meetstream-ai/meetstream-agent bridge.
Architecture

The bridge server exposes two WebSocket endpoints. Each MeetStream connection opens one to each:
Each MeetStream connection is identified by a bot_id. The session manager maintains one AI session per bot_id, created on first connection and torn down when both WebSockets disconnect.
Session Lifecycle

Key rules:
- Either channel can arrive first. The session is created on whichever connects first.
- Both channels share the same
bot_idand the same AI session. - Cleanup happens when both WebSockets have disconnected for a given
bot_id.
Core Components
1. Session Manager
The session manager is the central coordinator. It maps bot_id to:
- An AI session (your STT/LLM/TTS pipeline)
- References to the audio and control WebSockets
- Per-session locks to prevent race conditions during creation
2. Audio Decoder
Decodes the binary frame format from MeetStream. See Live Audio Capture & Frame Decoding for the full specification.
Frames come in two types. 0x01 frames are 48 kHz mono. 0x04 frames carry the sample rate and the channel count in the header. Zoom sends 0x04 frames. Google Meet sends both types in the same call: in live calls the bot sent one 0x01 frame and then only 0x04 frames. Choose the layout from byte 0 of each frame, never from the platform. The decoder returns the sample rate with the audio.
3. Audio Resampler
0x01 frames arrive at 48 kHz. 0x04 frames (Zoom and Google Meet) arrive at the rate in the frame header (Zoom: 32 kHz). Do not assume 48 kHz for a Google Meet call. Resample to the rate of your model before you send audio to it (for example, 24 kHz for OpenAI Realtime or 16 kHz for Whisper), and resample back to 48 kHz before you send audio to the meeting.
4. Speaker Filter
Filter out MeetStream’s own audio to prevent echo/feedback loops. The display name appears in the speaker_name field.
A name filter is not sufficient on Google Meet. The mixed Google Meet stream can be tagged "NoSpeaker", so the bot’s own voice does not always carry the bot’s name. Also ignore or gate incoming audio while your bot is speaking.
5. Command Sender
Helper functions to build outbound commands for the control channel. See Meeting Control & Command Patterns for the full command reference.
On Zoom and Teams, send resume_audio after an interrupt. Google Meet ignores resume_audio, so you can send it on all platforms.
WebSocket Endpoints
Audio Endpoint: /bridge/audio
Receives binary audio frames from the meeting. Decodes speaker metadata, filters out MeetStream’s own audio, and routes PCM to your AI pipeline.
Control Endpoint: /bridge
Your AI pipeline sends commands (sendaudio, sendmsg, interrupt, resume_audio) over this connection. MeetStream sends the ready handshake and command acknowledgements.
Event Pump
The event pump is a background task that continuously reads output from your AI pipeline and forwards it to the meeting through the control WebSocket. This is the outbound half of the bridge.
Note: The event types above (
audio,audio_interrupted,text_response) are illustrative. Replace them with whatever events your AI framework emits. Keep theresume_audiostep: on Zoom and Teams, sendresume_audioafter aninterrupt. Google Meet ignoresresume_audio, so you can send it on all platforms.
Full Working Skeleton
A minimal but complete bridge server. Replace the YourAISession class with your actual AI pipeline.
Run:
Connecting MeetStream
When creating a MeetStream session, point both WebSocket URLs at your bridge server:
Both connections carry the same bot_id in their handshake, so the session manager can link them together.
Design Decisions
Why two separate WebSocket connections?
Separation of concerns. The audio channel is high-throughput binary data (hundreds of frames per minute). The control channel is low-frequency JSON commands. Splitting them avoids head-of-line blocking and makes it easier to handle each independently.
Why does the decoder check byte 0?
0x01 frames are 48 kHz mono. 0x04 frames carry the sample rate in the header. Zoom sends 0x04 frames, and Google Meet sends both types in the same call. Reading byte 0 of every frame lets one decoder handle every platform and skip frame types that it does not know.
Why lock on session creation?
Both WebSocket connections race to ensure_session(). Without a lock, two AI sessions could be created for the same bot_id. The async lock ensures exactly one session is created.
Why clean up only when both connections close?
A single reconnecting WebSocket shouldn’t destroy the running session. The session stays alive as long as at least one channel is connected.
Why resample instead of sending at the model's native rate?
Meeting audio arrives at 48 kHz in 0x01 frames and at the header rate in 0x04 frames (32 kHz from Zoom; Google Meet also sends 0x04 frames). Your model can need 16 kHz or 24 kHz. Send audio back to the meeting at 48 kHz. The bridge handles both conversions, so neither MeetStream nor your model needs to know about the other’s sample rate.
Related Documentation
- Live Audio Capture & Frame Decoding: binary frame formats (
0x01and0x04), decode examples in 4 languages, FAQ - Meeting Control & Command Patterns: full command reference for
sendaudio,sendmsg,interrupt,resume_audio,sendimg,sendimg_url
