Send DingTalk robot messages, supporting all DingTalk robot message types.
main:
push:
- stages:
- name: dingtalk-bot-msg
imports: https://xxx/envs.yaml
image: tencentcom/dingtalk-bot-msg:latest
settings:
content: "your message"
c_type: "text" # Supported: text, markdown, link, actionCard, multiActionCard, feedCard
secret: $SECRET
webhook: $WEBHOOK
at: "199xxxxxx" # Multiple numbers separated by semicolons (;)
isAtAll: false
debug: false # New: Enable debug mode
Example envs.yaml file:
WEBHOOK: xxx
SECRET: xxx
c_type: "text"
content: "Text message content"
c_type: "markdown"
content: "#### Markdown Title\n- Item 1\n- Item 2"
c_type: "link"
content: "Title|Message content|Image URL|Jump URL"
c_type: "actionCard"
content: "Title|Message content|Button orientation(0-vertical,1-horizontal)|Button title|Jump URL"
c_type: "multiActionCard"
content: "Title|Message content|Button orientation(0-vertical,1-horizontal)|Button1 title,Button1 URL|Button2 title,Button2 URL"
c_type: "feedCard"
content: "Title1,Jump URL1,Image URL1|Title2,Jump URL2,Image URL2"
content: Message content, format varies according to message type
c_type: Message type. Supported: text, markdown, link, actionCard, multiActionCard, feedCard
webhook: DingTalk robot WebHook [Need to create in DingTalk PC client].
Reference Documentation
secret: Secret key for security settings and signing. Optional (recommended).
Reference Documentation
at: People to be mentioned. Enter the mobile numbers of the people to be mentioned, separated by ";" for multiple.
isAtAll: Whether to mention everyone. Boolean value.
debug: Whether to enable debug mode. Boolean value, default is false. When enabled, it will display complete request and response information, including sensitive information.
The newly added debug mode can help users better troubleshoot issues during development and testing:
Features:
Usage:
debug: true parameter in configuration--debug true parameter in command lineUse Cases:
Security Tips:
This extended implementation covers all message types supported by DingTalk robots and provides clear documentation and test cases for users to easily use various message types.
Parameter Precise Matching:
text and markdown type messages contain PLUGIN_AT and PLUGIN_ISATALL parametersTherefore, the entry file entrypoint.sh has been optimized
Enhanced Readability:
Parameter Completeness:
Unified Format:
Error Prevention:
Debug Support:
This test script can now comprehensively verify the correctness of various message types while conforming to the specification requirements of the DingTalk robot API.
The current entrypoint.sh script has been optimized to conditionally pass parameters based on message type and support debug mode:
#!/bin/sh
# Basic parameters
ARGS="--content \"$PLUGIN_CONTENT\" \
--c_type \"$PLUGIN_C_TYPE\" \
--webhook \"$PLUGIN_WEBHOOK\""
# Add secret parameter (if exists)
if [ -n "$PLUGIN_SECRET" ]; then
ARGS="$ARGS --secret \"$PLUGIN_SECRET\""
fi
# Only text and markdown messages support @ functionality
case "$PLUGIN_C_TYPE" in
"text"|"markdown")
# Add at parameter (if exists)
if [ -n "$PLUGIN_AT" ]; then
ARGS="$ARGS --at \"$PLUGIN_AT\""
fi
# Add isAtAll parameter (default is false)
ARGS="$ARGS --isAtAll ${PLUGIN_ISATALL:-false}"
;;
esac
# Finally add debug parameter
ARGS="$ARGS --debug \"${PLUGIN_DEBUG:-false}\""
# Execute Go program
eval "go run /plugins/main.go $ARGS"
text and markdown message types will pass --at and --isAtAll parameterseval to finally execute the command, correctly handling parameters with spacessecret parameter is only passed when providedat parameter is only passed when provided (only for supported message types)isAtAll maintains default value as false (only for supported message types)debug parameter defaults to falseevallink, actionCard, multiActionCard, and feedCard type messages do not support @ functionalityFor more usage, refer to: DingTalk Open Platform Help Documentation