Skip to content

feat(gateway/dingtalk): rich media (image, voice, video, file) support In&Outbound#9451

Open
dingtalkwukong wants to merge 4 commits into
NousResearch:mainfrom
dingtalkwukong:main
Open

feat(gateway/dingtalk): rich media (image, voice, video, file) support In&Outbound#9451
dingtalkwukong wants to merge 4 commits into
NousResearch:mainfrom
dingtalkwukong:main

Conversation

@dingtalkwukong

Copy link
Copy Markdown

Motivation

Sync the DingTalk gateway implementation with the upstream connector to add robust rich media handling for inbound and outbound messages.
Provide native robot OpenAPI paths for sending images, voice, video and files and ensure inbound media is downloaded, cached and exposed to the agent.
Add comprehensive unit tests to cover media workflows, routing, and edge cases.

Description

Replaced gateway/platforms/dingtalk.py with an upstream implementation that adds inbound media download/caching (images, audio, video, files), outbound media upload and native robot media senders, session context capture, access token caching and OpenAPI interactions.
Introduced parsing and helper utilities (_rich_text_items, download_inbound*, _send_robot_media_message, _upload_media, context merging, robot identity resolution, logging/redaction helpers, etc.) to reliably handle multiple message shapes and rich-text items.
Replaced tests/gateway/test_dingtalk.py with the upstream test suite expanded to exercise the new media flows, session/context behaviors, token refresh and error cases.
Kept send/markdown reply behavior and added guard rails for webhook/session validation and local path validation for outbound media.

What does this PR do?

gateway/dingtalk feat:
Outbound rich media (image, voice, video, file) sent via DingTalk Robot OpenAPI.
Inbound media (image, audio, file) downloaded and cached for agent consumption.

dingtalkwukong and others added 3 commits April 14, 2026 04:06
…, video, file) support

Sync DingTalk gateway platform and tests from dingtalk-hermes-connector main branch.

This update replaces gateway/platforms/dingtalk.py and tests/gateway/test_dingtalk.py with upstream implementations.

Highlights include expanded inbound parsing and outbound sending paths for rich media message types, plus comprehensive test coverage updates for media workflows and platform behaviors.
… handler

Add _IncomingHandler.raw_process compatibility path expected by DingTalk callback flows and tests.

Normalize callback payload fields into ChatbotMessage-like attributes when SDK objects are unavailable, preserve _raw_data, and return a fallback ACK object with code/headers.
@dingtalkwukong

Copy link
Copy Markdown
Author

Your AI can now access all dingtalk api docs here: https://github.com/dingtalkwukong/dingtalk-openapi-docs-markdown

@dingtalkwukong

Copy link
Copy Markdown
Author

You can paste this to your hermes agent:
Use the patched DingTalk adapter here: https://raw.githubusercontent.com/dingtalkwukong/dingtalk-hermes-connector/main/gateway/platforms/dingtalk.py

Replace ~/.hermes/hermes-agent/gateway/platforms/dingtalk.py with this file and restart hermes gateway to make DingTalk messaging work normally.

DingTalk platform adapter for hermes Supports:

Outbound rich media (image, voice, video, file) sent via DingTalk Robot OpenAPI.
Inbound media (image, audio, file) downloaded and cached for agent consumption.

@OpenClawGuard

Copy link
Copy Markdown

Note — PR Comments Suggest Replacing Local Files from External Repository

The PR code itself adds DingTalk rich media support and appears clean — all URLs point to official DingTalk APIs (api.dingtalk.com, oapi.dingtalk.com), with no eval/exec, subprocess calls, or suspicious outbound requests found in the patch. The external repository (dingtalkwukong/dingtalk-hermes-connector) was also reviewed and no malicious code was found in its current version.

However, the PR comments suggest a workaround that bypasses the normal review process:

1. Comment posted shortly after PR creation:

"Use the patched DingTalk adapter here: https://raw.githubusercontent.com/dingtalkwukong/dingtalk-hermes-connector/main/gateway/platforms/dingtalk.py
Replace ~/.hermes/hermes-agent/gateway/platforms/dingtalk.py with this file and restart hermes gateway"

This is likely the author trying to help users who need the feature before the PR is merged — a common pattern in open-source. However, it would be better practice to suggest checking out the PR branch directly rather than raw-file replacement, since:

  • The raw URL points to main, which can change at any time without review
  • The external file's SHA does not currently match the PR's head, so users aren't getting the exact reviewed code
  • Direct file replacement in ~/.hermes/ bypasses version tracking

@dingtalkwukong — consider updating your comment to suggest users check out your branch directly instead of raw file replacement. This way users get the exact code that's in the PR and can track updates.

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.

3 participants