Skip to content

feat(whatsapp): send images and voice notes via bridge /send-media - #32947

Closed
jlugo63 wants to merge 1 commit into
NousResearch:mainfrom
jlugo63:feat/whatsapp-media-send
Closed

feat(whatsapp): send images and voice notes via bridge /send-media#32947
jlugo63 wants to merge 1 commit into
NousResearch:mainfrom
jlugo63:feat/whatsapp-media-send

Conversation

@jlugo63

@jlugo63 jlugo63 commented May 27, 2026

Copy link
Copy Markdown

What & why

send_message can deliver media (images, voice notes, documents) on telegram, discord, matrix, weixin, signal, yuanbao, and feishu — but WhatsApp was the only phone platform left out. Its standalone sender _send_whatsapp only POSTed to the bridge's /send (text-only) endpoint, so any MEDIA attachments fell through to the "MEDIA attachments were omitted" warning and were silently dropped.

The Baileys bridge already exposes POST /send-media ({ chatId, filePath, mediaType?, caption?, fileName? }) — the same endpoint the in-gateway WhatsAppAdapter uses. This PR wires the standalone tool path to it, closing the gap.

What changed

  • _send_to_platform — route Platform.WHATSAPP + media_files through _send_whatsapp, matching the existing yuanbao/feishu chunking pattern.
  • _send_whatsapp(..., media_files=None) — each (path, is_voice) entry is POSTed to /send-media:
    • the message text rides as the caption of the first attachment so text + media stay grouped in one conversation;
    • is_voice entries set mediaType=audio so the bridge renders a native voice bubble (ptt);
    • missing files and non-200 responses surface as errors; text-only sends are unchanged (still POST /send).
  • Added whatsapp to the two supported-platforms messages.
  • Added tests/tools/test_whatsapp_media.py.

How to test

Unit (bridge mocked):

scripts/run_tests.sh tests/tools/test_whatsapp_media.py

Covers: text-only routing to /send, image+caption, voice (mediaType=audio), caption-only-on-first-attachment, missing file, and bridge HTTP error.

Manual: with a WhatsApp gateway + bridge running, call send_message with a MEDIA attachment — it now delivers natively (image with caption / voice as a ptt bubble) instead of dropping it with a warning.

Platforms tested

Linux (WSL2, Ubuntu 24.04), Python 3.11, against a live Baileys bridge.

Related

WhatsApp was the lone gap in the send_message media-support list; this brings it to parity with the other media-capable platforms.

WhatsApp was the only phone platform whose send_message media attachments
were silently dropped: _send_whatsapp only hit POST /send (text-only), so
images and voice notes fell through to the "media omitted" warning. The
Baileys bridge already exposes POST /send-media (the same endpoint the
in-gateway WhatsAppAdapter uses), so wire the standalone tool path to it.

- Route Platform.WHATSAPP + media_files through _send_whatsapp, matching the
  existing yuanbao/feishu chunking pattern in _send_to_platform.
- _send_whatsapp POSTs each attachment to /send-media: the message text rides
  as the caption of the first attachment so text + media stay grouped in one
  conversation, and is_voice entries set mediaType=audio so the bridge renders
  a native voice bubble (ptt). Missing files and non-200 responses surface as
  errors; text-only sends are unchanged.
- Add whatsapp to the supported-platforms messages.
- Add tests/tools/test_whatsapp_media.py: text-only routing, image+caption,
  voice (mediaType=audio), caption-only-on-first-attachment, missing file,
  and bridge HTTP error.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists platform/whatsapp WhatsApp Business adapter comp/gateway Gateway runner, session dispatch, delivery labels May 27, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Closing in favor of #53598 (merged: cd592c1), which adds native WhatsApp media delivery for send_message via the Baileys bridge /send-media endpoint — images/videos/voice arrive as native bubbles. Your PR targeted the same area and you're credited in the merged PR body. Thanks!

@teknium1 teknium1 closed this Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/whatsapp WhatsApp Business adapter type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants