Featured image of post Building a Message Push Service Bot Using WeCom

Building a Message Push Service Bot Using WeCom

Setting up a message push service without send frequency limits

Start

Previously, I configured message push notifications on CODING for all successful project deployments. As the number of projects increased and other services required message notifications, the free quota provided by Server Chan became insufficient.

After researching two commonly used services, both have frequency limitations:

  • Server Chan: Free tier allows only 5 messages/day
  • Qmsg Chan: 30 messages/day with occasional instability

Configuration

  • Discovered that Server Chan’s documentation teaches how to build a WeCom bot service. Repository: https://github.com/easychen/wecomchan
  • Followed the README to register a WeCom enterprise account (individual users can create an “enterprise” with personal information)
  • Obtained API parameters (agentid, secret, corpid) for sending messages through WeCom’s API
  • Server Chan provides a pre-built Go service: https://github.com/easychen/wecomchan/blob/main/go-wecomchan/README.md
  • Modified CODING deployment scripts to send requests to my self-hosted service instead of Server Chan:
// Server Chan  
sshCommand(  
  remote: remoteConfig,  
  command: "curl -X POST -d \"title=`echo \$(curl -I 127.0.0.1:8199/ping)`&desp=Message details\" https://sctapi.ftqq.com/xxxx.send",  
  sudo: true,  
)  
              
// Modified version  
sshCommand(  
  remote: remoteConfig,  
  command: "curl -X POST -d \"sendkey=xxxxxxx&msg_type=text&msg=${DOCKER_REPO_NAME}%0D%0A${SERVICE_URL}%0D%0A%0D%0A`echo \$(curl -I 127.0.0.1:8199/ping)`\" http://127.0.0.1:8080/wecomchan",  
  sudo: true,  
)  

Demo