When a workflow finishes — whether it succeeds or fails — Argo Workflows can automatically run an exit handler to notify external systems. This topic shows you how to configure a DingTalk chatbot as the notification target using an exit handler and the onExit field.
Prerequisites
Before you begin, make sure you have:
-
A Kubernetes cluster for distributed Argo Workflows. For setup instructions, see Create a cluster for Argo Workflows
-
Internet access enabled for the cluster's virtual private cloud (VPC)
How it works
-
External systems receive messages by exposing an HTTP webhook endpoint.
-
Argo Workflows supports
exit handlertemplates. You can define anexit handlerfor a specific step, or for the entire workflow using theonExitfield. -
The
exit handlerruns in a container. Use thecurlcommand in the container to send an HTTP request — with the notification payload — to the webhook endpoint.
Step 1: Create a DingTalk chatbot
Creating a chatbot generates a dedicated webhook URL that you associate with Argo Workflows to receive notifications.
-
Open the DingTalk group that should receive event notifications.
-
Set up a custom robot:
-
Click the Group Settings icon
in the upper-right corner. In the Group Settings panel, click Bot. -
In the Robot Management panel, click Add Robot. In the Add Robot section of the Robot dialog box, click
. -
In the Please choose which robot to add section, click Custom. In the Robot details dialog box, click Add. Complete the configuration as prompted, and select at least one security option. Select Additional Signature, IP Address, or both.
ImportantThe cluster's VPC must have internet access to reach the DingTalk API. Configure an internet NAT gateway and specify its elastic IP address (EIP) in the IP Address field of the chatbot.
-
-
After completing the setup, copy the generated webhook URL.

Step 2: Configure the workflow to send notifications
Use the following YAML to create a workflow with an exit handler that sends a DingTalk notification. For more information about creating workflows, see Create a workflow.
The exit handler uses curlimages/curl to send a link-type DingTalk message. The onExit field runs the handler after the workflow finishes, regardless of the outcome.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: notification-demo-
spec:
entrypoint: say-hello
onExit: exit-handler # Runs after the workflow completes, whether it succeeds or fails.
templates:
- name: say-hello
container:
image: alpine:latest
command: [sh, -c]
args: ["echo hello"]
- name: exit-handler
container:
image: curlimages/curl
command: [sh, -c]
# Sends a link-type DingTalk message. The link URL points to the Argo Workflows console
# so recipients can view workflow details directly.
# Available variables: {{workflow.name}}, {{workflow.status}}, {{workflow.failures}}, {{workflow.workflow.duration}}
args: [
"curl -H 'Content-Type: application/json' -d '{
\"msgtype\": \"link\",
\"link\": {
\"title\": \"Argo workflow notification\",
\"text\": \"WF {{workflow.name}} {{workflow.status}}\",
\"messageUrl\": \"https://argo.xxx.cn-zhangjiakou.alicontainer.com:2746/workflows/default/{{workflow.name}}?tab=workflow\"
}
}'
https://oapi.dingtalk.com/robot/send?access_token=b97fb519129fdfce879baa4e3b905b14e6a64e8994f0ea3b11dda****"
# Replace with the webhook URL of your DingTalk group.
]
The following screenshot shows an example of the resulting DingTalk message.
What's next
-
To integrate a custom DingTalk chatbot with other systems, see Integrate custom chatbots.