Skip to content

DingTalk Setup

The DingTalk adapter connects EdgeCrab to DingTalk via the DingTalk Open Platform v2 API. It uses a stream connection for receiving messages and REST for replies.


  1. A DingTalk developer account at open.dingtalk.com
  2. A registered DingTalk app with Robot permissions
  3. AppKey and AppSecret from your app credentials

VariableRequiredDescription
DINGTALK_APP_KEYYesDingTalk app AppKey
DINGTALK_APP_SECRETYesDingTalk app AppSecret
DINGTALK_ROBOT_CODENoRobot code if using multiple robots
DINGTALK_WEBHOOK_PORTNoWebhook port (default auto-assigned)

  1. Go to open.dingtalk.comApplication Development
  2. Create a new Internal Enterprise Application
  3. Navigate to Credentials and basic info — copy AppKey and AppSecret
  4. Under Capabilities, enable Robot
  5. Configure the robot name and icon
~/.edgecrab/.env
DINGTALK_APP_KEY=dingxxxxxxxxxxxxxxxx
DINGTALK_APP_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Terminal window
edgecrab gateway start

The adapter uses the DingTalk Stream SDK to receive messages without requiring a public webhook endpoint.


  1. In DingTalk, search for your robot by name and add it to a group or send a direct message
  2. In a group: @EdgeCrab your question here
  3. In a direct message: just type your message

Gateway slash commands (send as DingTalk messages):

CommandEffect
/helpList all available gateway commands
/newStart a fresh conversation (clears history)
/resetAlias for /new
/stopCancel the currently running agent response
/retryRe-send your last message
/statusShow whether the agent is running or idle
/usageShow session stats
/hooksList loaded event hooks

  • DingTalk supports both group and direct message conversations
  • Group messages require @mentioning the bot; DM messages do not
  • The adapter auto-reconnects on disconnection with exponential backoff
  • Max message length: 6,000 characters (auto-chunked for longer responses)

  • Stream SDK vs. public webhook: The DingTalk Stream SDK used here doesn’t need a public URL — it maintains an outbound stream connection. This makes it safe to run behind NAT/firewalls.
  • AppKey freshness: DingTalk app credentials expire after inactivity in some configurations. If the bot stops responding after weeks, regenerate credentials in the DingTalk Open Platform console.
  • Group vs. DM sessions: Group chats and DM chats are separate sessions. DM EdgeCrab for private experiments, use a group channel for team-shared tasks.
  • Enterprise deployment: Use Internal Enterprise Applications (not ISV apps) for self-hosted use. Internal apps don’t require public marketplace review.

Bot not visible in DingTalk search:
Publish the robot from the Open Platform console. Internal robots must be published even for internal use before they appear in search.

Messages arrive but bot doesn’t respond:
Verify DINGTALK_APP_KEY and DINGTALK_APP_SECRET match the Credentials and basic info page exactly. No extra spaces or newlines.

Stream connection keeps dropping:

Terminal window
RUST_LOG=debug edgecrab gateway start
# Look for [dingtalk] connection/reconnect log lines

Exponential backoff means reconnects start at 1s and increase. Normal behavior on flaky networks.


Q: Does EdgeCrab support DingTalk Mini Programs or Intelligent Workbench?
Not currently. The adapter uses the Robot/Stream API for conversational messages only.

Q: Can I use this with DingTalk’s international version?
Yes — DingTalk international (dingtalk.com) and the China version use the same Open Platform API. The Stream SDK connects to the same endpoint regardless of region.

Q: How do I restrict which DingTalk users can chat with EdgeCrab?
Use DINGTALK_ALLOWED_USERS (comma-separated DingTalk user IDs). Find user IDs in the DingTalk admin console under Address Book → Member Management.

Q: Does EdgeCrab support DingTalk message cards (JSON templates)?
Not currently — EdgeCrab sends plain text responses. Rich card support is planned.