DuliDuli Open Platform
EN
简体中文
繁體中文
English
Quick Start APIs DuliDuli Official Website
模板

Group Bot


How to Use the Group Bot

The bot currently supports joining group chats and can be used to push app notifications.

• After adding a bot to a group in the terminal, the creator can see the bot's unique webhook URL on the bot details page. Developers can send an HTTP POST request to this address as described below to send messages to the group. Here's a simple example. Suppose the webhook is:https://xxx../app/appWebhookMsgReceive?accessToken=LOHcr%2Bt9qR4NajdqYrx9JBw%2FrlsxITtgclmWFFmidZ6O8SITNXzVagTglXgG3Qi9Xkko7PW6wSSDBFeaPSWLuQzQ77pZqtCUYyH%2B9O8pMtjzrOXMnFJDpcbhctGALoNf

Important Note: Be sure to protect the bot's webhook URL and avoid leaking it! Do not share it on GitHub, blogs, or other publicly accessible places, otherwise malicious users could use your bot to send spam messages.

Creating a Bot Application

  1. Log in to the Duli management backend, go to "Workbench - Application Management", and click to add a "webhook application".

  1. Add a webhook application and set the basic application information.

Adding to a Group Chat

  1. Go to the bot settings and bind the bot to a group.


2.Obtain the webhook URL.

Sending Bot Messages

Request Instructions

Make a POST request to the URL: (Note: Replace the URL with your bot's webhook address)https://xxx../app/appWebhookMsgReceive?accessToken=xxxx

  • The current custom bot supports message types such as text, markdown, and template card.

1.Text Message

{
"title": "[发火][发火][发火]:告警节点: 机器告警 \n",
"message": "问题详情: cpu太高了 \n 告警主机:Host1111 \n 告警时间:2022-11-21 11:06:00 \n 告警等级:高 \n 告警信息:CPU使用率高达100% \n 告警项目:有鸽服务 \n 当前状态: Open \n 告警描述: CPU高达100% \n 事件 ID: 1234"
}

Parameters

Required

Description

title

Y

Message type, fixed as "text" at this time.

content

Y

Text content, up to 2048 bytes in length, must be UTF-8 encoded.

mentioned_list

N

List of user IDs to mention specific members in the group (@someone), @all to mention everyone. If the developer cannot obtain user IDs, they can use mentioned_mobile_list.

mentioned_mobile_list

N

List of mobile numbers to mention group members corresponding to the numbers (@someone), @all to mention everyone.

Example Image:

2.Card Message 1:

{
"msgType": "action_card",
"content":{
"title": "是透出到会话列表和通知的文案",
"markdown":"支持markdown格式的正文内容",
"single_title":"查看详情",
"single_url": "https://open.dingtalk.com"
}
}

3.Card Message 2:

{
"msgType": "action_card",
"content": {
"text":"",
"title": "我 20 年前想打造一间苹果咖啡厅,而它正是 Apple Store 的前身",
"markdown": "![screenshot](https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png) \n\n #### 乔布斯 20 年前想打造的苹果咖啡厅 \n\n Apple Store 的设计正从原来满满的科技感走向生活化,而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划",
"btn_orientation": "0",
"btn_json_list": [
{
"title": "内容不错",
"action_url": "http://ugram2.bigdamo.com/images/contact/icon_company.png/"
},
{
"title": "不感兴趣",
"action_url": "http://ugram2.bigdamo.com/images/contact/icon_company.png/"
}
]
}
}

Example Image:

4.Markdown Message

{
"msgType": "markdown",
"content": {
"text": "#### 杭州天气 @150XXXXXXXX \n > 9度,西北风1级,空气良89,相对温度73%\n > ![screenshot](https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png)\n > ###### 10点20分发布 [天气](https://www.dingtalk.com) \n",
"title": "markdownTitle"
}
}


Example Image:



Error Codes

code

message

Desc

500

err_message_resolve

Parameter parsing failed, unable to retrieve appId.

500

IP limit

Not in the application whitelist.

500

Webhook address invalid

Invalid webhook address.

500

AppId error

Invalid appId.

500

AppId closed

Backend application not enabled.

0

fail in send

System exception.