Message Types and Data Formats
There are two ways to send bot messages: sending them through the API and sending them through a Webhook. Different methods support different message types and data formats. Note We recommend sending messages through the API.| Message Type | Send Bot Messages via API | Send Bot Messages via Webhook |
|---|---|---|
| Text type | ✅ | ✅ |
| Markdown type | ✅ | ✅ |
| Image type | ✅ | ❌ |
| ActionCard type | ✅ | ✅ |
| FeedCard type | ❌ | ✅ |
| Link message | ✅ | ✅ |
Message Types and Data Formats Supported by the API
Applicable APIs
Data Formats
| Message Type | Message Template Key | Message Template Parameters | Description |
|---|---|---|---|
| Text type | sampleText | { "content": "xxxx" } | |
| Markdown type | sampleMarkdown | { "title": "xxxx", "text": "xxxx" } | |
| Image type | sampleImageMsg | { "photoURL": "xxxx" } | |
| Link type | sampleLink | { "text": "Message content test", "title": "sampleLink message test", "picUrl": "@lADOADmaWMzazQKA", "messageUrl": "http://dingtalk.com" } | Link message. |
| ActionCard type | sampleActionCard | { "title": "Test title", "text": "Content test", "singleTitle": "View details", "singleURL": "https://open.dingtalk.com" } | Card message: one button. One button |
| sampleActionCard2 | { "title": "Message title test", "text": "Message body text test", "actionTitle1": "One button", "actionURL1": "https://www.taobao.com", "actionTitle2": "Two buttons", "actionURL2": "https://www.tmall.com" } | Card message: two vertical buttons. Two vertical buttons | |
| sampleActionCard3 | { "title": "Message title test", "text": "Message content test", "actionTitle1": "Text of the first button", "actionURL1": "URL triggered by the first button", "actionTitle2": "Text of the second button", "actionURL2": "URL triggered by the second button", "actionTitle3": "Text of the third button", "actionURL3": "URL triggered by the third button" } | Card message: three vertical buttons. | |
| sampleActionCard4 | { "title":"Message title test", "text":"Message content test", "actionTitle1":"Text of the first button", "actionURL1":"URL triggered by the first button", "actionTitle2":"Text of the second button", "actionURL2":"URL triggered by the second button", "actionTitle3":"Text of the third button", "actionURL3":"URL triggered by the third button", "actionTitle4":"Text of the fourth button", "actionURL4":"URL triggered by the fourth button" } | Card message: four vertical buttons. | |
| sampleActionCard5 | { "title":"Message title test", "text":"Message content test", "actionTitle1":"Text of the first button", "actionURL1":"URL triggered by the first button", "actionTitle2":"Text of the second button", "actionURL2":"URL triggered by the second button", "actionTitle3":"Text of the third button", "actionURL3":"URL triggered by the third button", "actionTitle4":"Text of the fourth button", "actionURL4":"URL triggered by the fourth button", "actionTitle5":"Text of the fifth button", "actionURL5":"URL triggered by the fifth button" } | Card message: five vertical buttons. | |
| sampleActionCard6 | { "title": "xxxx", "text": "xxxx", "buttonTitle1":"xxxxx", "buttonUrl1":"xxxxx", "buttonTitle2":"xxxxx", "buttonUrl2":"xxxxx" } | Card message: two horizontal buttons. Horizontal buttons |
Message Types and Data Formats Supported by Webhooks
Applicable Scope
Note Webhooks are only supported in group chats. For details on how to send messages through a Webhook, see Send Group Chat Messages Using a Webhook with an Internal Bot and Custom Bot Integration.Data Formats
-
Text type
{ "at": { "atMobiles": [ "180xxxxxx" ], "atUserIds": [ "user123" ], "isAtAll": false }, "text": { "content": "I am who I am, @180xxxxxx a different kind of fireworks" }, "msgtype": "text" }Parameter Required Type Description msgtype Yes String text. content Yes String Message text. atMobiles No Array The mobile numbers of the people to @mention. Note The message content must include “@mobile number” and be used together with the atMobiles parameter for the @mention to take effect, as shown in the example above. atUserIds No Array The user IDs of the people to @mention. isAtAll No Boolean Set to true to @Everyone; otherwise, false. -
Link type
{ "msgtype": "link", "link": { "text": "This is a Link message", "title": "This is a Link message", "picUrl": "https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png", "messageUrl": "https://open.dingtalk.com/document/" } }Parameter Parameter Type Required Description msgtype String Yes Message type. Fixed to link in this case. title String Yes Message title. text String Yes Message content. If it is too long, only part of it is displayed. messageUrl String Yes The URL that opens when you click the message. picUrl String No Image URL. -
Markdown type
{ "msgtype": "markdown", "markdown": { "title":"Hangzhou Weather", "text": "#### Hangzhou Weather @150XXXXXXXX \n> 9 degrees, northwest wind level 1, air quality good 89, relative humidity 73% \n> \n> ###### Published at 10:20 [Weather](https://www.dingalk.com) \n" }, "at": { "atMobiles": [ "150XXXXXXXX" ], "atUserIds": [ "user123" ], "isAtAll": false } }Currently, only a subset of Markdown syntax is supported. The supported elements are as follows:Parameter Required Type Description msgtype Yes String markdown. title Yes String The content displayed on the first screen of the chat. text Yes String Message content in Markdown format. atMobiles No Array The mobile numbers of the people to @mention. Note The message content must include “@mobile number” and be used together with the atMobiles parameter for the @mention to take effect, as shown in the example above. atUserIds No Array The user IDs of the people to @mention. isAtAll No Boolean Set to true to @Everyone; otherwise, false. Titles # Heading 1 ## Heading 2 ### Heading 3 #### Heading 4 ##### Heading 5 ###### Heading 6 Quote > A man who stands for nothing will fall for anything. Bold and italic text **bold** *italic* Link [this is a link](https://www.dingtalk.com/) Image Bulleted List - item1 - item2 Numbered List 1. item1 2. item2 -
Whole-Card Jump ActionCard type
{ "msgtype": "actionCard", "actionCard": { "title": "Build a Coffee Shop", "text": " \n #### The Apple coffee shop Steve Jobs wanted to build 20 years ago \n\n The design of the Apple Store is moving from a heavily tech-oriented feel toward a more lifestyle-oriented one, a direction that can actually be traced back to a plan Apple had 20 years ago to build a coffee shop", "singleTitle" : "Read More", "singleURL" : "https://www.dingtalk.com/" } }Parameter Required Type Description msgtype Yes String actionCard. title Yes String The content displayed on the first screen of the chat. text Yes String Message content in Markdown format. singleTitle Yes String The title of the single button. singleURL Yes String The jump link of the single button. -
Independent Jump ActionCard type
{ "msgtype": "actionCard", "actionCard": { "title": "Steve Jobs wanted to build an Apple coffee shop 20 years ago, and it was the forerunner of the Apple Store", "text": " \n\n #### The Apple coffee shop Steve Jobs wanted to build 20 years ago \n\n The design of the Apple Store is moving from a heavily tech-oriented feel toward a more lifestyle-oriented one, a direction that can actually be traced back to a plan Apple had 20 years ago to build a coffee shop", "btnOrientation": "0", "btns": [ { "title": "Great content", "actionURL": "https://www.dingtalk.com/" }, { "title": "Not interested", "actionURL": "https://www.dingtalk.com/" } ] } }Parameter Required Type Description msgtype Yes String actionCard. title Yes String The content displayed on the first screen of the chat. text Yes String Message content in Markdown format. btns Yes Array Buttons. title Yes String Button title. actionURL Yes String The URL triggered when you click the button. btnOrientation No String The arrangement order of the buttons. 0: Buttons arranged vertically 1: Buttons arranged horizontally -
FeedCard type
{ "msgtype": "feedCard", "feedCard": { "links": [ { "title": "The Train of the Times Moves Forward 1", "messageURL": "https://www.dingtalk.com/", "picURL": "https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png" }, { "title": "The Train of the Times Moves Forward 2", "messageURL": "https://www.dingtalk.com/", "picURL": "https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png" } ] } }When you do not want to reply with a message in the group, use the following reply format:Parameter Required Type Description msgtype Yes String feedCard. title Yes String The text of a single message item. messageURL Yes String The jump link of a single message item. picURL Yes String The URL of the image after a single message item. { "msgtype": "empty" }