Quick node setup to get notifications about requested reviews each workday morning.
Flow json:
[{"id":"3ba912e4.896146","type":"http request","z":"8357254d.c82348","name":"Query","method":"GET","ret":"obj","paytoqs":"query","url":"","tls":"","persist":false,"proxy":"","authType":"","x":530,"y":880,"wires":[["fa377f9a.5a51a","872d9224.2341b8"]]},{"id":"fa377f9a.5a51a","type":"debug","z":"8357254d.c82348","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":960,"wires":[]},{"id":"ea784988.39d24","type":"inject","z":"8357254d.c82348","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":940,"wires":[["fef091db.f8a6c"]]},{"id":"fef091db.f8a6c","type":"function","z":"8357254d.c82348","name":"Prepare request","func":"let username = \"foosel\";\nlet query = `review-requested:${username} is:pr is:open`;\n\nreturn {\n headers: {\n \"Accept\": \"application/vnd.github.v3+json\",\n \"User-Agent\": username,\n },\n url: \"http://api.github.com/search/issues\",\n payload: {\n q: query,\n },\n github_username: username,\n github_query: query,\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":880,"wires":[["3ba912e4.896146"]]},{"id":"52b97957.078a38","type":"http request","z":"8357254d.c82348","name":"Discord","method":"POST","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":1220,"y":880,"wires":[[]]},{"id":"f923a83a.95c05","type":"function","z":"8357254d.c82348","name":"prepare discord","func":"let count = msg.payload.total_count;\nlet query = encodeURIComponent(msg.github_query);\nlet payload = {\n content: `@here There are currently ${count} open review requests on GitHub`,\n embeds: [{\n title: \"Search PRs with requested reviews\",\n url: `https://github.com/search?q=${query}`\n }]\n};\nlet webhook = \"https://discord.com/api/webhooks/REDACTED\";\n\nreturn {\n url: webhook,\n payload: payload\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1000,"y":880,"wires":[["fc94956f.419cb","52b97957.078a38"]]},{"id":"fc94956f.419cb","type":"debug","z":"8357254d.c82348","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1210,"y":960,"wires":[]},{"id":"872d9224.2341b8","type":"switch","z":"8357254d.c82348","name":"Any found?","property":"payload.total_count","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":770,"y":880,"wires":[["f923a83a.95c05"]]},{"id":"74c1a72d.e7f9a","type":"cronplus","z":"8357254d.c82348","name":"Every morning","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"Every morning","topic":"every morning","payloadType":"default","payload":"","expressionType":"cron","expression":"30 9 * * 1-5","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":160,"y":880,"wires":[["fef091db.f8a6c"]]},{"id":"466ec4c8.adee24","type":"comment","z":"8357254d.c82348","name":"Review request reminder to Discord","info":"","x":200,"y":820,"wires":[]}]
Utilizes the cronplus node, so that needs to be installed first.
- Install cronplus
- Import the flow definition
- Edit "Prepare request" and adjust
username
to be your GitHub username. - Edit "prepare discord" and adjust
webhook
to be your own Discord webhook URL (how to get one). - Edit the cronplus node to your liking.
- Deploy