feat(whatsapp): send images and voice notes via bridge /send-media - #32947
Closed
jlugo63 wants to merge 1 commit into
Closed
feat(whatsapp): send images and voice notes via bridge /send-media#32947jlugo63 wants to merge 1 commit into
jlugo63 wants to merge 1 commit into
Conversation
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>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
send_messagecan 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_whatsapponly 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-gatewayWhatsAppAdapteruses. This PR wires the standalone tool path to it, closing the gap.What changed
_send_to_platform— routePlatform.WHATSAPP+media_filesthrough_send_whatsapp, matching the existing yuanbao/feishu chunking pattern._send_whatsapp(..., media_files=None)— each(path, is_voice)entry is POSTed to/send-media:captionof the first attachment so text + media stay grouped in one conversation;is_voiceentries setmediaType=audioso the bridge renders a native voice bubble (ptt);POST /send).whatsappto the two supported-platforms messages.tests/tools/test_whatsapp_media.py.How to test
Unit (bridge mocked):
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_messagewith 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_messagemedia-support list; this brings it to parity with the other media-capable platforms.