Background
To ensure the security of Custom bots, we provide three protection measures to safeguard the operation of your Custom bot. These measures include Custom keywords, sign request (encryption with a signature), and IP address (range). These methods effectively protect your bot from malicious attacks.Prerequisites
Complete the Create a Custom bot procedure.Custom keywords
You can configure up to 10 keywords. A message must contain at least one of these keywords to be sent successfully. For example, if you add the Custom keyword monitoring alert, the messages sent by this bot must contain the phrase monitoring alert to be delivered successfully.Sign request
The sign request method enables two-way Security Authentication between the DingTalk Bot and the developer to verify Security. The signature calculation steps are as follows:-
Use the timestamp and the secret as the signing string. Calculate the signature using the HmacSHA256 algorithm, encode the result with Base64, and then urlEncode the signature parameter to obtain the final signature. UTF-8 encoding is required.
Parameter Description timestamp The current system timestamp of the developer service, in milliseconds. The difference from the request invocation time must not exceed 1 hour. secret The secret. The string starting with SEC displayed under the Sign request section on the bot Security Settings Page. -
Sample signature calculation code (Java)
-
Sample signature calculation code (Python)
-
Sample signature calculation code (Java)
-
Obtain the current system timestamp and the encrypted sign value from the developer service, and append timestamp and sign to the URL.
For details, see Send Group Chat messages with a Custom bot.
Parameter Description timestamp The timestamp used by the developer to calculate the sign value. sign The signature value obtained in Step 1.
IP address (range)
After configuration, only requests from IP addresses within the specified range are processed. Two configuration methods are supported: IP address and IP address range. IPv6 Allowlist is not yet supported. The formats are as follows:| Format | Description |
|---|---|
| 1.1.1.1 | The developer’s outbound public IP address (not a LAN address). |
| 1.1.1.0/24 | A network segment expressed in CIDR notation. |
Related documents
- Send Group Chat messages with a Custom bot
- OpenAPI for sending group messages with a Custom bot