Skip to content

feat(whatsapp): add media send/receive support#2010

Closed
Zeknes wants to merge 8 commits intoHKUDS:mainfrom
Zeknes:feat/whatsapp-media
Closed

feat(whatsapp): add media send/receive support#2010
Zeknes wants to merge 8 commits intoHKUDS:mainfrom
Zeknes:feat/whatsapp-media

Conversation

@Zeknes
Copy link
Copy Markdown
Contributor

@Zeknes Zeknes commented Mar 14, 2026

🎯 Purpose

Add WhatsApp media send/receive support (images, audio, video, documents).

✨ Features

  • Receive media: Auto-download images, voice messages, videos, documents from WhatsApp
  • Send media: Unified sendMessage() API supporting text + media with caption
  • Media type detection: Auto-detect media type from file extension
  • Caption support: Extract caption from message content for image/video/document

🏗️ Architecture

  • Bridge (TypeScript): WhatsApp Client downloads media to local path, sends to Python via WebSocket
  • Channel (Python): Unified send() method, auto-detects media type
  • Design: Aligned with Feishu channel pattern (unified send method)

📝 Files Modified

File Changes
.gitignore + bridge/node_modules/
bridge/src/server.ts Unified send command interface
bridge/src/whatsapp.ts +downloadMedia for audio, +sendMessage with media support
nanobot/channels/whatsapp.py Unified send() + _detect_media_type()

✅ Testing

Tested all media types:

  • ✅ Image (PNG, JPG)
  • ✅ Audio (OGG voice messages)
  • ✅ Video (MP4)
  • ✅ Document (XAPK, large files)

Commit History (3 commits, rebased on latest upstream):

  • 8f84e27 test(whatsapp): media send/receive working
  • 862c3cb refactor(whatsapp): unify send() method for text and media
  • 570191f feat(whatsapp): add media send/receive support

Zeknes added 6 commits March 15, 2026 12:49
- Bridge: download voice messages (audioMessage)
- Bridge: add sendMedia() method for image/audio/video/document
- Python: parse media tags and send via WebSocket
- Server: handle send_media command

No message deduplication logic included.
- Merge sendMedia() into sendMessage() with optional parameters
- Simplify server.ts interface (remove send_media command)
- Python channel auto-detects media tags and sends unified payload
- Backward compatible: sendMedia() deprecated but still works

Design aligned with Feishu channel pattern.
- Verified all media types: image, audio, video, document
- Unified sendMessage() API working correctly
- Caption extraction from media tags functional
- Add react_emoji config option (optional, default null)
- Auto-send reaction when receiving messages (like Feishu bot)
- Bridge: handle send_reaction command
- WhatsApp Client: sendReaction() using Baileys API

Configuration:
  channels:
    whatsapp:
      react_emoji: "👍"  # Set emoji or null to disable
- Document reactEmoji option in WhatsApp configuration
- Show default value (👍) and how to disable (null)
- Add configuration options table for clarity
@Zeknes Zeknes force-pushed the feat/whatsapp-media branch from 7523727 to fd71fb8 Compare March 15, 2026 04:49
@Zeknes
Copy link
Copy Markdown
Contributor Author

Zeknes commented Mar 21, 2026

@Re-bin hello, I have been using these changes daily, works fine, ready for review, would appreciate any feedback

@Re-bin
Copy link
Copy Markdown
Collaborator

Re-bin commented Mar 21, 2026

I will check this soon ;) thanks!

@CharlesXu1124
Copy link
Copy Markdown

@Zeknes I would suggest removing the thumb-up react feature, as Whatsapp already has its receipt mechanism, this is especially the case for users who talk to their own number, and every other person who talks to you would also have their messages thumbed up including your own, which is quite some distraction

@Zeknes
Copy link
Copy Markdown
Contributor Author

Zeknes commented Mar 26, 2026

@Zeknes I would suggest removing the thumb-up react feature, as Whatsapp already has its receipt mechanism, this is especially the case for users who talk to their own number, and every other person who talks to you would also have their messages thumbed up including your own, which is quite some distraction

You can set it to "" to disable the feature, this should only work on bot count logged in on nanobot.

Resolved conflicts:
- bridge/src/server.ts: kept reaction support + added send_media command
- nanobot/channels/whatsapp.py: merged media sending, reactions, and group_policy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants