Skip to content

Add outbound Weixin native voice-message support#9

Open
cgf120 wants to merge 1 commit into
Tencent:mainfrom
cgf120:feat/weixin-voice-outbound
Open

Add outbound Weixin native voice-message support#9
cgf120 wants to merge 1 commit into
Tencent:mainfrom
cgf120:feat/weixin-voice-outbound

Conversation

@cgf120
Copy link
Copy Markdown

@cgf120 cgf120 commented Mar 31, 2026

Summary

This PR adds outbound native Weixin voice-message support.

The protocol layer already defines:

  • UploadMediaType.VOICE = 4
  • MessageItemType.VOICE = 3
  • VoiceItem with voice-specific metadata

The README also documents voice_item / SILK-based voice messages.

However, the current outbound implementation only exposes:

  • text
  • image
  • video
  • file

Audio files are currently routed through the generic file path instead of being sent as native Weixin voice messages.

What changed

  • Added uploadVoiceToWeixin() using UploadMediaType.VOICE
  • Added sendVoiceMessageWeixin() to emit MessageItemType.VOICE
  • Updated send-media.ts so supported audio files are routed to the voice path instead of always falling back to file attachments
  • Preserved file fallback for unsupported audio formats

Notes

  • The current implementation routes:
    • .silkencode_type = 6
    • .mp3 / audio/mpegencode_type = 7
    • .ogg / audio/oggencode_type = 8
  • Unsupported audio formats still fall back to file attachment delivery
  • This keeps the existing behavior safe while enabling native voice delivery for supported formats

Why

The protocol and public docs already indicate native voice-message capability, but the outbound implementation was missing the final send/upload path for VOICE.

This PR completes that missing path so outbound behavior matches the documented message schema.

@cgf120
Copy link
Copy Markdown
Author

cgf120 commented Apr 13, 2026

@pumpkinxing1 HI

@victorhuoxu
Copy link
Copy Markdown

Hi! This PR is exactly what our family needs.

We use OpenClaw's DD Agent (an AI companion for our 9-year-old son) through the WeChat channel. TTS voice replies currently arrive as file attachments, which is confusing for a child — he has to tap, open, and play a file instead of just pressing a native voice bubble like he does with family voice messages.

The native voice message experience (语音条) is critical for kids — it's the interaction pattern they already understand from WeChat daily use.

Is there anything we can help with to get this reviewed and merged? Happy to test on our setup if needed.

Thanks for the great work!

@zhongruan0522
Copy link
Copy Markdown

Hi, thanks for the PR.

I’m interested in understanding how the native voice-message support was validated here. Was this tested end-to-end with a real Weixin client, or is the implementation mainly based on inference from the existing protocol definitions?

I also did some experiments based on the 1.x documentation before. Although the voice media type is defined as 4, I wasn’t able to successfully send a native Weixin voice message in practice. From the PR, I also don’t see concrete test evidence such as screenshots, logs, or examples showing that the message is actually rendered as a native voice bubble instead of a regular file attachment.

Would you mind sharing how you verified this behavior?

@victorhuoxu
Copy link
Copy Markdown

@zhongruan0522 Good point about real-world validation — I've experienced exactly this gap firsthand.

Our setup: OpenClaw DD Agent → WeChat channel → 9-year-old child. TTS voice replies currently come through as file attachments. A kid has to tap → open → play a file. Confusing. We actually had to switch back to text-only because of it, and now our son barely uses the bot.

A native voice bubble (语音条) that he can just press and listen to — same as family voice messages — would change everything.

I'm happy to:

  1. Build this PR branch and end-to-end test on a real WeChat client
  2. Share screenshots, logs, actual rendering results
  3. Report back with proof one way or the other

@cgf120 any guidance before I dive in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants