Skip to content

feat(dingtalk): support incoming audio messages via SDK extensions - #24861

Closed
zh-xl-kang wants to merge 1 commit into
NousResearch:mainfrom
zh-xl-kang:feat/dingtalk-audio-support
Closed

feat(dingtalk): support incoming audio messages via SDK extensions#24861
zh-xl-kang wants to merge 1 commit into
NousResearch:mainfrom
zh-xl-kang:feat/dingtalk-audio-support

Conversation

@zh-xl-kang

Copy link
Copy Markdown

Summary

DingTalk official API sends voice messages via Stream Mode as msgtype: audio with a recognition field containing server-side ASR text. The dingtalk-stream SDK only parses text/picture/richText into typed attributes; audio content lands in message.extensions as raw dict.

This PR adds handling for msgtype: audio in the DingTalk adapter.

Changes

  • _extract_text: read recognition from extensions['content'] for audio messages, with two fallback paths and a placeholder when ASR unavailable
  • _extract_media: set MessageType.AUDIO without adding raw downloadCode to media_urls (STT pipeline expects local paths)
  • _IncomingHandler: INFO log for raw msgtype of every Stream callback

Testing

Verified with real DingTalk single-chat bot traffic against dingtalk-stream SDK v0.24.3. Voice messages with recognition are correctly extracted as text; messages without use a placeholder to avoid silent drops.

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/dingtalk DingTalk adapter labels May 13, 2026
@zh-xl-kang
zh-xl-kang force-pushed the feat/dingtalk-audio-support branch 2 times, most recently from 5fed206 to e3bdcc1 Compare May 13, 2026 07:15
DingTalk's official API sends voice messages as msgtype=audio with
a recognition field containing server-side ASR text. However, the
dingtalk-stream SDK (v0.24.3) only parses text/picture/richText
msgtypes into typed attributes; audio/video/file content lands in
message.extensions as a raw dict.

Changes:
- _extract_text: read recognition from extensions['content'] for
  audio messages, falling back to a placeholder when ASR is unavailable
- _extract_media: set MessageType.AUDIO without adding raw downloadCode
  to media_urls (the STT pipeline expects local file paths, not
  DingTalk download codes)

Verified against dingtalk-stream SDK v0.24.3 with real single-chat
(单聊) bot traffic.
@zh-xl-kang
zh-xl-kang force-pushed the feat/dingtalk-audio-support branch from e3bdcc1 to cd5ca4a Compare May 13, 2026 07:21
@zh-xl-kang

Copy link
Copy Markdown
Author

Gentle bump on this one — it's a clean +31/-0 addition to handle DingTalk voice messages (msgtype: audio) which the current stream SDK drops silently. The ASR recognition text gets extracted with two fallback paths. Tested against real DingTalk bot traffic. Would appreciate a review, thanks!

@zh-xl-kang

Copy link
Copy Markdown
Author

Closing in favor of #49546 — same feature (DingTalk audio ASR extraction) with a cleaner fix that handles both SDK recognition paths and the edge case where content is nested in extensions dict. That PR is the corrected version of this one.

@zh-xl-kang zh-xl-kang closed this Jun 22, 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/dingtalk DingTalk adapter type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants