HTTP header parameters
| Parameter | Description |
|---|---|
| timestamp | The timestamp when the message was sent, in milliseconds. |
| sign | The signature value. |
- If the timestamp differs from the current system timestamp by more than 1 hour, the request is considered invalid.
- If the sign does not match the value calculated by the developer, the request is considered invalid.
How to calculate the sign
Use the timestamp from the header + “\n” + the bot’s appSecret as the string to sign. Calculate the signature using the HmacSHA256 algorithm, then Base64-encode the result to obtain the final signature value. Sample signature calculation code (Java)HTTP Body
Parameter description
| Parameter | Required | Type | Description |
|---|---|---|---|
| msgtype | Yes | String | The message type. |
| content | Yes | String | The message text. |
| msgId | Yes | String | The encrypted message ID. |
| createAt | Yes | String | The message timestamp, in milliseconds. |
| conversationType | Yes | String | 1: Direct Message 2: Group Chat |
| conversationId | Yes | String | The chat ID. |
| conversationTitle | No | String | The chat title. Returned only for group chats. |
| senderId | Yes | String | The encrypted sender ID. Note Use senderStaffId as the sender’s user ID value. |
| senderNick | Yes | String | The sender’s name. |
| senderCorpId | No | String | The organization ID of the sender’s current group in an internal group. |
| sessionWebhook | Yes | String | The Webhook URL of the current chat. |
| sessionWebhookExpiredTime | Yes | Long | The expiration time of the current chat’s Webhook URL. |
| isAdmin | No | boolean | Indicates whether the sender is an Admin. Note Takes effect after the bot is published. |
| chatbotCorpId | No | String | The encrypted organization ID where the bot resides. |
| isInAtList | No | boolean | Indicates whether the user is in the @ list. |
| senderStaffId | No | String | The user ID of the member who @mentioned the bot in an internal group. Note This field is returned only after the bot is published to the production version. |
| senderUnionId | No | String | The unionId of the sender. |
| chatbotUserId | Yes | String | The encrypted bot ID. |
| atUsers | No | Array | Information about the @mentioned users. - dingtalkId: The encrypted ID of the @mentioned user. - staffId: The userId of the @mentioned user. This field is empty for external users in external chats. - unionId: The unionid of the @mentioned user. |
Supported message types for receiving
Bots currently support receiving text, voice, image, file, video, and rich text messages. The following tables explain the fields for each type of message that the bot receives. Apart from the message type and message body fields, all other parameter fields are the same as in the table above.Important
- In a group chat: when group members @mention the bot, the bot does not support receiving voice, file, or video types.
- In a person-to-person chat: the bot does not support receiving voice, file, or video types.
- In a person-to-bot chat: the bot supports receiving voice, file, and video types.
Text message
Parameter description:
| Parameter | Type | Description |
|---|---|---|
| msgtype | String | The message type: - text: Text message |
| content | String | The text message content. |
Voice message
Parameter description:
| Parameter | Type | Description |
|---|---|---|
| msgtype | String | The message type: - audio: Voice message |
| downloadCode | String | The download code of the voice file. Use it to retrieve the binary voice file by calling the Server API Download the file content received by the bot to obtain a temporary download URL. |
| recognition | String | The text result of Speech-to-Text recognition. |
| duration | Long | The duration of the voice, in milliseconds. |
Image message
Parameter description:
| Parameter | Type | Description |
|---|---|---|
| msgtype | String | The message type: - picture: Image message |
| downloadCode | String | The download code of the image file. Use it to retrieve the binary image file by calling the Server API Download the file content received by the bot to obtain a temporary download URL. |
Video message
Parameter description:
| Parameter | Type | Description |
|---|---|---|
| msgtype | String | The message type: - video: Video message |
| downloadCode | String | The download code of the video file. Use it to retrieve the binary video file by calling the Server API Download the file content received by the bot to obtain a temporary download URL. |
| videoType | String | The video File Type. |
| duration | Long | The duration of the video, in milliseconds. |
File message
Parameter description:
| Parameter | Type | Description |
|---|---|---|
| msgtype | String | The message type: - video: File message |
| downloadCode | String | The download code of the file. Use it to retrieve the binary file by calling the Server API Download the file content received by the bot to obtain a temporary download URL. |
| fileName | String | The file name. |
Rich text message
Parameter description:
| Name | Type | Required | Description |
|---|---|---|---|
| msgtype | String | Yes | The message type: - richText: Rich Text |
| content | Object | Yes | The message content. |
| richText | Array | Yes | The Rich Text list. Note The message list can contain: - text: Text message - picture: Image message |