Skip to content

Wire Protocol

The bridge terminates two protocols: the StandIn media bridge’s worker protocol on one side, and the Deepgram Voice Agent WebSocket on the other. This page documents both. The StandIn side is identical to the sibling bridges - the implementations are interchangeable.

The StandIn media bridge opens one WebSocket per call to {path}/{callId} - the call id is the last path segment of the URL. The upgrade carries two headers:

HeaderValue
X-StandIn-TimestampUnix epoch milliseconds
X-StandIn-SignatureHMAC-SHA256(secret, "{timestampMs}.{callId}"), lowercase hex

The legacy header names X-OpenClawTeamsBridge-Timestamp / -Signature are still accepted (the bridge checks the new names first); StandIn sends both pairs during the transition.

Verification (401 on failure): the timestamp must be within the freshness window (HMAC_FRESHNESS_MS, default 60 s), the signature must match (constant-time compare), and the (callId, ts, sig) tuple must be single-use (a captured handshake cannot be replayed within the window). The bridge fails closed if the shared secret is unset. The call id is also cross-checked against the session.start body.

GuardValue
Max concurrent connections64 (MAX_CONNECTIONS)
Per-IP cap= total cap (MAX_CONNECTIONS_PER_IP)
Max inbound frame2 MB
Outbound backpressure cap1 MB (drops hot-path audio above it; control frames, one-shot images, and goodbye audio always pass)
Pre-start timeout10 s (PRE_START_TIMEOUT_MS) - drops a socket that never sends session.start
Worker idle timeout90 s (WORKER_IDLE_TIMEOUT_MS) - dead-peer detection: ends the call after 3 missed 30 s heartbeats, freeing the call id and the billed agent session
Duplicate call idrejected with 409 - no second billed agent session for one call

Audio on the StandIn wire is base64 PCM 16 kHz, 16-bit, mono; toward Deepgram it is the same linear16 at 16 kHz, sent as raw binary frames.

MessageFieldsBridge action
session.startcallId, threadId, caller{aadId?, displayName?, tenantId?}, recordingStatus?, direction?Open the Voice Agent session; after Welcome, send Settings (prompt with caller name/tenant/direction, linear16 @ 16k, models, greeting, functions). All caller fields are nullable and are defaulted, never sent as null.
audio.frameseq, timestampMs, payloadBase64, speakerName?Base64-decode, send as a raw binary frame. Buffered until the server acks SettingsApplied, then flushed oldest-first. In group calls, a changed speakerName becomes a rate-limited context note.
video.framesource (camera/screenshare), ts, width, height, mime, dataBase64, participantId?, participantName?Buffer the latest frame per source, in memory, for the on-demand look tool. Unknown sources are ignored.
participantscountContext note appended to the prompt via UpdatePrompt (“N humans on the call, stay quiet unless addressed”).
dtmfdigitContext note via UpdatePrompt (“the caller pressed {digit}”).
pingtsReply pong with the same ts.
recording.statusstatusGate what may be persisted (transcripts; and look frames when VISION_REQUIRES_RECORDING).
assistant.saytextGovernor goodbye: speak it (Aura TTS or the live agent), backstop teardown armed, then StandIn tears the call down.
session.endreasonClose the Voice Agent socket, tear down.
MessageFieldsMeaning
audio.frameseq, timestampMs, payloadBase64Agent audio for the Teams side (base64 of the raw binary Deepgram frame).
assistant.cancelturnIdBarge-in (or goodbye flush): flush queued playback on the Teams side. turnId is always 0 - the worker’s flush ignores the value.
expressionemotionAvatar emotion cue (from the agent’s express function).
display.imagedataBase64, mime, mode?, caption?, …Show an image on the bot’s video tile (from show_image). Never dropped under backpressure.
pongtsReply to a worker ping.
session.endreasonAsk StandIn to tear the call down (governor, agent end_call, or fatal error).

Endpoint: wss://agent.deepgram.com/v1/agent/converse (or the regional api.eu / api.au hosts), authenticated with Authorization: Token <api key>.

Voice Agent messageDirectionBridge behavior
WelcomeDG → bridgeGates the connect: Settings is only sent after it arrives.
Settingsbridge → DGSent once: audio.input/output pinned to linear16 @ 16 kHz (container: none), agent.listen/think/speak providers with language, prompt, optional greeting, optional think.endpoint (BYO LLM), and the functions list (built-ins + custom).
SettingsAppliedDG → bridgeThe server is ready for audio. The bridge flushes buffered caller speech; a 10 s ack timeout ends the call rather than leaving it silent.
binary audiobothCaller audio (bridge → DG) and agent audio (DG → bridge), raw linear16 @ 16 kHz - relayed verbatim.
UserStartedSpeakingDG → bridgeCaller barge-in: emit assistant.cancel, ghost-drop in-flight agent frames until AgentStartedSpeaking.
AgentStartedSpeakingDG → bridgeStop ghost-dropping (the deterministic-goodbye mute latch still wins).
FunctionCallRequestDG → bridgeClient-side tool calls (client_side true): dispatch to end_call / express / show_image / look or a registered custom tool. Server-side calls (with an endpoint) are Deepgram’s own and are ignored.
FunctionCallResponsebridge → DGThe tool result ({type, id, name, content}).
UpdatePromptbridge → DGLive context: caller context + a bounded rolling notes section (participants, DTMF, active speaker). The Voice Agent API has no non-interrupting context message, so context rides the prompt.
InjectAgentMessagebridge → DGThe goodbye fallback when no Aura TTS model is set - the live agent speaks the exact text.
ConversationTextDG → bridgeTranscripts, logged only when LOG_TRANSCRIPTS=true and Teams recording is active.
KeepAlivebridge → DGSent every 8 s so the session does not idle out during silence.
Error / Warning / InjectionRefusedDG → bridgeLogged; the call survives malformed or advisory frames.