Slack-Bot using RunwayML
A Slack-bot using RunwayML to process images with Neural Nets
About
This is an example for prototyping a slack-bot with Node-RED. If you post a picture in slack and mention the clippingbot, it will send the picture to RunwayML to remove the background.
It should be easy to adapt this to use any other Runway Model.
Environment variables
This flow needs two environment variables
SLACK_TOKEN
— your slack bot user OAuth access token starting with xoxb-RUNWAY_TOKEN
— to your runway model token
Flow variables
Thos flow sets three variables (you need to adapt those if you are using a different model)
runway_model
— URL of your runway modelrunway_input
— imput image propertyrunway_output
— output image property
Slack permissions
You need to create a bot with the following bot token scopes:
app_mentions:read
chat:write
files:read
files:write
RunwayML model
This setup uses an implementation of BASNet, contributed by Anastasis Germanidis, based on this paper
Node-RED Requirements
- node-red-contrib-image-tools — for displaying images
- node-red-contrib-browser-utils — for testing purposes
[{"id":"6132258b.426fd4","type":"tab","label":"clipping bot","disabled":false,"info":"A Slack-bot using RunwayML to process images with Neural Nets\n\n## About\n\nThis is an example for prototyping a slack-bot with Node-RED.\nIf you post a picture in slack and mention the clippingbot, it will send the picture to RunwayML to remove the background. \n\nIt should be easy to adapt this to use any other Runway Model.\n\n## Environment variables\n\nThis flow needs two environment variables\n\n- `SLACK_TOKEN` — your slack bot user OAuth access token starting with **xoxb-**\n- `RUNWAY_TOKEN` — to your runway model token\n\n## Flow variables\n\nThos flow sets three variables\n(you need to adapt those if you are using a different model)\n\n- `runway_model`— URL of your runway model\n- `runway_input`— imput image property \n- `runway_output` — output image property\n\n## Slack permissions\n\nYou need to create a bot with the following bot token scopes:\n\n- `app_mentions:read`\n- `chat:write`\n- `files:read`\n- `files:write`\n\n## RunwayML model\n\nThis setup uses an implementation of BASNet, contributed by Anastasis Germanidis, based on [this paper](https://openaccess.thecvf.com/content_CVPR_2019/html/Qin_BASNet_Boundary-Aware_Salient_Object_Detection_CVPR_2019_paper.html)\n\n## Node-RED Requirements\n\n - [node-red-contrib-image-tools](https://flows.nodered.org/node/node-red-contrib-image-tools) — for displaying images\n - [node-red-contrib-browser-utils](https://flows.nodered.org/node/node-red-contrib-browser-utils) — for testing purposes"},{"id":"fc0f251.5f10fd8","type":"http in","z":"6132258b.426fd4","name":"","url":"/event","method":"post","upload":true,"swaggerDoc":"","x":130,"y":660,"wires":[["23d02ad9.387256","5139a6d8.a4b628","f254a620.10ab8"]]},{"id":"88ca5db4.c7771","type":"inject","z":"6132258b.426fd4","name":"","topic":"","payload":"SLACK_TOKEN","payloadType":"env","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":110,"y":120,"wires":[["7efa7ac7.68fd6c"]]},{"id":"57e2a45a.d2e73c","type":"debug","z":"6132258b.426fd4","name":"slack token","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1070,"y":120,"wires":[]},{"id":"888dd1f0.f5ec58","type":"http response","z":"6132258b.426fd4","name":"","statusCode":"","headers":{},"x":930,"y":620,"wires":[]},{"id":"2a57fbeb.00fde4","type":"change","z":"6132258b.426fd4","name":"echo challenge","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.challenge","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":620,"wires":[["888dd1f0.f5ec58"]]},{"id":"23d02ad9.387256","type":"switch","z":"6132258b.426fd4","name":"app_mention event?","property":"payload.event.type","propertyType":"msg","rules":[{"t":"eq","v":"app_mention","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":500,"y":840,"wires":[["6bbb73c2.0e4f24"]]},{"id":"389e2d44.85cfda","type":"switch","z":"6132258b.426fd4","name":"are there files?","property":"payload.event.files.length","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1020,"y":840,"wires":[["58a11f96.9925e"],["83f0c4b9.f7ea18"]]},{"id":"83f0c4b9.f7ea18","type":"function","z":"6132258b.426fd4","name":"create message without pic","func":" \nmsg.payload = {\n token: env.get(\"SLACK_TOKEN\"),\n channel: msg.channel,\n text: \"If you add a picture when mentionig me, I will transform it ...\",\n};\nmsg.headers = {\n \"content-type\": \"multipart/form-data\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":1320,"y":900,"wires":[["188b6df0.e9ae82","102b3e58.f9e102"]]},{"id":"5139a6d8.a4b628","type":"switch","z":"6132258b.426fd4","name":"challenge?","property":"payload.challenge","propertyType":"msg","rules":[{"t":"nnull"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":660,"wires":[["2a57fbeb.00fde4"],["71421665.ec5a8"]]},{"id":"9b87165d.c8a948","type":"inject","z":"6132258b.426fd4","name":"","topic":"","payload":"RUNWAY_TOKEN","payloadType":"env","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":110,"y":160,"wires":[["6d01dab4.59d9cc"]]},{"id":"d8561730.ddb38","type":"debug","z":"6132258b.426fd4","name":"runway token","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1080,"y":160,"wires":[]},{"id":"58a11f96.9925e","type":"link out","z":"6132258b.426fd4","name":"get picture from slack message","links":["4a130eb.eb5b57"],"x":1215,"y":800,"wires":[]},{"id":"4a130eb.eb5b57","type":"link in","z":"6132258b.426fd4","name":"get picture from slack message","links":["58a11f96.9925e"],"x":375,"y":1200,"wires":[["ca372e6a.704588"]]},{"id":"17d88fa3.706cd","type":"http request","z":"6132258b.426fd4","name":"download pic","method":"GET","ret":"bin","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":1200,"y":1200,"wires":[["2490285e.cd8b4","fc6aa301.bbf52","23001dc9.45d652"]]},{"id":"8df39fb2.359ec8","type":"function","z":"6132258b.426fd4","name":"authorize slack","func":"msg.headers = {\n 'Authorization': 'Bearer ' + env.get(\"SLACK_TOKEN\")\n}\nreturn msg;","outputs":1,"noerr":0,"x":1000,"y":1200,"wires":[["17d88fa3.706cd"]]},{"id":"ca372e6a.704588","type":"change","z":"6132258b.426fd4","name":"get file url","rules":[{"t":"set","p":"url","pt":"msg","to":"payload.event.files[0].url_private","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":1200,"wires":[["8df39fb2.359ec8","47eb21db.492ce8"]]},{"id":"76a1e675.72522","type":"comment","z":"6132258b.426fd4","name":"get picture from slack message","info":"","x":210,"y":1200,"wires":[]},{"id":"2f838e0f.cf5e0a","type":"comment","z":"6132258b.426fd4","name":"webhook for slack's app_mention event","info":"","x":210,"y":620,"wires":[]},{"id":"976f8efd.c0d4c8","type":"http request","z":"6132258b.426fd4","name":"runway request","method":"POST","ret":"obj","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":1580,"y":1500,"wires":[["166f201.214a46"]]},{"id":"714ab8d.2e4f0c8","type":"function","z":"6132258b.426fd4","name":"create runway request","func":"\n\nmsg.headers = {\n \"Authorization\": \"Bearer \" + env.get(\"RUNWAY_TOKEN\")\n};\n\nmsg.payload = {\n [ flow.get(\"runway_input\") ]: msg.payload\n};\n\nmsg.url = flow.get(\"runway_model\") + \"/query\";\n\nreturn msg;\n","outputs":1,"noerr":0,"x":1300,"y":1500,"wires":[["976f8efd.c0d4c8","eac81dfe.dd7e08"]]},{"id":"ecec5ea0.0ccc38","type":"image viewer","z":"6132258b.426fd4","name":"","width":160,"data":"payload","dataType":"msg","x":2670,"y":1460,"wires":[[]]},{"id":"41ca875f.afb18","type":"jimp-image","z":"6132258b.426fd4","name":"base64 image","data":"image","dataType":"msg","ret":"b64","parameter1":"","parameter1Type":"msg","parameter2":"","parameter2Type":"msg","parameter3":"","parameter3Type":"msg","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","parameterCount":0,"jimpFunction":"none","selectedJimpFunction":{"name":"none","fn":"none","description":"Just loads the image.","parameters":[]},"x":1000,"y":1500,"wires":[["714ab8d.2e4f0c8","f68d287e.f50c58"]]},{"id":"90a78b7b.5b6bd8","type":"fileinject","z":"6132258b.426fd4","name":"","x":280,"y":1400,"wires":[["37ce621a.9bdca6"]]},{"id":"4e1048c4.2e8a6","type":"debug","z":"6132258b.426fd4","name":"modell error","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2170,"y":1760,"wires":[]},{"id":"eac81dfe.dd7e08","type":"debug","z":"6132258b.426fd4","name":"runway request","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1580,"y":1560,"wires":[]},{"id":"166f201.214a46","type":"switch","z":"6132258b.426fd4","name":"server status code","property":"statusCode","propertyType":"msg","rules":[{"t":"eq","v":"200","vt":"num"},{"t":"eq","v":"429","vt":"num"},{"t":"eq","v":"502","vt":"num"},{"t":"eq","v":"500","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":5,"x":1830,"y":1500,"wires":[["3c9f7d8f.412c6a"],["3220d0da.6a15e8","4e58a20e.c14c3c"],["eacbd24.09a15b","4e58a20e.c14c3c"],["4e1048c4.2e8a6","4e58a20e.c14c3c"],["9e9b0e91.160b8","4e58a20e.c14c3c"]]},{"id":"9ae6f29.c97341","type":"link in","z":"6132258b.426fd4","name":"transform picture with runway","links":["23001dc9.45d652"],"x":375,"y":1500,"wires":[["37ce621a.9bdca6"]]},{"id":"80b44f62.eba54","type":"comment","z":"6132258b.426fd4","name":"test runway","info":"","x":270,"y":1360,"wires":[]},{"id":"4f73ba79.c0443c","type":"comment","z":"6132258b.426fd4","name":"transform picture with runway","info":"","x":220,"y":1500,"wires":[]},{"id":"5aaf49c1.e08ad8","type":"comment","z":"6132258b.426fd4","name":"get picture from slack message","info":"","x":1370,"y":800,"wires":[]},{"id":"23001dc9.45d652","type":"link out","z":"6132258b.426fd4","name":"transform picture with runway","links":["9ae6f29.c97341"],"x":1375,"y":1200,"wires":[]},{"id":"e54b477e.4fc008","type":"comment","z":"6132258b.426fd4","name":"transform picture with runway","info":"","x":1520,"y":1200,"wires":[]},{"id":"71421665.ec5a8","type":"http response","z":"6132258b.426fd4","name":"","statusCode":"200","headers":{},"x":680,"y":720,"wires":[]},{"id":"2490285e.cd8b4","type":"image viewer","z":"6132258b.426fd4","name":"","width":160,"data":"payload","dataType":"msg","x":1430,"y":1320,"wires":[[]]},{"id":"3455572a.93832","type":"comment","z":"6132258b.426fd4","name":"use tokens from ENV variables","info":"","x":190,"y":80,"wires":[]},{"id":"188b6df0.e9ae82","type":"debug","z":"6132258b.426fd4","name":"message without pic","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1700,"y":940,"wires":[]},{"id":"fc6aa301.bbf52","type":"debug","z":"6132258b.426fd4","name":"picture from slack message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1500,"y":1260,"wires":[]},{"id":"416286ff.0f7fd8","type":"debug","z":"6132258b.426fd4","name":"picture from runway","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":2720,"y":1400,"wires":[]},{"id":"cec592ac.75ba38","type":"comment","z":"6132258b.426fd4","name":"post message on slack","info":"","x":240,"y":2340,"wires":[]},{"id":"57514d05.d8049c","type":"link in","z":"6132258b.426fd4","name":"post message on slack","links":["102b3e58.f9e102","cb7e4763.7ada88","4e5d65de.6d6aac"],"x":375,"y":2340,"wires":[["66e1f0f6.80453"]]},{"id":"66e1f0f6.80453","type":"http request","z":"6132258b.426fd4","name":"post message","method":"POST","ret":"obj","paytoqs":false,"url":"https://slack.com/api/chat.postMessage","tls":"","persist":false,"proxy":"","authType":"","x":1120,"y":2340,"wires":[["90e5dfc1.495d6"]]},{"id":"102b3e58.f9e102","type":"link out","z":"6132258b.426fd4","name":"post message on slack","links":["57514d05.d8049c"],"x":1615,"y":900,"wires":[]},{"id":"46d7d07a.22b608","type":"comment","z":"6132258b.426fd4","name":"post message on slack","info":"","x":1740,"y":900,"wires":[]},{"id":"dde1a3a1.f12a38","type":"comment","z":"6132258b.426fd4","name":"at least one file","info":"","x":1280,"y":760,"wires":[]},{"id":"1f847bb3.b90114","type":"comment","z":"6132258b.426fd4","name":"no files","info":"","x":1250,"y":860,"wires":[]},{"id":"3c3d7114.acb676","type":"comment","z":"6132258b.426fd4","name":"challenge accepted!","info":"","x":710,"y":580,"wires":[]},{"id":"1a933057.6cd038","type":"comment","z":"6132258b.426fd4","name":"it's alright","info":"","x":680,"y":680,"wires":[]},{"id":"eacbd24.09a15b","type":"debug","z":"6132258b.426fd4","name":"rate limit","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":2160,"y":1700,"wires":[]},{"id":"3220d0da.6a15e8","type":"debug","z":"6132258b.426fd4","name":"asleep","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2150,"y":1640,"wires":[]},{"id":"40a6aced.86942c","type":"inject","z":"6132258b.426fd4","name":"https://clipping.hosted-models.runwayml.cloud/v1/","topic":"","payload":"https://clipping.hosted-models.runwayml.cloud/v1/","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":250,"y":300,"wires":[["fd525a09.115218"]]},{"id":"fd525a09.115218","type":"change","z":"6132258b.426fd4","name":"","rules":[{"t":"set","p":"runway_model","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":300,"wires":[["7d87e9dc.576fa"]]},{"id":"890f8b8a.4d9b08","type":"comment","z":"6132258b.426fd4","name":"set runway model","info":"","x":150,"y":260,"wires":[]},{"id":"7d87e9dc.576fa","type":"debug","z":"6132258b.426fd4","name":"runway","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1060,"y":300,"wires":[]},{"id":"9e9b0e91.160b8","type":"debug","z":"6132258b.426fd4","name":"http error","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2160,"y":1820,"wires":[]},{"id":"7efa7ac7.68fd6c","type":"function","z":"6132258b.426fd4","name":"check","func":"if(msg.payload == \"\") {\n node.error(\"Token missing, make sure to set the RUNWAY_TOKEN env variable\")\n}\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":120,"wires":[["57e2a45a.d2e73c"]]},{"id":"6d01dab4.59d9cc","type":"function","z":"6132258b.426fd4","name":"check","func":"\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":160,"wires":[["d8561730.ddb38"]]},{"id":"35f30136.1d561e","type":"change","z":"6132258b.426fd4","name":"","rules":[{"t":"set","p":"runway_input","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":340,"wires":[["35aa1215.ed22ae"]]},{"id":"a07b279a.5dade8","type":"change","z":"6132258b.426fd4","name":"","rules":[{"t":"set","p":"runway_output","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":380,"wires":[["a46c40ad.14c1"]]},{"id":"b946b309.eb41c8","type":"inject","z":"6132258b.426fd4","name":"","topic":"","payload":"image","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":110,"y":340,"wires":[["35f30136.1d561e"]]},{"id":"7841af9c.70cc68","type":"inject","z":"6132258b.426fd4","name":"","topic":"","payload":"image","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":110,"y":380,"wires":[["a07b279a.5dade8"]]},{"id":"35aa1215.ed22ae","type":"debug","z":"6132258b.426fd4","name":"runway input","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1070,"y":340,"wires":[]},{"id":"a46c40ad.14c1","type":"debug","z":"6132258b.426fd4","name":"runway output","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1080,"y":380,"wires":[]},{"id":"3c9f7d8f.412c6a","type":"function","z":"6132258b.426fd4","name":"get model output","func":"msg.payload = msg.payload[ flow.get(\"runway_output\") ];\nreturn msg;","outputs":1,"noerr":0,"x":2170,"y":1460,"wires":[["416286ff.0f7fd8","ecec5ea0.0ccc38","e5751c54.d231f8"]]},{"id":"f68d287e.f50c58","type":"debug","z":"6132258b.426fd4","name":"base64 input image","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1310,"y":1560,"wires":[]},{"id":"4e58a20e.c14c3c","type":"function","z":"6132258b.426fd4","name":"create error message","func":"msg.payload = {\n token: env.get(\"SLACK_TOKEN\"),\n channel: msg.channel,\n text: `I am sorry, there was a ${msg.statusCode} error at Runway`,\n};\nmsg.headers = {\n \"content-type\": \"multipart/form-data\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":2180,"y":1540,"wires":[["cb7e4763.7ada88"]]},{"id":"cb7e4763.7ada88","type":"link out","z":"6132258b.426fd4","name":"post error message on slack","links":["57514d05.d8049c"],"x":2315,"y":1540,"wires":[]},{"id":"da984c72.e8051","type":"link out","z":"6132258b.426fd4","name":"upload transformed file to slack","links":["ee5684.a1ded18"],"x":2655,"y":1340,"wires":[]},{"id":"1825c3e0.33e024","type":"comment","z":"6132258b.426fd4","name":"upload transformed file to slack","info":"","x":2810,"y":1340,"wires":[]},{"id":"90e5dfc1.495d6","type":"debug","z":"6132258b.426fd4","name":"slack message post response","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1390,"y":2340,"wires":[]},{"id":"5128267.69d02d8","type":"comment","z":"6132258b.426fd4","name":"wake up runway","info":"","x":760,"y":1500,"wires":[]},{"id":"317c8568.8ade02","type":"http request","z":"6132258b.426fd4","name":"","method":"GET","ret":"obj","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":750,"y":2000,"wires":[["66755477.7e42e4"]]},{"id":"461c0d9c.483c4c","type":"debug","z":"6132258b.426fd4","name":"runway status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1180,"y":2080,"wires":[]},{"id":"60e8f070.3afe7","type":"function","z":"6132258b.426fd4","name":"create request","func":"\nmsg.headers = {\n \"Authorization\": \"Bearer \" + env.get(\"RUNWAY_TOKEN\")\n};\n\nmsg.url = flow.get('runway_model');\n\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":2000,"wires":[["317c8568.8ade02"]]},{"id":"66755477.7e42e4","type":"change","z":"6132258b.426fd4","name":"model status","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.status","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":2000,"wires":[["461c0d9c.483c4c","db04ed61.e928a8"]]},{"id":"db04ed61.e928a8","type":"switch","z":"6132258b.426fd4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"running","vt":"str"},{"t":"eq","v":"starting","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":1150,"y":2000,"wires":[["6714fc1b.beaad4"],["2a4c9ca1.b7ae2c"],["840a0fb.74851f"]]},{"id":"b020ffd4.711c7","type":"comment","z":"6132258b.426fd4","name":"runway is awake now","info":"","x":1480,"y":1840,"wires":[]},{"id":"4c216e2.3d27f9","type":"delay","z":"6132258b.426fd4","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1880,"y":2040,"wires":[["78de7c24.25cf44"]]},{"id":"840a0fb.74851f","type":"debug","z":"6132258b.426fd4","name":"runway status error","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1530,"y":2160,"wires":[]},{"id":"78de7c24.25cf44","type":"link out","z":"6132258b.426fd4","name":"try again","links":["1b6d3aaf.d48cdd"],"x":2075,"y":2040,"wires":[]},{"id":"e34ae220.f6205","type":"comment","z":"6132258b.426fd4","name":"try again!","info":"","x":2160,"y":2040,"wires":[]},{"id":"1b6d3aaf.d48cdd","type":"link in","z":"6132258b.426fd4","name":"wake up runway","links":["78de7c24.25cf44","87f54255.f6278"],"x":375,"y":2000,"wires":[["60e8f070.3afe7"]]},{"id":"6714fc1b.beaad4","type":"link out","z":"6132258b.426fd4","name":"runway is awake now","links":["e272703.8662f9"],"x":1355,"y":1840,"wires":[]},{"id":"a21a5779.49b99","type":"comment","z":"6132258b.426fd4","name":"wake up runway","info":"","x":280,"y":2000,"wires":[]},{"id":"87f54255.f6278","type":"link out","z":"6132258b.426fd4","name":"wake up runway","links":["1b6d3aaf.d48cdd"],"x":655,"y":1500,"wires":[]},{"id":"e272703.8662f9","type":"link in","z":"6132258b.426fd4","name":"runway is awake now","links":["6714fc1b.beaad4"],"x":875,"y":1500,"wires":[["41ca875f.afb18"]]},{"id":"37ce621a.9bdca6","type":"change","z":"6132258b.426fd4","name":"","rules":[{"t":"set","p":"image","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":1500,"wires":[["87f54255.f6278"]]},{"id":"d8ef7b9d.51ca88","type":"comment","z":"6132258b.426fd4","name":"upload file to slack","info":"","x":250,"y":2400,"wires":[]},{"id":"ee5684.a1ded18","type":"link in","z":"6132258b.426fd4","name":"upload file to slack","links":["61e4b312.40f394","da984c72.e8051"],"x":375,"y":2400,"wires":[["aae38a66.bad858","28b6fd92.d66872"]]},{"id":"eec5e3c2.ab4838","type":"http request","z":"6132258b.426fd4","name":"post file","method":"POST","ret":"obj","paytoqs":false,"url":"https://slack.com/api/files.upload","tls":"","persist":false,"proxy":"","authType":"","x":1100,"y":2400,"wires":[["8a3396d7.9206d"]]},{"id":"f254a620.10ab8","type":"debug","z":"6132258b.426fd4","name":"slack event","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":470,"y":920,"wires":[]},{"id":"d4b5491f.a4e0e","type":"debug","z":"6132258b.426fd4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"channel","targetType":"msg","x":1010,"y":920,"wires":[]},{"id":"6bbb73c2.0e4f24","type":"change","z":"6132258b.426fd4","name":"get slack channel","rules":[{"t":"set","p":"channel","pt":"msg","to":"payload.event.channel","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":840,"wires":[["d4b5491f.a4e0e","389e2d44.85cfda"]]},{"id":"8a3396d7.9206d","type":"debug","z":"6132258b.426fd4","name":"slack file upload response","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1370,"y":2400,"wires":[]},{"id":"2f823a47.ec7d9e","type":"comment","z":"6132258b.426fd4","name":"post error message on slack","info":"","x":2460,"y":1540,"wires":[]},{"id":"28b6fd92.d66872","type":"debug","z":"6132258b.426fd4","name":"picture for slack","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":840,"y":2460,"wires":[]},{"id":"aae38a66.bad858","type":"function","z":"6132258b.426fd4","name":"create request","func":"\nmsg.payload = {\n channels: msg.channel,\n initial_comment: \"Here's your clipping!\",\n token: env.get(\"SLACK_TOKEN\"),\n \"file\": {\n \"value\": msg.payload,\n \"options\": {\n \"filename\": \"clipping.png\"\n }\n }\n};\n\nmsg.headers = {\n \"Content-Type\": \"multipart/form-data\"\n};\n\ndelete msg.url;\n\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":2400,"wires":[["eec5e3c2.ab4838","bf8aaa35.e9047"]]},{"id":"bf8aaa35.e9047","type":"debug","z":"6132258b.426fd4","name":"request for file upload","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1140,"y":2460,"wires":[]},{"id":"e5751c54.d231f8","type":"jimp-image","z":"6132258b.426fd4","name":"to buffer","data":"payload","dataType":"msg","ret":"buf","parameter1":"","parameter1Type":"msg","parameter2":"","parameter2Type":"msg","parameter3":"","parameter3Type":"msg","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","parameterCount":0,"jimpFunction":"none","selectedJimpFunction":{"name":"none","fn":"none","description":"Just loads the image.","parameters":[]},"x":2540,"y":1340,"wires":[["da984c72.e8051"]]},{"id":"154b09f4.28eade","type":"function","z":"6132258b.426fd4","name":"create status message","func":"msg.payload = {\n token: env.get(\"SLACK_TOKEN\"),\n channel: msg.channel,\n text: \"AI is waking up, please hold on ...\",\n};\n\nmsg.headers = {\n \"content-type\": \"multipart/form-data\"\n}\n\nmsg.firstloop = true;\n\ndelete msg.url;\n\nreturn msg;","outputs":1,"noerr":0,"x":1920,"y":1960,"wires":[["4e5d65de.6d6aac"]]},{"id":"4e5d65de.6d6aac","type":"link out","z":"6132258b.426fd4","name":"post waking up message on slack","links":["57514d05.d8049c"],"x":2075,"y":1960,"wires":[]},{"id":"159bb9ed.e92726","type":"comment","z":"6132258b.426fd4","name":"post waking up message on slack","info":"","x":2240,"y":1960,"wires":[]},{"id":"2a4c9ca1.b7ae2c","type":"switch","z":"6132258b.426fd4","name":"first loop?","property":"firstloop","propertyType":"msg","rules":[{"t":"null"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1400,"y":2000,"wires":[["908eeb43.55c33"],["4c216e2.3d27f9"]]},{"id":"908eeb43.55c33","type":"change","z":"6132258b.426fd4","name":"","rules":[{"t":"set","p":"firstloop","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1630,"y":1960,"wires":[["154b09f4.28eade","4c216e2.3d27f9"]]},{"id":"93681ce6.720c","type":"comment","z":"6132258b.426fd4","name":"do this only once","info":"","x":1620,"y":1920,"wires":[]},{"id":"47eb21db.492ce8","type":"debug","z":"6132258b.426fd4","name":"file url","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":750,"y":1280,"wires":[]}]