# How can i build a random delayed trigger loop?

**URL:** <https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912>\
**Category:** General\
**Created:** [12 October 2018 07:34 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912 "2018-10-12T07:34:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarkusR](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/markusr/32/2934_2.png) [@MarkusR](https://discourse.nodered.org/u/MarkusR)\
**Post date:** [12 October 2018 07:34 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/1 "2018-10-12T07:34:25Z")

</div>

hello,  
i have the intention to fill a chart with random data.  
it shall simulate if people done a task it appear in a chart.  
i have no sucecss with inject & delay node. (at least my chart looks linear slope)  
i need a trigger that send a message random between 1-10 minutes and after the delay  
it create a new random delay and send new message all day long.

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [12 October 2018 07:58 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/2 "2018-10-12T07:58:12Z")

</div>

Try this 🙂

`[{"id":"5e55e393.3c7b3c","type":"delay","z":"6c2991c6.f2285","name":"","pauseType":"delayv","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"5","randomLast":"10","randomUnits":"seconds","drop":false,"x":520,"y":360,"wires":[["c4c706c8.3fa4c8","a0367298.d3914"]]},{"id":"7abe9d2b.6ca824","type":"inject","z":"6c2991c6.f2285","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":300,"y":300,"wires":[["a0367298.d3914"]]},{"id":"c4c706c8.3fa4c8","type":"debug","z":"6c2991c6.f2285","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":730,"y":360,"wires":[]},{"id":"a0367298.d3914","type":"change","z":"6c2991c6.f2285","name":"","rules":[{"t":"set","p":"delay","pt":"msg","to":"$floor($random()*600000)","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"$floor($random()*10)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":300,"wires":[["5e55e393.3c7b3c"]]}]`

---

<div class="post-metadata">

**Author:** ![MarkusR](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/markusr/32/2934_2.png) [@MarkusR](https://discourse.nodered.org/u/MarkusR)\
**Post date:** [12 October 2018 08:22 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/3 "2018-10-12T08:22:08Z")

</div>

thank you, i build it in

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [12 October 2018 19:34 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/4 "2018-10-12T19:34:42Z")

</div>

Nice, but I would suggest a reset input, just in case you don't really want it to run forever.

```auto
[{"id":"81fa9f84.c2ef3","type":"change","z":"f3a075a0.2b2ae","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":120,"wires":[["3fac4536.38e1d2"]]},{"id":"3fac4536.38e1d2","type":"delay","z":"f3a075a0.2b2ae","name":"","pauseType":"delayv","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"5","randomLast":"10","randomUnits":"seconds","drop":false,"x":540,"y":120,"wires":[["3d9011e2.9a279e","3888711f.dad256"]]},{"id":"16d5b50f.05f7bb","type":"inject","z":"f3a075a0.2b2ae","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":60,"wires":[["3888711f.dad256"]]},{"id":"3d9011e2.9a279e","type":"debug","z":"f3a075a0.2b2ae","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":770,"y":120,"wires":[]},{"id":"3888711f.dad256","type":"change","z":"f3a075a0.2b2ae","name":"","rules":[{"t":"set","p":"delay","pt":"msg","to":"$floor($random()*600000)","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"$floor($random()*10)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":60,"wires":[["3fac4536.38e1d2"]]},{"id":"aad6f390.80961","type":"inject","z":"f3a075a0.2b2ae","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":120,"wires":[["81fa9f84.c2ef3"]]}]
``
```

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [12 October 2018 19:56 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/5 "2018-10-12T19:56:35Z")

</div>

I just tried to stay in scope of issue. For full solution I think there is much more needed of course.

---

<div class="post-metadata">

**Author:** ![MarkusR](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/markusr/32/2934_2.png) [@MarkusR](https://discourse.nodered.org/u/MarkusR)\
**Post date:** [13 October 2018 07:01 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/6 "2018-10-13T07:01:31Z")

</div>

thanks for the reset hint.

my current solution:

> [{"id":"3716c275.fcba66","type":"subflow","name":"jobs simulation","info":"","category":"","in":[{"x":100,"y":120,"wires":[{"id":"d8b4ec33.0ea608"}]}],"out":[{"x":1180,"y":240,"wires":[{"id":"b93c39d1.206018","port":0}]}]},{"id":"b93c39d1.206018","type":"delay","z":"3716c275.fcba66","name":"","pauseType":"random","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"5","randomLast":"45","randomUnits":"seconds","drop":false,"x":980,"y":240,"wires":[["d8b4ec33.0ea608"]]},{"id":"d8b4ec33.0ea608","type":"delay","z":"3716c275.fcba66","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":240,"y":120,"wires":[["e1e866a1.ee1a"]]},{"id":"cf70b3a4.37554","type":"function","z":"3716c275.fcba66","name":"working hours","func":"var d = new Date();\nvar h = d.getHours();\nif (msg.do=="yes") {\n if (h\>=8 && h\<=17){\n } else {\n msg.do=="no" \n }\n}\nreturn msg;\n","outputs":1,"noerr":0,"x":600,"y":260,"wires":[["2330084b.7b17d"]]},{"id":"e1e866a1.ee1a","type":"function","z":"3716c275.fcba66","name":"work days","func":"var d = new Date();\n// 0 Sunday\n// 1 Monday\n// 2 Tuesday\n// 3 Wednesday\n// 4 Thursday\n// 5 Friday\n// 6 Saturday\nvar day = d.getDay();\nif (day\>=1 && day\<=6){\n msg.do="yes";\n} else {\n msg.do="no";\n}\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":260,"wires":[["cf70b3a4.37554"]]},{"id":"2330084b.7b17d","type":"switch","z":"3716c275.fcba66","name":"","property":"do","propertyType":"msg","rules":[{"t":"eq","v":"no","vt":"str"},{"t":"eq","v":"yes","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":770,"y":260,"wires":[["d8b4ec33.0ea608"],["b93c39d1.206018"]],"outputLabels":["no","yes"]},{"id":"33cd4306.9cbb14","type":"comment","z":"3716c275.fcba66","name":"jobs simulation","info":"created by M.Rauch 10/2018\n\nit have a clock\nthen the work days are checked\nthen the working hours are checked\nif not at work the clock ticks\nif at work then the delay simulate a task\n","x":120,"y":40,"wires":}]

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [2 November 2018 21:49 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/7 "2018-11-02T21:49:43Z")

</div>

In case anyone is still interested, this flow will generate the sort of random events that @MarkusR wants, using only a single `function` node and no feedback loop. It also illustrates what a pain JavaScript can be (at least for me) when what you want is synchronous execution. I was already working on something similar, so it was worth the effort, but if anyone can suggest less ugly code I would be grateful.

```auto
[{"id":"13c7f4da.98d3bb","type":"function","z":"9b4deac7.469e4","name":"","func":"const minDelay = 1, maxDelay =5; // seconds\nvar run = context.get('state') || false;\nif (msg.topic.toLowerCase() === 'control') {\n run = ! run;\n}\ncontext.set('state',run);\nnode.status({fill:(run) ? 'green':'red'});\nif (run) {\n randomDelay(maxDelay,minDelay);\n node.status({fill:'green',text:delay.toFixed(2)});\n}\n\nfunction randomDelay(max,min) {\n delay = Math.random() * (max - min) + min;\n setTimeout(sendMessages,1000 * delay);\n msg.delay = delay;\n return delay;\n}\n\nfunction sendMessages() {\n node.send(msg);\n run = context.get('state');\n if (run) {\n randomDelay(maxDelay,minDelay);\n node.status({fill:'green',text:delay.toFixed(2)});\n }\n}\n","outputs":1,"noerr":0,"x":530,"y":500,"wires":[["f2d3395f.8d1ad8"]]},{"id":"48ab97b.5d78868","type":"inject","z":"9b4deac7.469e4","name":"start/stop","topic":"control","payload":"random trigger","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":400,"y":500,"wires":[["13c7f4da.98d3bb"]]},{"id":"f2d3395f.8d1ad8","type":"debug","z":"9b4deac7.469e4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":650,"y":500,"wires":[]}]

```

---

<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:** [3 November 2018 07:20 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/8 "2018-11-03T07:20:57Z")

</div>

Here is a way of refactoring the loop to make it a bit neater.

```auto
[{"id":"f6d5dfd7.84ec5","type":"function","z":"6dc690a3.1abc88","name":"","func":"const minDelay = 1, maxDelay =5; // seconds\nvar run = context.get('state') || false;\nif (msg.topic.toLowerCase() === 'control') {\n run = ! run;\n}\ncontext.set('state',run);\nnode.status({fill:(run) ? 'green':'red'});\n\nvar msgToSend = null;\nloop();\nreturn null;\n\nfunction loop() {\n if (context.get('state')) {\n node.send(msgToSend);\n msgToSend = msg;\n let delay = Math.random() * (maxDelay - minDelay) + minDelay;\n setTimeout(loop,1000 * delay);\n node.status({fill:'green',text:delay.toFixed(2)});\n }\n}\n","outputs":1,"noerr":0,"x":320,"y":209,"wires":[["9e9ea6e4.a82078"]]},{"id":"7defb913.a1ebe","type":"inject","z":"6dc690a3.1abc88","name":"start/stop","topic":"control","payload":"random trigger","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":209,"wires":[["f6d5dfd7.84ec5"]]},{"id":"9e9ea6e4.a82078","type":"debug","z":"6dc690a3.1abc88","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":440,"y":209,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [3 November 2018 07:29 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/9 "2018-11-03T07:29:33Z")

</div>

also posted here [HTTP GET request for data and post to website](https://discourse.nodered.org/t/http-get-request-for-data-and-post-to-website/4520?u=ukmoose)

---

<div class="post-metadata">

**Author:** ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)\
**Post date:** [3 November 2018 12:44 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/10 "2018-11-03T12:44:34Z")

</div>

> [@drmibell](#):
>
> ... but if anyone can suggest less ugly code I would be grateful.

You could use a dsm node:

```auto
[{"id":"a26cd0b7.90aef","type":"dsm","z":"66646ca8.e97654","name":"random trigger","sm_config":"{\n \"currentState\": \"stopped\",\n \"states\": {\n \"stopped\": {\n \"start\": \"running\"\n },\n \"running\": {\n \"running\": \"running\",\n \"stop\": \"stopped\"\n }\n },\n \"data\": {\n \"minDelay\": 1,\n \"maxDelay\": 5\n },\n \"methods\": {\n \"start\": [\n \"resume('running', msg);\"\n],\n \"running\": [\n \"sm.delay = Math.random() * (sm.data.maxDelay - sm.data.minDelay) + sm.data.minDelay;\",\n \"msg.delay = 'delay '+ sm.delay.toFixed(2);\",\n \"timeout.delay = setTimeout(function() {\",\n \" node.send(msg);\",\n \" resume('running',msg);\",\n \"},sm.delay*1000);\"\n],\n \"stop\": [\n \"clearTimeout(timeout.delay);\",\n \"msg.delay = 'stopped';\"\n],\n \"onTransition\": [\n \"output = false;\"\n],\n \"status\": {\n \"fill\": {\n \"get\": \"sm.currentState === 'running' ? 'green' : 'red';\"\n },\n \"shape\": \"dot\",\n \"text\": {\n \"get\": \"msg.delay;\"\n }\n }\n }\n}","x":330,"y":320,"wires":[["fdb8b530.787a38"]]},{"id":"c78a24cc.f507f8","type":"inject","z":"66646ca8.e97654","name":"start","topic":"start","payload":"random trigger","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":320,"wires":[["a26cd0b7.90aef"]]},{"id":"fdb8b530.787a38","type":"debug","z":"66646ca8.e97654","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":490,"y":320,"wires":[]},{"id":"894976da.9dfca8","type":"inject","z":"66646ca8.e97654","name":"stop","topic":"stop","payload":"random trigger","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":360,"wires":[["a26cd0b7.90aef"]]}]

```

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [4 November 2018 17:13 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/11 "2018-11-04T17:13:29Z")

</div>

@Colin, thanks! That certainly is neater -- and just the sort of help I'll need if I am ever going to get really comfortable with JavaScript. I have coded in at least a dozen high-level languages since the mid-1970's, and JS may not be the most difficult or opaque, but somehow I find it the most annoying...

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [4 November 2018 19:20 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/12 "2018-11-04T19:20:05Z")

</div>

@cflurin That's a really nice solution to the problem. At one time, finite state machines were my bread and butter, so I've looked for opportunities to use your node. Unfortunately, I haven't done much with it for a couple of reasons. One is the learning curve associated with the JSON objects used for programming the node, and the other is that in debugging it is sometimes hard to see the connection between JS error messages and syntax errors in the configuration. I think I will give it another try.

BTW, have you considered developing an edit window that would let the user define the states and transition table with text entry boxes and pull-down menus? Perhaps actions could then be entered simply as blocks of JS code. All this would still be translated into JSON in the background, but the ui might be more accessible to a beginner.

---

<div class="post-metadata">

**Author:** ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)\
**Post date:** [5 November 2018 09:20 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/13 "2018-11-05T09:20:55Z")

</div>

@drmibell: Thanks for your feedback, your answer is dsm specific, so I moved to node-red-contrib-dsm [Node-red-contrib-dsm](https://discourse.nodered.org/t/node-red-contrib-dsm/1388)

---

<div class="post-metadata">

**Author:** ![eugene](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@eugene](https://discourse.nodered.org/u/eugene)\
**Post date:** [3 January 2020 14:58 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/14 "2020-01-03T14:58:23Z")

</div>

Hi Guys,

All solution looks cool, but could someone improvised such that, it always run? no need manual intervention?  
I did something like this:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a7d57490985005d06ca9d426998dd49c32d770c5.png)  
But it would go haywire/crazy when I click multiple time on inject. And I do not want the possibility of accidentally turn delay off.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [6 January 2020 16:39 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/15 "2020-01-06T16:39:15Z")

</div>

I'm not certain exactly what issue you are having, but I suggest that instead of the `function` node you use [node-red-contrib-random-event-generator](https://flows.nodered.org/node/node-red-contrib-random-event-generator), which has the same functionality. This flow will start generating triggers at random intervals as soon as it is deployed.

```auto
[{"id":"11bbb517.23d813","type":"event","z":"2f7c2f6d.c20a68","name":"","controlTopic":"control","meanInterval":1,"distribution":"exponential","minInterval":1,"maxInterval":2,"outputTopic":"event","outputPayload":"timestamp","x":630,"y":620,"wires":[["c3a06c28.eb70f8"]]},{"id":"c3a06c28.eb70f8","type":"debug","z":"2f7c2f6d.c20a68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":620,"wires":[]},{"id":"396c67a0.a60bc8","type":"inject","z":"2f7c2f6d.c20a68","name":"start/stop","topic":"control","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":500,"y":620,"wires":[["11bbb517.23d813"]]}]

```

To prevent accidental shutoffs, you can disable the `inject` node, although it is probably a good idea to be able to stop the generator if necessary. (Apparently, once the `inject` node is disabled the flow must be re-deployed to enable it.) I hope that helps.

---

<div class="post-metadata">

**Author:** ![eugene](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@eugene](https://discourse.nodered.org/u/eugene)\
**Post date:** [6 January 2020 23:53 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/16 "2020-01-06T23:53:29Z")

</div>

Thank you, i think this is what I am looking for. Without inject node, this will run indefinitely??  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/0136752ced50e3fe47d6d0b6f41cb456b77d3949.png)

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [9 January 2020 18:34 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/17 "2020-01-09T18:34:17Z")

</div>

> [@eugene](#):
>
> Without inject node, this will run indefinitely?

No, the random event generator is designed to be stopped when it is first deployed. This prevents messages from flowing before other nodes in the flow are ready to handle them. The flow I posted above will start to run as soon as it is deployed, thanks to the way the `inject` node is configured. (You can even program a delay, if you want.)

If your application absolutely demands that you not use an `inject` node, it may be possible to modify `node-red-contrib-random-event-generator` so that it has an option to start running immediately as soon as it is deployed. If that can be done, I will need some time to test and document the changes. If you raise an issue on [GitHub](https://github.com/drmibell/node-red-contrib-random-event-generator/issues), it will help me track the work.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [9 January 2020 19:33 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/18 "2020-01-09T19:33:57Z")

</div>

If you do add an option to autostart, then you should also then remove the input pin as it’s no longer needed.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [9 January 2020 19:44 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/19 "2020-01-09T19:44:20Z")

</div>

> [@dceejay](#):
>
> remove the input pin

Actually, it's still needed in case the user wants to stop the generator.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [9 January 2020 19:45 UTC](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912/20 "2020-01-09T19:45:30Z")

</div>

So using an inject to start it is not unreasonable (as that is what is designed to do)

[Next page](https://discourse.nodered.org/t/how-can-i-build-a-random-delayed-trigger-loop/3912.md?page=2)
