preparation
Enterprise wechat administrator account (you can apply for one by yourself) Enterprise account , for testing)
Self built application for testing
Wechat alarm configuration parameters
corpid
Each enterprise has a unique corpid. To obtain this information, you can view the "enterprise ID" (with administrator permission) under "my enterprise" - enterprise information "in the management background
agentid
Each application has a unique agentid. In the management background - > applications and applets - > applications, click an application to see agentid.
secret
Secret is the "key" used to ensure data security in enterprise applications. Each application has an independent access key. In order to ensure data security, secret must not be disclosed.
At present, the secret includes:
Self built application secret. In the management background - > applications and applets - > applications - > self built, click an application to see it.
Basic application secret. Some basic applications (such as "approval" and "clock in" applications) support operations through APIs. In the management background - > Application and applet - > Application - > foundation, click an application and open the "API" button to see
users
You can enter it at will
send.type
Sending type, application and group chat
user.send.msg
Content to send, JSON format
Application format
{ "touser": "UserID1|UserID2|UserID3", "toparty": "PartyID1|PartyID2", "totag": "TagID1 | TagID2", "msgtype": "text", "agentid": 1, "text": { "content": "Your express has arrived\n Please bring your work card to the mail center to get it" }, "safe": 0, "enable_id_trans": 0, "enable_duplicate_check": 0 }
Group chat format
{ "chatid": "CHATID", "msgtype": "text", "text": { "content": "Your express has arrived\n Please bring your work card to the mail center to get it" }, "safe": 0 }
Refer to enterprise wechat Development Center
Alarm usage record
40008 error
2022-03-02 11:15:27.150 INFO 1909 --- [pool-3-thread-1] o.a.d.plugin.alert.wechat.WeChatSender : Enterprise WeChat send [https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=wdH26O_yUyQ7HE9qTgocvHz4IW2Thw1qc-XIUK8IPsTs1TTzykogH1BHFpcBTVQbohcUuquq-U90rrWZO_86r-VWyZJpLEdjrLNwgVCS1jqt-RotbaxJ92uZBh_Nzln6P75HiSmoTfmw98b5IZkI9fDLhpAxrz5GtXwXAuoneazV2gmaehT5v5cSHUuEkbUeCGx7-n7MAn06yRIea4Aeug], param:test alert, resp:{"errcode":40008,"errmsg":"Warning: wrong json format. invalid message type, hint: [1646190927277970339863326], from ip: 36.5.134.204, more info at https://open.work.weixin.qq.com/devtool/query?e=40008"} 2022-03-02 11:15:27.172 INFO 1909 --- [pool-3-thread-1] o.a.dolphinscheduler.alert.AlertSender : Alert Plugin WeChat send error : Warning: wrong json format. invalid message type, hint: [1646190927277970339863326], from ip: 36.5.134.204, more info at https://open.work.weixin.qq.com/devtool/query?e=40008
The reason is user send. MSG configuration content is incorrect, pass Enterprise wechat Developer Center - Interface debugging tool , after debugging directly, copy the body content
Verify again
2022-03-02 14:31:57.250 INFO 1909 --- [pool-3-thread-1] o.a.d.plugin.alert.wechat.WeChatSender : Enterprise WeChat send [https://qyapi. weixin. qq. com/cgi-bin/message/send? access_ token=0suIhV8_ YfrgWRQ8o5JYO9UhqsQIxxJKaHmdROUt3MJAM24IgwMTw6lwDa45btKtBzrJ7NsIhw2Sde-3AWyjlKJ36jHTaXeAe_ ZAOi0Yye_ OrvzPk0zr28iayeT25Jn3d_ ONQ8Fk9vQe6zts3FZc6dlIuncrAsfTJRfEHH99Ht7zjPyVD6XO1wO1MiWiGaJHLAQ09gYw0LlgzwnwH_ Iqja], param: {"touser": "1", "toParty": "1", "totag": "tagid1 | tagid2", "msgtype": "text", "AgentID": 1000002, "text": {"content": "testing wechat API"}, "safe": 0, "enable_id_trans": 0, "enable_duplicate_check": 0}, resp:{"errcode":0,"errmsg":"ok","invaliduser":"1","invalidtag":"0","msgid":"Dv0oBVNA9p2BIWPODPqgktEu4XC8Y5v2dnEPBBt0GuGW6lViRFDOqz-9mIPuwa5IzUngy4Yk3Ef4tXu0ADGW8w"} 2022-03-02 14:31:57.250 INFO 1909 --- [pool-3-thread-1] o.a.dolphinscheduler.alert.AlertSender : Alert Plugin WeChat send success
But the alarm content is written dead!!!!
How to send specific task error information
View source code
Modify the content and replace the specific task information
The variable msg format is not configured correctly. If $, {}, "", 44004 error will be reported
2022-03-02 15:11:57.193 INFO 1909 --- [pool-3-thread-1] o.a.d.plugin.alert.wechat.WeChatSender : Enterprise WeChat send [https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=0suIhV8_YfrgWRQ8o5JYO9UhqsQIxxJKaHmdROUt3MJAM24IgwMTw6lwDa45btKtBzrJ7NsIhw2Sde-3AWyjlKJ36jHTaXeAe_ZAOi0Yye_OrvzPk0zr28iayeT25Jn3d_ONQ8Fk9vQe6zts3FZc6dlIuncrAsfTJRfEHH99Ht7zjPyVD6XO1wO1MiWiGaJHLAQ09gYw0LlgzwnwH_IQjA], param:{ "touser": "14ead2cf8110655aed8fdf2257ab5c1d", "toparty": "1", "totag": "TagID1 | TagID2", "msgtype": "text", "agentid": 1000002, "text": {"content": $`start process failed` >projectId:1 >projectName:dolphin >owner:admin >processId:49 >processDefinitionCode:4696813047552 >processName:alert-1-20220302151151784 >taskCode:4696810253440 >taskName:testAlert >taskType:SHELL >taskState:FAILURE >taskStartTime:2022-03-02 15:11:51 >taskEndTime:2022-03-02 15:11:51 >taskHost:192.168.56.10:1234 >logPath:/home/dolphinscheduler/app/dolphinscheduler/logs/4696813047552_1/49/57.log }, "safe": 0, "enable_id_trans": 0, "enable_duplicate_check": 0 }, resp:{"errcode":44004,"errmsg":"Warning: wrong json format. empty content, hint: [1646205117042450091058341], from ip: 36.5.134.204, more info at https://open.work.weixin.qq.com/devtool/query?e=44004","msgid":"Dv0oBVNA9p2BIWPODPqgktEu4XC8Y5v2dnEPBBt0GuFZDilY0v-NBE66YjhWNimCQRXZm-_TMwwtLbWQxXgDDA"} 2022-03-02 15:11:57.193 INFO 1909 --- [pool-3-thread-1] o.a.dolphinscheduler.alert.AlertSender : Alert Plugin WeChat send error : Warning: wrong json format. empty content, hint: [1646205117042450091058341], from ip: 36.5.134.204, more info at https://open.work.weixin.qq.com/devtool/query?e=44004
Verify again
2022-03-02 15:16:42.172 INFO 1909 --- [pool-3-thread-1] o.a.d.plugin.alert.wechat.WeChatSender : Enterprise WeChat send [https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=0suIhV8_YfrgWRQ8o5JYO9UhqsQIxxJKaHmdROUt3MJAM24IgwMTw6lwDa45btKtBzrJ7NsIhw2Sde-3AWyjlKJ36jHTaXeAe_ZAOi0Yye_OrvzPk0zr28iayeT25Jn3d_ONQ8Fk9vQe6zts3FZc6dlIuncrAsfTJRfEHH99Ht7zjPyVD6XO1wO1MiWiGaJHLAQ09gYw0LlgzwnwH_IQjA], param:{ "touser": "14ead2cf8110655aed8fdf2257ab5c1d", "toparty": "1", "totag": "TagID1 | TagID2", "msgtype": "text", "agentid": 1000002, "text": {"content": "$`start process failed` >projectId:1 >projectName:dolphin >owner:admin >processId:50 >processDefinitionCode:4696813047552 >processName:alert-1-20220302151637646 >taskCode:4696810253440 >taskName:testAlert >taskType:SHELL >taskState:FAILURE >taskStartTime:2022-03-02 15:16:37 >taskEndTime:2022-03-02 15:16:37 >taskHost:192.168.56.10:1234 >logPath:/home/dolphinscheduler/app/dolphinscheduler/logs/4696813047552_1/50/58.log " }, "safe": 0, "enable_id_trans": 0, "enable_duplicate_check": 0 }, resp:{"errcode":0,"errmsg":"ok. Warning: wrong json format. ","invalidtag":"0","msgid":"ApdmTZacy5fwcrmY4C90r3teipLMq1w1kUrdF8B6gEPJugsbwGrAkbGGkYsRAC5doqD9unFNXaaL36GjzulS4w"} 2022-03-02 15:16:42.173 INFO 1909 --- [pool-3-thread-1] o.a.dolphinscheduler.alert.AlertSender : Alert Plugin WeChat send success (END)
other
Wechat directly receives enterprise application notifications
chatid
Only the group created by api has group ID
WeChat should also receive the message, but it needs the official account or business certification to open it.
Opening method: workbench - management enterprise - message exchange with wechat