对于不了解这是什么东西,请参考以下两篇文章,两篇对照这看让你更容易上手:
- 基于企业微信的一对多消息送达服务-完美替代pushbear](基于企业微信的一对多消息送达服务-完美替代pushbear
- 企业微信pushbear所踩的坑](企业微信pushbear所踩的坑
推送节点有更新注意查看, 1.0.8新增两个节点注意查看
推送节点有更新注意查看, 1.0.8新增两个节点注意查看
推送节点有更新注意查看, 1.0.8新增两个节点注意查看
节点分为 服务端,输出, 推送
- 服务端: 用来接收企业微信发来的信息,你可以在后面获取企业微信发过来的信息,但是同时你
需要给它反馈
不然它认为你没有收到,重复发送三次,只是确认收到消息,直接返回一个空,即msg.payload = ‘’ - 输出: 用于返回
服务端
信息,一般跟在服务端
后面,不可以单独使用 - 推送: 发送消息给指定的人或多个人,默认为群发,指定人是通过通讯录里面的账号, 可以自行查看
如何使用
服务端消息
开启接收消息模式后,企业成员在企业微信应用里发送消息时,企业微信会将消息同步到企业应用的后台。
如何接收消息已经在使用接收消息说明,本小节是对普通消息结构体的说明。
消息类型支持:文本、图片、语音、视频、位置以及链接信息。
详细的消息格式请看这里](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
用于自动获取内容不太好看的时候
- 发送给所有人
[{"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":[[]]}]
- 发送给指定的人(可以通过前面节点指定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在同一企业内应用之间可以共享
特别说明:
本节点需要三个参数:
- payload 文件数据,可以通过
http
或file
节点获取 - type 具体格式参考微信文档](https://work.weixin.qq.com/api/doc#90000/90135/90253)
- filename 随意填写,注意文件格式保持正确即可
[{"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"}]