Skip to content

feat(whatsapp): voice-note transcription — extend the transcription branch beyond Telegram (#468 item 3d) #1933

Open

Description

@vybe

Summary

WhatsApp voice notes reach the agent as an audio file, never as text. Transcription is gated to Telegram by an explicit channel check in the message router, so a WhatsApp user who sends a voice message gets an agent that cannot read it. This pulls item 3d out of the #468 umbrella into a standalone, pickable issue.

Context

src/backend/adapters/message_router.py (~line 936):

async def _maybe_transcribe_voice(...):
    """Step 2b: transcribe a Telegram voice note in place."""
    if channel != "telegram":
        return message

Two things changed since 3d was written as a speculative bullet inside an umbrella framed as "ship only if demand appears":

  1. Demand appeared. A live deployment received WhatsApp voice notes from a real user and had to reply that it couldn't hear them.
  2. The channel is asymmetric. Outbound voice on WhatsApp already exists — an agent can deliver its reply as a playable voice note. Inbound is the remaining gap: the agent can speak but not listen.

Two details in the #468 3d bullet are stale and worth correcting when this is picked up: it specifies the Whisper API, but transcription moved to Gemini (_transcribe_audio_gemini, model pinned via GEMINI_TRANSCRIPTION_MODEL after #1130); and it cites message_router.py:212, while the branch now lives at ~936.

Hard dependency: WhatsApp media download is currently broken (#1932) — the SSRF allowlist refuses Twilio's media CDN, so download_file returns None for every attachment. Transcription cannot be built or tested until that lands.

Acceptance Criteria

  • A WhatsApp voice note is transcribed and the transcript replaces the media placeholder in the agent's prompt, matching Telegram's behavior
  • The transcription branch becomes channel-generic rather than gaining a second hardcoded channel name — the guard keys on "this message carries a voice attachment this adapter can fetch", not on a channel string
  • Reuses the shared _transcribe_audio_gemini(bytes, mime_type) helper — no WhatsApp-specific transcription implementation
  • Audio is fetched through the existing SSRF-gated WhatsAppAdapter.download_file — no new fetch path
  • Graceful fallback: on download failure, transcription failure, or unsupported MIME type, the agent still receives the message with an honest placeholder naming what failed — never a silent drop
  • When transcription is unavailable (no Gemini key configured), the user-visible result is a clear placeholder, not an error
  • Oversized or long audio has a defined ceiling with a documented fallback rather than an unbounded API call
  • Unit tests for the WhatsApp voice path: happy path, download failure, transcription failure, unsupported MIME
  • docs/memory/feature-flows/whatsapp-integration.md updated; feat(whatsapp): Phase 3 advanced features — templates, SMS, interactive, voice (WHATSAPP-001 Phase 3, #299 follow-up) #468 item 3d checked off

Technical Notes

  • Guard: src/backend/adapters/message_router.py — _maybe_transcribe_voice (~936), called from ~406 (verified on dev)
  • Transcription helper: src/backend/services/telegram_media.py — _transcribe_audio_gemini (~220) is MIME-agnostic and takes raw bytes. WhatsApp voice notes arrive as audio/ogg, the same MIME Telegram sends, so the helper should work unchanged
  • process_voice (~172) is not reusable as-is — it downloads through the Telegram Bot API. Either extract its transcribe-and-format tail into a channel-neutral helper or call _transcribe_audio_gemini directly from the WhatsApp path
  • Inbound shapes differ: Telegram's is raw_msg["voice"], WhatsApp's is a FileAttachment parsed from MediaUrl{N}. The generic seam is NormalizedMessage.files filtered by audio MIME
  • Once a second channel uses it, consider whether the transcription helper still belongs in telegram_media.py
  • A channel-generic guard would make Slack voice clips near-free — worth noting, not in scope here

Related

Activity

  1. added
    priority-p2
    type-feature
    theme-channels
    complexity-low
    status-ready
    on Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-lowpriority-p2status-readytheme-channelstype-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions