feat(dingtalk): proactive messaging via Robot OpenAPI#17370
Conversation
When no session_webhook is available (e.g. agent-initiated messages, expired webhook, or scheduler-triggered sends), fall back to DingTalk Robot OpenAPI for message delivery — the same pattern Feishu uses for proactive im.v1.message.create calls. Module-level additions: - _dingtalk_fetch_access_token() / _dingtalk_fetch_oapi_token() — dual token management (OAuth2 + legacy OAPI) with in-memory cache + expiry - _dingtalk_upload_media() — upload image/video/voice/file via /v1.0/robot/messageFiles/download with 20MB guard - _dingtalk_classify_chat_id() — route OTO vs group by sender_id format - _dingtalk_build_msg_param() — build sampleText/sampleMarkdown/ sampleImageMsg/sampleFile payloads with auto-format detection - dingtalk_send_proactive() — orchestrate token → classify → build → POST /v1.0/robot/oToMessages/batchSend or /v1.0/robot/groupMessages/send - _looks_like_markdown() — heuristic for markdown auto-detection Class-level changes: - Add self._robot_code to __init__ - send() now falls back to dingtalk_send_proactive() when no webhook Ported from dingtalk-openclaw-connector services/proactive-sender.ts. to #
|
Hi @alt-glitch, thanks for the careful review! 🙏 Correct — this extracts the proactive messaging feature from the original stacked #14336, rebased cleanly against Context: We're the DingTalk (钉钉) Open Platform team at Alibaba. @PeterGuy326 and @spike2204 are colleagues on the same team. Regarding #12077: Our implementation is more comprehensive and follows the same architectural pattern Hermes already uses for Feishu's proactive
This has been running in our production deployment handling proactive notifications, scheduled digests, and cross-platform message forwarding. We're happy to help reconcile with #12077 — our implementation likely subsumes its scope. Let us know if you'd like any changes! 🚀 |
|
@alt-glitch, hope this PR can be merged soon. Currently dingtalk is missing these features, making it inconvenient to use. If my PR #12077 is not modular enough, feel free to merge this PR directly. |
|
Hi guys, I built a CLI tool that sends messages directly to DingTalk (individual or group), with a plugin system so more platforms can be added later. |
Summary
When no session_webhook is available (e.g. agent-initiated messages, expired webhook, or scheduler-triggered sends), fall back to DingTalk Robot OpenAPI for message delivery — the same pattern Feishu uses for proactive
im.v1.message.createcalls.Changes
Module-level additions:
_dingtalk_fetch_access_token()/_dingtalk_fetch_oapi_token()— dual token management (OAuth2 + legacy OAPI) with in-memory cache + expiry_dingtalk_upload_media()— upload image/video/voice/file via /v1.0/robot/messageFiles/download with 20MB guard_dingtalk_classify_chat_id()— route OTO vs group by sender_id format_dingtalk_build_msg_param()— build sampleText/sampleMarkdown/sampleImageMsg/sampleFile payloads with auto-format detectiondingtalk_send_proactive()— orchestrate token → classify → build → POST_looks_like_markdown()— heuristic for markdown auto-detectionClass-level changes:
self._robot_codeto__init__send()now falls back todingtalk_send_proactive()when no webhookPorted from dingtalk-openclaw-connector
services/proactive-sender.ts.Related
Part of the DingTalk adapter enhancement series — see #12769 for the umbrella PR.