node-red-contrib-bizwechat(企业微信版本的pushbear)

对于不了解这是什么东西,请参考以下两篇文章,两篇对照这看让你更容易上手:

推送节点有更新注意查看, 1.0.8新增两个节点注意查看
推送节点有更新注意查看, 1.0.8新增两个节点注意查看
推送节点有更新注意查看, 1.0.8新增两个节点注意查看

节点分为 服务端输出推送

  1. 服务端: 用来接收企业微信发来的信息,你可以在后面获取企业微信发过来的信息,但是同时你需要给它反馈不然它认为你没有收到,重复发送三次,只是确认收到消息,直接返回一个空,即msg.payload = ‘’
  2. 输出: 用于返回服务端信息,一般跟在服务端后面,不可以单独使用
  3. 推送: 发送消息给指定的人或多个人,默认为群发,指定人是通过通讯录里面的账号, 可以自行查看

如何使用

服务端消息

开启接收消息模式后,企业成员在企业微信应用里发送消息时,企业微信会将消息同步到企业应用的后台。
如何接收消息已经在使用接收消息说明,本小节是对普通消息结构体的说明。
消息类型支持:文本、图片、语音、视频、位置以及链接信息。

详细的消息格式请看这里](https://work.weixin.qq.com/api/doc#90000/90135/90239)

开启接收消息模式后,可以配置接收事件消息。
当企业成员通过企业微信APP或微工作台(原企业号)触发进入应用、上报地理位置、点击菜单等事件时,企业微信会将这些事件消息发送给企业后台。

详细的事件格式请看这里](https://work.weixin.qq.com/api/doc#90000/90135/90240)

服务端消息查看实战

  • 查看消息和事件
    企业微信要求在5s内必须有响应不然会再次重试发送,为了不重复接收相同的消息目前节点会在4s的时候回复一个空包,下图是如何查看微信消息及事件的流

[{"id":"f1a926c1.47a0c8","type":"bizwechat-input","z":"8de36836.2ad578","name":"1","bizwechat":"66803d6f.5417b4","x":1031,"y":295,"wires":[["b371c09.f13734"]]},{"id":"b371c09.f13734","type":"debug","z":"8de36836.2ad578","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1250,"y":293,"wires":[]},{"id":"66803d6f.5417b4","type":"bizwechat-configurator","z":"","name":"","port":"3001","corpid":" ","agentid":" ","corpsecret":" ","url":" ","token":" ","aeskey":" ","client_id":"","client_secret":""}]


  • 响应消息
    上面已经说到了服务器节点会自动响应,所以注意自己的操作时间,根据优先响应规则,后面回复的消息企业微信将无法收到。

[{"id":"f1a926c1.47a0c8","type":"bizwechat-input","z":"8de36836.2ad578","name":"1","bizwechat":"66803d6f.5417b4","x":1031,"y":295,"wires":[["b371c09.f13734","7a5fee7e.96fe"]]},{"id":"b371c09.f13734","type":"debug","z":"8de36836.2ad578","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1092,"y":149,"wires":[]},{"id":"7a5fee7e.96fe","type":"function","z":"8de36836.2ad578","name":"我收到了","func":"//如果设置空即 msg.payload = '',则是确认消息\nmsg.payload = \"我收到了\"\nreturn msg;","outputs":1,"noerr":0,"x":1208,"y":293,"wires":[["9cf1b0de.a92ee"]]},{"id":"9cf1b0de.a92ee","type":"bizwechat-output","z":"8de36836.2ad578","name":"","bizwechat":"66803d6f.5417b4","x":1378,"y":289,"wires":[]},{"id":"66803d6f.5417b4","type":"bizwechat-configurator","z":"","name":"","port":"3001","corpid":" ","agentid":" ","corpsecret":" ","url":" ","token":" ","aeskey":" ","client_id":"","client_secret":""}]

  • 推送消息
    发送消息给指定的人或多个人,默认为群发,指定人是通过通讯录里面的账号, 可以自行查看。消息格式支持markdown,此节点依赖服务器节点请注意:

重要: 1.0.8 之后添加了消息简介: introduction 用于自动获取内容不太好看的时候
重要: 1.0.8 之后添加了消息简介: introduction 用于自动获取内容不太好看的时候
重要: 1.0.8 之后添加了消息简介: introduction 用于自动获取内容不太好看的时候

  1. 发送给所有人

[{"id":"d2cfbe29.54fd9","type":"debug","z":"8de36836.2ad578","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":786,"y":235,"wires":[]},{"id":"2976594b.99a2e6","type":"bizwechat-pushbear","z":"8de36836.2ad578","name":"","bizwechat":"","touser":"","toparty":"测试","title":"修改标题","description":"","x":752,"y":318,"wires":[["d2cfbe29.54fd9"]]},{"id":"e89a3e0a.48d71","type":"inject","z":"8de36836.2ad578","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":405,"y":332,"wires":[["d34c6f27.c06ed"]]},{"id":"d34c6f27.c06ed","type":"function","z":"8de36836.2ad578","name":"发送消息给所有人","func":"\nmsg.payload = `我们为记录思想和分享知识提供更专业的工具。 您可以使用 Cmd Markdown:\n\n> * 整理知识,学习笔记\n> * 发布日记,杂文,所见所想\n> * 撰写发布技术文稿(代码支持)\n> * 撰写发布学术论文(LaTeX 公式支持)\n\n![cmd-markdown-logo](https://www.zybuluo.com/static/img/logo.png)`\nreturn msg;","outputs":1,"noerr":0,"x":576,"y":324,"wires":[["2976594b.99a2e6"]]},{"id":"a4e4f92c.ab3658","type":"bizwechat-input","z":"8de36836.2ad578","name":"服务器","bizwechat":"","x":400,"y":193,"wires":[[]]}]

  1. 发送给指定的人(可以通过前面节点指定touser或节点里面写指定的人)


[{"id":"d2cfbe29.54fd9","type":"debug","z":"8de36836.2ad578","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":786,"y":235,"wires":[]},{"id":"2976594b.99a2e6","type":"bizwechat-pushbear","z":"8de36836.2ad578","name":"","bizwechat":"","touser":"","toparty":"测试","title":"修改标题","description":"","x":752,"y":318,"wires":[["d2cfbe29.54fd9"]]},{"id":"e89a3e0a.48d71","type":"inject","z":"8de36836.2ad578","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":405,"y":332,"wires":[["d34c6f27.c06ed"]]},{"id":"d34c6f27.c06ed","type":"function","z":"8de36836.2ad578","name":"发送给自己","func":"//接收者账号\nmsg.touser = 'yaming116'\n//发送给内容\nmsg.payload = `我们为记录思想和分享知识提供更专业的工具。 您可以使用 Cmd Markdown:\n\n> * 整理知识,学习笔记\n> * 发布日记,杂文,所见所想\n> * 撰写发布技术文稿(代码支持)\n> * 撰写发布学术论文(LaTeX 公式支持)\n\n![cmd-markdown-logo](https://www.zybuluo.com/static/img/logo.png)`\nreturn msg;","outputs":1,"noerr":0,"x":556,"y":324,"wires":[["2976594b.99a2e6"]]},{"id":"a4e4f92c.ab3658","type":"bizwechat-input","z":"8de36836.2ad578","name":"服务器","bizwechat":"","x":400,"y":193,"wires":[[]]}]
  • 高级玩法初步
    因为可以做对话,所以我们可以根据发送的指令做一些响应,导入下面节点进入应用看看会收到啥,也可以尝试发送查询看看会有啥反馈

[{"id":"b371c09.f13734","type":"debug","z":"8de36836.2ad578","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1165,"y":152,"wires":[]},{"id":"7a5fee7e.96fe","type":"function","z":"8de36836.2ad578","name":"你来啦","func":"//如果设置空,则是确认消息\nmsg.payload = '你来啦'\nreturn msg;","outputs":1,"noerr":0,"x":1446,"y":191,"wires":[["9cf1b0de.a92ee"]]},{"id":"9cf1b0de.a92ee","type":"bizwechat-output","z":"8de36836.2ad578","name":"","bizwechat":"66803d6f.5417b4","x":1726,"y":304,"wires":[]},{"id":"a4e4f92c.ab3658","type":"bizwechat-input","z":"8de36836.2ad578","name":"服务器","bizwechat":"66803d6f.5417b4","x":1042,"y":297,"wires":[["9b88330d.2b7a5","b371c09.f13734","34899757.f67728"]]},{"id":"9b88330d.2b7a5","type":"switch","z":"8de36836.2ad578","name":"事件监听","property":"message.Event","propertyType":"msg","rules":[{"t":"eq","v":"enter_agent","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1246,"y":210,"wires":[["7a5fee7e.96fe"]]},{"id":"34899757.f67728","type":"switch","z":"8de36836.2ad578","name":"文本查询","property":"message.Content","propertyType":"msg","rules":[{"t":"eq","v":"查询","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1222,"y":306,"wires":[["61454e1f.b4429"]]},{"id":"61454e1f.b4429","type":"function","z":"8de36836.2ad578","name":"收到查询指令","func":"//如果设置空,则是确认消息\nmsg.payload = '收到查询指令'\nreturn msg;","outputs":1,"noerr":0,"x":1446,"y":302,"wires":[["9cf1b0de.a92ee"]]},{"id":"66803d6f.5417b4","type":"bizwechat-configurator","z":"","name":"","port":"3001","corpid":"xxx","agentid":"xxx","corpsecret":"xxx","url":"xxxx","token":"xxx","aeskey":"xxx","client_id":"","client_secret":""}]

  • 高级推送
    在节点发布一段时间后,发现有些伙伴需要企业微信的另外一些推送消息格式,所以多了这两个节点.高级推送是用户自己组装推送消息用于发布,需要自己查看腾讯文档](https://work.weixin.qq.com/api/doc#90000/90135/90236)
[{"id":"cb6e44eb.43f0c8","type":"inject","z":"8de36836.2ad578","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":596,"y":589,"wires":[["26647815.2e2eb8"]]},{"id":"26647815.2e2eb8","type":"function","z":"8de36836.2ad578","name":"发送给自己","func":"\nmsg.payload = {\n   \"touser\" : \"@all\",\n   \"msgtype\" : \"text\",\n   \"text\" : {\n       \"content\" : \"你的快递已到,请携带工卡前往邮件中心领取。\\n出发前可查看<a href=\\\"http://work.weixin.qq.com\\\">邮件中心视频实况</a>,聪明避开排队。\"\n   },\n   \"safe\":0\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":771,"y":592,"wires":[["59c9d75d.9aa378"]]},{"id":"59c9d75d.9aa378","type":"bizwechat-push","z":"8de36836.2ad578","name":"","bizwechat":"66803d6f.5417b4","x":1031,"y":601,"wires":[["6296109.688f4f"]]},{"id":"6296109.688f4f","type":"debug","z":"8de36836.2ad578","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1292,"y":472,"wires":[]},{"id":"66803d6f.5417b4","type":"bizwechat-configurator","z":"","name":"","port":"3001","corpid":"xxx","agentid":"1000004","corpsecret":"xxx","url":"xxx","token":"xxx","aeskey":"xxx","client_id":"xxx","client_secret":"xxx"}]
  • 上传临时素材

素材上传得到media_id,该media_id仅三天内有效
media_id在同一企业内应用之间可以共享

特别说明:
本节点需要三个参数:



[{"id":"9f54353d.420758","type":"inject","z":"8de36836.2ad578","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":430,"y":736,"wires":[["ee6778a6.b4c528"]]},{"id":"ee6778a6.b4c528","type":"www-request","z":"8de36836.2ad578","name":"大方摄像机获取图片","method":"GET","ret":"bin","url":"http://192.168.123.166/cgi-bin/currentpic.cgi","follow-redirects":false,"tls":"","x":643,"y":699,"wires":[["2eea9f23.9bc64"]]},{"id":"2eea9f23.9bc64","type":"function","z":"8de36836.2ad578","name":"","func":"msg.type = \"image\"\nmsg.filename = \"xxx.jpg\"\nreturn msg;","outputs":1,"noerr":0,"x":820,"y":700,"wires":[["e4b86fd.aa8a99","6296109.688f4f"]]},{"id":"e4b86fd.aa8a99","type":"bizwechat-upload","z":"8de36836.2ad578","name":"","bizwechat":"66803d6f.5417b4","x":988,"y":699,"wires":[["6296109.688f4f"]]},{"id":"6296109.688f4f","type":"debug","z":"8de36836.2ad578","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1292,"y":472,"wires":[]},{"id":"66803d6f.5417b4","type":"bizwechat-configurator","z":"","name":"","port":"3001","corpid":"xxxx","agentid":"xxxx","corpsecret":"xxx","url":"xxxx","token":"xxxx","aeskey":"xxxx","client_id":"xxxx","client_secret":"xxxx"}]


先要有个公司来用企业微信

1 个赞

企业微信就是一个可以打通微信的app,不需要公司也可以的。

始终装不上node-red-contrib-bizwechat 以前也没弄过 node-red 请大神解答下!!:lol

我现在也一直装不上这个节点,,,太难了。

复制这里的代码到node-red里报错,应该是不完整。


一路路灯安装完成,但是推送的时候nodered报错,“Error: Invalid property expression: unexpected ’ ’ at position 7”
流程如下,设置信息已重新处理:
[{“id”:“e2ae4f4d.1aa66”,“type”:“debug”,“z”:“7823e34a.591d0c”,“name”:"",“active”:true,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“true”,“x”:630,“y”:440,“wires”:[]},{“id”:“a072b770.69b078”,“type”:“bizwechat-pushbear”,“z”:“7823e34a.591d0c”,“name”:"",“bizwechat”:“77b4c5a7.4070cc”,“touser”:"",“toparty”:“测试”,“title”:“修改标题”,“description”:"",“x”:490,“y”:440,“wires”:[[“e2ae4f4d.1aa66”]]},{“id”:“38826af5.84e4a6”,“type”:“inject”,“z”:“7823e34a.591d0c”,“name”:"",“topic”:"",“payload”:"",“payloadType”:“date”,“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“x”:110,“y”:440,“wires”:[[“9f31820f.e2f67”]]},{“id”:“9f31820f.e2f67”,“type”:“function”,“z”:“7823e34a.591d0c”,“name”:“发送消息给所有人”,“func”:" msg.payload = 1111111111111111111111111111\n return msg;",“outputs”:1,“noerr”:0,“x”:290,“y”:440,“wires”:[[“a072b770.69b078”]]},{“id”:“77b4c5a7.4070cc”,“type”:“bizwechat-configurator”,“z”:"",“name”:"",“port”:“13418888888”,“corpid”:“ww4281b64888888888”,“agentid”:“1000088888888”,“corpsecret”:“AY7w1UDyeK3AYy88888888888888”,“url”:“http://aaa.com:9991”,“token”:“HWxSnM888888888Jkv”,“aeskey”:“QulfmnPnzQF9GMKlA888888888888888888rO9NMLj”,“client_id”:"",“client_secret”:""}]

检查配置信息,应该里面有空格

老大 看了你好多教程,代码导进去都有问题,不知道哪个环节有问题。有的是括号缺了,有的是用的中文引号,有的是识别不出json。

你导入哪个有问题的?这个我应该全部都修正过了

非常详尽,有点搞明白这个企业微信怎么使用了 :smile:

感谢花神,我的应用ID前有空格

谢谢花神分享!看视频教程一步一步跟着做一次成功,企业微信唯一的缺点就是不直观,要点进去看,普通域名还打不开,测试.com域名没问题,要是能弹窗就看到消息就完美了。

使用企业微信app

你的这个报告后来解决没有?我也是这个报错

我的也是报这个错,就是那个应用ID前面的空格要去掉

强。。。折腾了半天,确实是Agentid的空格去掉即可。

能不能出一个青春版,只保留推送功能不要接收功能?

设置成功了,好高兴;分享一个最简单的流,如果有人能用到也是不错的。刚刚入手,只能弄成这样简单的东西。多分享就好

1.用处:可以给企业微信发定义好的问题,然后获得答案;
QQ截图20210907002224

我不会插入red的导出代码。。。
flows.json (2.1 KB)

一直卡在这里 配置里面也检查了没有空格

1 个赞