# deploying/Importing without pressing deploy/import

**URL:** <https://discourse.nodered.org/t/deploying-importing-without-pressing-deploy-import/37583>\
**Category:** General\
**Created:** [16 December 2020 15:44 UTC](https://discourse.nodered.org/t/deploying-importing-without-pressing-deploy-import/37583 "2020-12-16T15:44:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![christopherm123](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@christopherm123](https://discourse.nodered.org/u/christopherm123)\
**Post date:** [16 December 2020 15:45 UTC](https://discourse.nodered.org/t/deploying-importing-without-pressing-deploy-import/37583/1 "2020-12-16T15:45:00Z")

</div>

Hello, I have created a flow that is able to output an importable json object, which creates it's own flow, this is based on "[https://eightbar.eu-gb.mybluemix.net/2014/01/19/node-red-flows-that-make-flows/](https://eightbar.eu-gb.mybluemix.net/2014/01/19/node-red-flows-that-make-flows/)"

My next step is to import and deploy the new flow automatically, meaning that if press inject it will do everything else. Is this possible? Any help would be really useful, I can include my flow if it would help. Thank you

```auto
[{"id":"78d9148.cd85bec","type":"function","z":"4fbdfc79.a0e3d4","name":"\"Kafka Consumer Group\"","func":"// create the parameters object from the incoming JSON object\nmsg.payload.push({\"id\":\"9d62194.66f19e8\",\ntype:\"Kafka Consumer Group\",\nz:\"44b6e5c1.60373c\",\nname:\"\",\nbroker:\"f4c7e5bd.09b818\",\ngroupId:\"eGroup\",\nsessionTimeout:15000,\nprotocol:[\"roundrobin\"],\nencoding:\"utf8\",\nfromOffset:\"latest\",\ncommitOffsetsOnFirstJoin:\"true\",\noutOfRangeOffset:\"earliest\",\ntopics:[msg.flow],\nx:140,\ny:200,\nwires:[[\"cbde2001.30002\"]]});\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":830,"y":300,"wires":[["726314e2.9379dc"]]},{"id":"435f421b.24853c","type":"function","z":"4fbdfc79.a0e3d4","name":"initialise","func":"// create the parameters object from the incoming JSON object\nconsole.log(msg.payload);\n//msg.parameters = JSON.parse(msg.payload);\n\n// we're going to create an array of objects\nmsg.payload = [];\nmsg.id = 0;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":300,"wires":[["78d9148.cd85bec"]]},{"id":"8211ab8e.04a3a8","type":"inject","z":"4fbdfc79.a0e3d4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"first\":\"busStop\", \"second\":\"json\"}","payloadType":"str","x":470,"y":200,"wires":[["4c0ca569.dc19cc"]]},{"id":"81705080.fc42d","type":"debug","z":"4fbdfc79.a0e3d4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":540,"wires":[]},{"id":"726314e2.9379dc","type":"function","z":"4fbdfc79.a0e3d4","name":"json","func":"msg.payload.push({\nid:\"cbde2001.30002\",\ntype:\"json\",\nz:\"44b6e5c1.60373c\",\nname:\"\",\nproperty:\"payload\",\naction:\"\",\npretty:false,\nx:330,\ny:200,\nwires:[[\"8b5a275.4eb6fd8\"]]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1090,"y":300,"wires":[["5ec7955c.4a89bc"]]},{"id":"5ec7955c.4a89bc","type":"function","z":"4fbdfc79.a0e3d4","name":"trigger","func":"msg.payload.push({\nid:\"58100134.d8b32\",\ntype:\"trigger\",\nz:\"44b6e5c1.60373c\",\nname:\"Error after 10 minutes\",\nop1:\"1\",\nop2:\"0\",\nop1type:\"str\",\nop2type:\"str\",\nduration:\"10\",\nextend:true,\noverrideDelay:false,\nunits:\"min\",\nreset:\"\",\nbytopic:\"all\",\ntopic:\"topic\",\noutputs:2,\nx:780,\ny:280,\nwires:[[],[\"64dd72c.0131f8c\"]]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1250,"y":300,"wires":[["6423dc91.aa72f4"]]},{"id":"6423dc91.aa72f4","type":"function","z":"4fbdfc79.a0e3d4","name":"change: payload to OFF","func":"msg.payload.push({\nid:\"64dd72c.0131f8c\",\ntype:\"change\",\nz:\"44b6e5c1.60373c\",\nname:\"\",\nrules:[{\"t\":\"set\",\"p\":\"payload\",\"pt\":\"msg\",\"to\":\"OFF\",\"tot\":\"str\"}],\naction:\"\",\nproperty:\"\",\nfrom:\"\",\nto:\"\",\nreg:false,\nx:1060,\ny:300,\nwires:[[\"454be8.c787a418\"]]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1430,"y":300,"wires":[["735da494.0082bc"]]},{"id":"735da494.0082bc","type":"function","z":"4fbdfc79.a0e3d4","name":"change: payload to ON","func":"msg.payload.push({\nid:\"800b91bd.2cc58\",\ntype:\"change\",\nz:\"44b6e5c1.60373c\",\nname:\"\",\nrules:[{\"t\":\"set\",\"p\":\"payload\",pt:\"msg\",to:\"ON\",\"tot\":\"str\"}],\naction:\"\",\nproperty:\"\",\nfrom:\"\",\nto:\"\",\nreg:false,\nx:760,\ny:360,\nwires:[[\"73ad45ec.62d3ac\"]]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":360,"wires":[["132e1409.8da13c"]]},{"id":"132e1409.8da13c","type":"function","z":"4fbdfc79.a0e3d4","name":"function","func":"msg.payload.push({\nid:\"73ad45ec.62d3ac\",\ntype:\"function\",\nz:\"44b6e5c1.60373c\",\nname:\"Test\",\nfunc:\"msg.color = (msg.payload === \\\"ON\\\")?\\\"lime\\\":\\\"red\\\";\\nreturn msg;\",\noutputs:1,\nnoerr:0,\"initialize\":\"\",\nfinalize:\"\",\nx:1010,\ny:360,\nwires:[[\"454be8.c787a418\"]]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":520,"y":360,"wires":[["65683c0a.d21114"]]},{"id":"65683c0a.d21114","type":"function","z":"4fbdfc79.a0e3d4","name":"ui_text: Working test","func":"msg.payload.push({\nid:\"454be8.c787a418\",\ntype:\"ui_text\",\nz:\"44b6e5c1.60373c\",\ngroup:msg.flow,\norder:3,\nwidth:\"3\",\nheight:\"3\",\nname:\"Working test\",\nlabel:\"Message recieved within last 10 minutes?\",\nformat:\"<font color={{msg.color}} ><i class=\\\"fa fa-circle\\\" style=\\\"font-size:48px;\\\"></i></font>\",\nlayout:\"row-center\",\nx:1230,\ny:360,\nwires:[]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":360,"wires":[["b0ed818d.a637e"]]},{"id":"b0ed818d.a637e","type":"function","z":"4fbdfc79.a0e3d4","name":"counter","func":"msg.payload.push({\nid:\"32db4683.3407aa\",\ntype:\"counter\",\nz:\"44b6e5c1.60373c\",\nname:\"\",\ninit:\"0\",\nstep:\"1\",\nlower:\"\",\nupper:\"\",\nmode:\"increment\",\noutputs:\"1\",\nx:720,\ny:460,\nwires:[[\"480ba7e.d806b58\",\"10183839.4a3418\",\"83b37196.856a\",\"6725370d.b391c8\"]]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":960,"y":360,"wires":[["4327932e.0160ec"]]},{"id":"4327932e.0160ec","type":"function","z":"4fbdfc79.a0e3d4","name":"change: Delete paylolad","func":"msg.payload.push({\nid:\"8b5a275.4eb6fd8\",\ntype:\"change\",\nz:\"44b6e5c1.60373c\",\nname:\"Delete paylolad\",\nrules:[{\"t\":\"delete\",\np:\"payload\",\npt:\"msg\"}],\naction:\"\",\nproperty:\"\",\nfrom:\"\",\nto:\"\",\nreg:false,\nx:500,\ny:240,\nwires:[[\"800b91bd.2cc58\",\"58100134.d8b32\",\"32db4683.3407aa\"]]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1190,"y":360,"wires":[["aea61abb.2a3db8"]]},{"id":"aea61abb.2a3db8","type":"function","z":"4fbdfc79.a0e3d4","name":"trigger: Message stopped","func":"msg.payload.push({\nid:\"480ba7e.d806b58\",\ntype:\"trigger\",\nz:\"44b6e5c1.60373c\",\nname:\"Message stopped\",\nop1:\"\",\nop2:\"0\",\nop1type:\"nul\",\nop2type:\"str\",\nduration:\"1\",\nextend:true,\noverrideDelay:false,\nunits:\"min\",\nreset:\"\",\nbytopic:\"all\",\ntopic:\"topic\",\noutputs:1,\nx:970,\ny:420,\nwires:[[\"e30629ef.5a3d98\"]]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1430,"y":360,"wires":[["b4e296b3.11f0f8"]]},{"id":"b4e296b3.11f0f8","type":"function","z":"4fbdfc79.a0e3d4","name":"ui_text: Total messages","func":"msg.payload.push({\nid:\"10183839.4a3418\",\ntype:\"ui_text\",\nz:\"44b6e5c1.60373c\",\ngroup:msg.flow,\norder:1,\nwidth:0,\nheight:0,\nname:\"Total messages\",\nlabel:\"Total messages:\",\nformat:\"{{msg.count}}\",\nlayout:\"row-spread\",\nx:1260,\ny:520,\nwires:[]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":310,"y":440,"wires":[["e84ca2a.721186"]]},{"id":"e84ca2a.721186","type":"function","z":"4fbdfc79.a0e3d4","name":"file","func":"msg.payload.push({\nid:\"e30629ef.5a3d98\",\ntype:\"file\",\nz:\"44b6e5c1.60373c\",\nname:\"\",\nfilename:\"count\",\nappendNewline:true,\ncreateDir:false,\noverwriteFile:\"true\",\nencoding:\"none\",\nx:1270,\ny:420,\nwires:[[]]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":510,"y":440,"wires":[["c18c90f8.13962"]]},{"id":"c18c90f8.13962","type":"function","z":"4fbdfc79.a0e3d4","name":"ui_text: Current messages","func":"msg.payload.push({\n\"id\":\"abb1f2b1.b383b\",\n\"type\":\"ui_text\",\n\"z\":\"44b6e5c1.60373c\",\n\"group\":msg.flow,\n\"order\":1,\n\"width\":0,\n\"height\":0,\n\"name\":\"Current messages\",\n\"label\":\"Current messages:\",\n\"format\":\"{{msg.count}}\",\n\"layout\":\"row-spread\",\n\"x\":1490,\n\"y\":580,\n\"wires\":[]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":730,"y":440,"wires":[["90fef8d.0695d08"]]},{"id":"90fef8d.0695d08","type":"function","z":"4fbdfc79.a0e3d4","name":"trigger","func":"msg.payload.push({\nid:\"83b37196.856a\",\ntype:\"trigger\",\nz:\"44b6e5c1.60373c\",\nname:\"Message stopped\",\nop1:\"\",\nop2:\"0\",\nop1type:\"nul\",\nop2type:\"str\",\nduration:\"1\",\nextend:true,\noverrideDelay:false,\nunits:\"min\",\nreset:\"\",\nbytopic:\"all\",\ntopic:\"topic\",\noutputs:1,\nx:930,\ny:620,\nwires:[[\"586eece1.8088d4\"]]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":930,"y":440,"wires":[["73df2b77.448164"]]},{"id":"73df2b77.448164","type":"function","z":"4fbdfc79.a0e3d4","name":"change:set msg.reset to true","func":"msg.payload.push({\nid:\"586eece1.8088d4\",\ntype:\"change\",\nz:\"44b6e5c1.60373c\",\nname:\"Reset\",\nrules:[{\"t\":\"set\",\"p\":\"reset\",\"pt\":\"msg\",\"to\":\"true\",\"tot\":\"str\"}],\naction:\"\",\nproperty:\"\",\nfrom:\"\",\nto:\"\",\nreg:false,\nx:1090,\ny:620,\nwires:[[\"6725370d.b391c8\"]]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1140,"y":440,"wires":[["99799dc7.b94ef"]]},{"id":"99799dc7.b94ef","type":"function","z":"4fbdfc79.a0e3d4","name":"counter","func":"msg.payload.push({\nid:\"6725370d.b391c8\",\ntype:\"counter\",\nz:\"44b6e5c1.60373c\",\nname:\"\",\ninit:\"0\",\nstep:\"1\",\nlower:\"\",\nupper:\"\",\nmode:\"increment\",\noutputs:\"1\",\nx:1240,\ny:580,\nwires:[[\"abb1f2b1.b383b\"]]});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1340,"y":440,"wires":[["4dfd954f.68af7c"]]},{"id":"4dfd954f.68af7c","type":"function","z":"4fbdfc79.a0e3d4","name":"Kafka Broker","func":"msg.payload.push({\nid:\"f4c7e5bd.09b818\",\ntype:\"Kafka Broker\",\nname:\"\",\nhosts:[{\"host\":\"kafka\",\"port\":9092}],\nhostsEnvVar:\"\",\nconnectTimeout:\"10000\",\nrequestTimeout:\"30000\",\nautoConnect:\"true\",\nidleConnection:\"5\",\nreconnectOnIdle:\"true\",\nmaxAsyncRequests:\"10\",\ncheckInterval:\"10\",\nselfSign:true,\nusetls:false,\nuseCredentials:false});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1490,"y":440,"wires":[["98f15499.517b28"]]},{"id":"98f15499.517b28","type":"function","z":"4fbdfc79.a0e3d4","name":"ui_group:busStop","func":"msg.payload.push({\n\"id\":msg.flow,\n\"type\":\"ui_group\",\n\"name\":msg.flow,\n\"tab\":\"a65b3274.2fafb\",\n\"order\":1,\n\"disp\":true,\n\"width\":\"6\",\n\"collapse\":false});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":540,"wires":[["842cbca2.bc02e"]]},{"id":"842cbca2.bc02e","type":"function","z":"4fbdfc79.a0e3d4","name":"ui_tab","func":"msg.payload.push({\nid:msg.flow,\ntype:\"ui_tab\",\nname:msg.flow,\nicon:\"dashboard\",\ndisabled:false,\nhidden:false});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":470,"y":540,"wires":[["81705080.fc42d"]]},{"id":"4c0ca569.dc19cc","type":"file in","z":"4fbdfc79.a0e3d4","name":"","filename":"autocompose.yaml","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":710,"y":200,"wires":[["36798317.530d8c"]]},{"id":"36798317.530d8c","type":"python-function","z":"4fbdfc79.a0e3d4","name":"","func":"count = 0\nmsgcount = 0\nlines = []\nwith open(\"autocompose.yaml\") as fp: \n\tfor line in fp: \n\t\tcount += 1\n\t\tcurline = line.strip()\n\t\tif(curline.startswith(\"- KAFKA_TOPIC_OUT=\")):\n\t\t newline = curline[18:]\n\t\t lines.append(newline)\n\t\t msgcount += 1\nmsg['payload'] = lines\nreturn msg \n","outputs":1,"x":940,"y":200,"wires":[["a0b0e9b5.eb3508"]]},{"id":"a0b0e9b5.eb3508","type":"split","z":"4fbdfc79.a0e3d4","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":230,"y":300,"wires":[["8c6f9f44.b79b5"]]},{"id":"8c6f9f44.b79b5","type":"change","z":"4fbdfc79.a0e3d4","name":"","rules":[{"t":"set","p":"flow","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":300,"wires":[["435f421b.24853c"]]}]

```

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [16 December 2020 15:53 UTC](https://discourse.nodered.org/t/deploying-importing-without-pressing-deploy-import/37583/2 "2020-12-16T15:53:45Z")

</div>

I doubt if you want that.  
Sounds like a very handy function for virus builders etc..to take over control.

---

<div class="post-metadata">

**Author:** ![christopherm123](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@christopherm123](https://discourse.nodered.org/u/christopherm123)\
**Post date:** [16 December 2020 15:59 UTC](https://discourse.nodered.org/t/deploying-importing-without-pressing-deploy-import/37583/3 "2020-12-16T15:59:35Z")

</div>

Thank you for the advice, but what I am hoping to create would read a single file and create a flows based on that file, it wouldn't be given to the public so if they wanted to abuse it they would have already had to get into the servers by that point.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 December 2020 16:34 UTC](https://discourse.nodered.org/t/deploying-importing-without-pressing-deploy-import/37583/4 "2020-12-16T16:34:09Z")

</div>

I believe the node-red admin api has capabilities that will do what you want, or at least some of it.

---

<div class="post-metadata">

**Author:** ![christopherm123](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@christopherm123](https://discourse.nodered.org/u/christopherm123)\
**Post date:** [17 December 2020 09:16 UTC](https://discourse.nodered.org/t/deploying-importing-without-pressing-deploy-import/37583/5 "2020-12-17T09:16:04Z")

</div>

Hello, sorry I didn't notice the notification for your message. Is there a good place to learn how to use the API? I have had a look at it and am unsure how it work. Thank you

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 December 2020 10:44 UTC](https://discourse.nodered.org/t/deploying-importing-without-pressing-deploy-import/37583/6 "2020-12-17T10:44:41Z")

</div>

Have you read the documentation? [https://nodered.org/docs/api/](https://nodered.org/docs/api/)

---

<div class="post-metadata">

**Author:** ![christopherm123](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@christopherm123](https://discourse.nodered.org/u/christopherm123)\
**Post date:** [17 December 2020 11:01 UTC](https://discourse.nodered.org/t/deploying-importing-without-pressing-deploy-import/37583/7 "2020-12-17T11:01:11Z")

</div>

Yes, I just had a look at the API and someone explained it to me, I think I understand it now. Thank you for all the help 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [31 December 2020 11:01 UTC](https://discourse.nodered.org/t/deploying-importing-without-pressing-deploy-import/37583/8 "2020-12-31T11:01:18Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
