DingTalk
Connect your GolemBot assistant to DingTalk using Stream mode (WebSocket). No public IP required.
Prerequisites
bash
pnpm add dingtalk-streamDingTalk Open Platform Setup
- Go to DingTalk Developer Portal and create a robot application
- Under Credentials, copy the Client ID (AppKey) and Client Secret (AppSecret)
- Under Message Push, select Stream mode
- Configure the bot's permissions as needed
Configuration
yaml
# golem.yaml
channels:
dingtalk:
clientId: ${DINGTALK_CLIENT_ID}
clientSecret: ${DINGTALK_CLIENT_SECRET}sh
# .env
DINGTALK_CLIENT_ID=dingxxxxxxxxxx
DINGTALK_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxHow It Works
- Transport: Stream mode via
DWClientfromdingtalk-stream, using theTOPIC_ROBOTtopic - Events: Receives robot messages via the stream connection
- Reply: Posts response to
data.sessionWebhookwithx-acs-dingtalk-access-tokenheader - Chat types: Supports both DMs and group chats
Start
bash
golembot gateway --verboseThe adapter connects to DingTalk's stream service on startup. Messages appear with [dingtalk] prefix when --verbose is enabled.
Group Chat
DingTalk server groups are treated as group chats. Configure the response policy via groupChat in golem.yaml:
yaml
groupChat:
groupPolicy: mention-only # recommended for DingTalkPlatform Limitation
DingTalk's Stream SDK (TOPIC_ROBOT) only delivers messages where the bot is @mentioned. Non-mention group messages are never sent to the bot process. This means:
mention-only— works as expectedsmart— cannot observe non-mention messages for group context accumulationalways— behaves the same asmention-only(platform-side filtering)
For best results, use mention-only with DingTalk.
Notes
- Stream mode uses outbound WebSocket — works behind NAT/firewalls
- Replies are sent to the session webhook URL provided in each incoming message
- The max message length is 4,000 characters; longer responses are automatically split