All Products
Search
Document Center

Container Service for Kubernetes:Use a DingTalk chabot to send event notifications

Last Updated:Mar 26, 2026

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

  1. External systems receive messages by exposing an HTTP webhook endpoint.

  2. Argo Workflows supports exit handler templates. You can define an exit handler for a specific step, or for the entire workflow using the onExit field.

  3. The exit handler runs in a container. Use the curl command 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.

  1. Open the DingTalk group that should receive event notifications.

  2. Set up a custom robot:

    1. Click the Group Settings icon 图标.png in the upper-right corner. In the Group Settings panel, click Bot.

    2. In the Robot Management panel, click Add Robot. In the Add Robot section of the Robot dialog box, click 图标2.png.

    3. 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.

      Important

      The 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.

  3. After completing the setup, copy the generated webhook URL.

    Webhook URL example

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.

DingTalk message example

What's next