This is the 7th day of my participation in the August Text Challenge.More challenges in August

An overview of the

Many companies will use the enterprise wechat for communication, just the enterprise wechat and open API for us, we can easily use the API it provides to achieve some automatic functions.

For example, in our company, overtime meals must be ordered on the food page, and only on the same day and before 16:30. When busy, some people may forget, so someone set a regular task at 16:00 to send a meal ordering reminder in the group through the API of the enterprise wechat.

The effect

From this, we were inspired to create an online fault group and send a report to the group if a fault is detected. Compared with email, this kind of reminder is more timely and not limited by the computer. You only need to open the wechat notification of the enterprise on your mobile phone, so you can receive the warning anytime and anywhere and deal with it quickly. You no longer need to worry about the problem that it has been several hours from the user’s discovery to the notification to us.

Enterprise wechat group robot API introduction

PS: If you can’t find it, you can go to search engine -> enterprise wechat API -> enterprise internal development -> Client API -> Group robot -> Group robot configuration description

Before beginning, it is suggested that have a look at the official documentation: work.weixin.qq.com/api/doc/900… , probably contains the following contents:

  • How to use swarm robots
  • Message type and data format
    • Text type
    • Markdown type
    • Image type
    • Graphic type
    • The file type
  • Message sending frequency limit
  • File upload interface

Now that we know what swarm robots can do, how do you build swarm robots?

Creating swarm robots

  1. Create a group chat that does not include wechat contacts.
  2. Go to Group Details -> Group Robots -> Click

  1. Click Add Robot

  1. A name

  1. Done, copy the Webhook

At this point, the swarm robot was successfully created. Webhook address is very important, do not disclose or public, otherwise people can use this place to push some spam to the group, causing bad effects.

Test group robot

After completing the robot creation 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 from the Body interface, paste the following content in:

{
    "msgtype": "text"."text": {
        "content": "Weather in Guangzhou today: 29 degrees, mostly cloudy, chance of rain: 60%"}}Copy the code

Click Send and you should receive a message from the robot in the group.

The following picture shows the author’s markdown format, which is more eye-catching than textThe official API manual.It is also possible to specify @someone by simply writing the corresponding phone number in the mentioned_mobile_list. Note that the @ function does not work when msgType=markdown.

PS: Once a bot is created, it can be added to other group chats.

To delete the robot, click the “… “of the robot details. Button.