Use enterprise WeChat API to implement weather robots, fault alarm robots, etc.

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.
Insert picture description here

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.
Insert picture description here

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

  1. Create a group chat first, it cannot contain WeChat contacts.

  2. Click on group details -> group robots -> click
    Insert picture description here

  3. Click to add robot
    Insert picture description here

  4. Give a name
    Insert picture description here

  5. Finish, copy Webhook
    Insert picture description here

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%"
    }
}

Insert picture description here

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 .
Insert picture description here
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.

Guess you like

Origin blog.csdn.net/xmcy001122/article/details/114127638