agentscope-extensions-channel-dingtalk connects your Agent to DingTalk (钉钉). It supports two reception modes: Stream (default) — a persistent WebSocket that receives bot messages in real time without exposing a public webhook endpoint — and HTTP callback — DingTalk POSTs each message to your Spring application, signed with your App Secret.
When to use
- Your Agent needs to respond to DingTalk bot messages (DM and group @-mentions).
- Prefer the WebSocket push model (Stream, default): no public endpoint, no ingress configuration.
- Prefer HTTP callbacks: your application already exposes public callback endpoints, or robots/credentials change at runtime (multi-tenant deployments) and you want a single stateless ingress instead of a pool of WebSocket connections.
Add the dependency
Prerequisites
- Create an Enterprise Internal App in the DingTalk Developer Console.
- Enable the Bot capability and subscribe to the bot-messages topic.
- Note down the App Key, App Secret, and Robot Code.
- For HTTP callback mode: configure the robot’s message reception to HTTP mode with the callback URL
https://your-host/api/channels/dingtalk/{channelId}/callback, and note down the aes_key if you enable body encryption.
Quickstart
DingTalkCallbackController is picked up by component scan):
Configuration properties
Note: For internet-facinghttpcallbacks, enabling message encryption (aesKey) is recommended: the request signature authenticates only thetimestampheader, so without encryption a captured signature pair remains replayable within the freshness window.
Message flow
Inbound (Stream): TheDingTalkStreamClient opens a WebSocket to the DingTalk gateway, receives bot-message callbacks, ACKs each frame, then dispatches through DingTalkInboundMapper → idempotency check → bot-loop guard → Gateway.
Inbound (HTTP callback): DingTalk POSTs each bot message to DingTalkCallbackController with timestamp/sign headers. The controller verifies the HMAC-SHA256 signature (rejecting stale timestamps), decrypts the encrypt envelope when an aesKey is configured, then hands the payload to the same dedup → mapping → bot-loop guard → Gateway pipeline. Replies are delivered through the outbound API, not the HTTP response.
Outbound: Replies are sent via DingTalkOutboundClient using the OpenAPI batchSend endpoints — oToMessages/batchSend for DMs and groupMessages/send for groups. Text and Markdown formats are auto-detected.