Overview
Many companies use corporate WeChat to communicate internally. It is precisely that corporate WeChat has opened up APIs to us. We can easily use the APIs it provides to implement some automated functions.
For example, in our company, all overtime meals must be ordered on the Meal page, and they can only be ordered on the same day and before 16:30. When busy, some people may forget it, so some people set up a 16:00 timed task, and send order reminders in the group regularly through the enterprise WeChat API.
From this, we have been inspired, is it possible to create an online fault group, if a fault is monitored, a report will be sent to the group. Compared with e-mail, this reminder method is more timely and is not restricted by the computer. You only need to open the corporate WeChat notification on your mobile phone, and you can receive warnings anytime and anywhere, quickly deal with it, and no longer have to worry about the notification from the user to the notification. Several hours have passed since we had this problem.
Introduction to Enterprise WeChat Group Robot API
PS: If you can’t find it, you can go through: Search Engine -> Enterprise WeChat API -> Enterprise Internal Development -> Client API -> Group Robots -> Group Robot Configuration Instructions
Before starting, it is recommended to look at the official documentation: https://work.weixin.qq.com/api/doc/90000/90136/91770 , which probably contains the following content:
- How to use swarm bots
- Message type and data format
- Text type
- markdown type
- Picture type
- Graphic type
- file type
- Message sending frequency limit
- File upload interface
After reading it, we probably know what swarm robots can do, so how to create swarm robots?
Create a group of robots
-
Create a group chat first, it cannot contain WeChat contacts.
-
Click on group details -> group robots -> click
-
Click to add robot
-
Give a name
-
Finish, copy Webhook
At this point, the group robot is successfully created. The webhook address is very important. Don't leak or make it public, otherwise others can push some spam information to the group through this place, which will cause a bad influence.
Test group robot
After completing the creation of the robot through the above steps, we can open the postman tool for API testing.
Select the POST request, paste the webhook address of the robot, select raw->Json on the Body interface, and paste the following content in:
{
"msgtype": "text",
"text": {
"content": "广州今日天气:29度,大部分多云,降雨概率:60%"
}
}
Click Send, and you should receive a message from the robot in the group.
The following picture is the message sent by the author in markdown format, which is more eye-catching than text. For the markdown format, please refer to the official API manual .
Of course, you can also specify @某人, just write the corresponding mobile phone number in the "mentioned_mobile_list". Note that when msgType=markdown, the @ function is not effective.
PS: After the robot is created, it can also be added to other group chats.
If you want to delete the robot, click the "..." button in the robot details.