# Trigger node - how to delay and repeat message?

**URL:** <https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117>\
**Category:** General\
**Created:** [24 January 2023 11:34 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117 "2023-01-24T11:34:30Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![OliverWieland](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oliverwieland/32/74937_2.png) [@OliverWieland](https://discourse.nodered.org/u/OliverWieland)\
**Post date:** [24 January 2023 11:34 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/1 "2023-01-24T11:34:30Z")

</div>

Hi!  
I want to set a trigger node to do the following:

- On message do nothing
- Send the received message every 10 seconds, until the reset criteria is fulfilled.

So I set "Send" to "nothing" and "then" to "resend it every".  
But when "Send" is set to "nothing", then the message is not sent at all.

Is there an issue with the trigger node?

Node Red V3.0.2

---

<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:** [24 January 2023 11:48 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/2 "2023-01-24T11:48:07Z")

</div>

well it's doing what its says... sending nothing then resending it (nothing) every 10 seconds...

---

<div class="post-metadata">

**Author:** ![OliverWieland](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oliverwieland/32/74937_2.png) [@OliverWieland](https://discourse.nodered.org/u/OliverWieland)\
**Post date:** [24 January 2023 11:51 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/3 "2023-01-24T11:51:16Z")

</div>

But that makes not really sense... 😉  
Wouldn't it be better to have the same possibilities on the "repeat" option than on the "delay" option?

---

<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:** [24 January 2023 12:09 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/4 "2023-01-24T12:09:51Z")

</div>

they are exactly the same options... you picked the nothing option ???  
the first boxes selects what to send - the second modifies how often.  
(I understand that it isn't really useful - but is what it is currently)  
I guss you could add a delay node afterwards set to 10 secs - and then set this to send existing message . And wire a msg.reset to both to stop them both at the same time.

---

<div class="post-metadata">

**Author:** ![OliverWieland](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oliverwieland/32/74937_2.png) [@OliverWieland](https://discourse.nodered.org/u/OliverWieland)\
**Post date:** [24 January 2023 12:29 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/5 "2023-01-24T12:29:08Z")

</div>

> [@dceejay](#):
>
> they are exactly the same options...

No, there are not.If I select "then" -\> "delay", I can determine what to be sent after the delay.  
With "then" -\> "repeat" I can't do this.

> [@dceejay](#):
>
> I guss you could add a delay node afterwards set to 10 secs - and then set this to send existing message

This is exactly what I've done as a workaround. But as I wrote: This is a workaround...

In my opinion it should not be possible to set any option combinations that does not make any sense.

So either, when "Send" is set to "nothing", the "Then" option "repeat" should not be able to be selected,  
or the node should provide the same possibilities for "repeat" than for "delay".

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [24 January 2023 13:21 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/6 "2023-01-24T13:21:53Z")

</div>

Instead of "repeat" use send nothing then send the original object, and feed the output back in to the trigger.

 ![Untitled 2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/e/3e39b3e44197e68a8d1c97eab23deaa13a1b3894.jpeg)

```auto
[{"id":"ef0c1e44b782a74a","type":"inject","z":"8964ba134d837e40","name":"reset","props":[{"p":"reset","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":300,"wires":[["4d9ef966df4f2c83"]]},{"id":"4d9ef966df4f2c83","type":"trigger","z":"8964ba134d837e40","name":"","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"2","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":380,"y":340,"wires":[["59fec3c4ee08c090","09aab31e6cc795f9"]]},{"id":"59fec3c4ee08c090","type":"debug","z":"8964ba134d837e40","name":"debug 242","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":340,"wires":[]},{"id":"b4d8ad15b1b6e7c8","type":"inject","z":"8964ba134d837e40","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":340,"wires":[["4d9ef966df4f2c83"]]},{"id":"09aab31e6cc795f9","type":"junction","z":"8964ba134d837e40","x":380,"y":400,"wires":[["4d9ef966df4f2c83"]]}]

```

I don't like making a loop. Make sure you don't inject multiple messages without resetting.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [24 January 2023 13:45 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/7 "2023-01-24T13:45:54Z")

</div>

This is safer

```auto
[{"id":"4d9ef966df4f2c83","type":"trigger","z":"8964ba134d837e40","name":"","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"2","extend":false,"overrideDelay":false,"units":"s","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":480,"y":420,"wires":[["59fec3c4ee08c090","09aab31e6cc795f9"]]},{"id":"59fec3c4ee08c090","type":"debug","z":"8964ba134d837e40","name":"debug 242","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":420,"wires":[]},{"id":"b4d8ad15b1b6e7c8","type":"inject","z":"8964ba134d837e40","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Repeat Me","payloadType":"str","x":140,"y":420,"wires":[["6f60abcff3602b66"]]},{"id":"6f60abcff3602b66","type":"trigger","z":"8964ba134d837e40","name":"reset first","op1":"reset","op2":"","op1type":"str","op2type":"pay","duration":"250","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":300,"y":420,"wires":[["4d9ef966df4f2c83"]]},{"id":"1fe88636074727ed","type":"inject","z":"8964ba134d837e40","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"And Me","payloadType":"str","x":150,"y":460,"wires":[["6f60abcff3602b66"]]},{"id":"09aab31e6cc795f9","type":"junction","z":"8964ba134d837e40","x":480,"y":460,"wires":[["4d9ef966df4f2c83"]]}]

```

---

<div class="post-metadata">

**Author:** ![OliverWieland](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oliverwieland/32/74937_2.png) [@OliverWieland](https://discourse.nodered.org/u/OliverWieland)\
**Post date:** [24 January 2023 17:37 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/8 "2023-01-24T17:37:22Z")

</div>

Thank you.  
But that doesn't change the fact that, in my opinion, the current configuration doesn't meet the standards I expect from a good UX.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [24 January 2023 18:14 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/9 "2023-01-24T18:14:53Z")

</div>

Fair enough.  
It seems obvious that the trigger node setup like this will send "congratulations" every 10 seconds.

 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1d4ae2ef0f38dc7de15cc1131a8c7a8ef99c9818.jpeg)

I wouldn't expect any different behaviour if the first message sent was 'nothing' rather than a string.  
I have never actually had a need for the "resend" option.

Your opinion is as good as mine though.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [24 January 2023 21:24 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/10 "2023-01-24T21:24:55Z")

</div>

> [@jbudd](#):
>
> I have never actually had a need for the "resend" option

I never knew it even existed 🙂

---

<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:** [25 January 2023 11:03 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/11 "2023-01-25T11:03:20Z")

</div>

PR raised to remove the repeat option when "nothing" is selected.

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [25 January 2023 23:04 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/12 "2023-01-25T23:04:18Z")

</div>

Are you sure this is what @OliverWieland was proposing?

---

<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:** [26 January 2023 00:15 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/13 "2023-01-26T00:15:20Z")

</div>

I suspect that @OliverWieland was hoping to have a second message (equal to the first) sent at specified intervals after a wait time. This is not currently possible, but it seems like a reasonable use case and consistent with the intended use of the node.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [26 January 2023 00:22 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/14 "2023-01-26T00:22:18Z")

</div>

If the repeat option were to increment msg.repeatcount, he could use a switch node to ignore the first iteration.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [26 January 2023 07:26 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/15 "2023-01-26T07:26:50Z")

</div>

It would make it more clear I guess. If you set it to 'nothing' it would repeat 'nothing'

Instead I would use something like:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/35fbaf9c0a2cddbde9030d141d5f018e8b519e21.png)

Or add an option to the trigger node with some logic attached, if nothing selected then add option: `resend last msg every...` ?

---

<div class="post-metadata">

**Author:** ![OliverWieland](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oliverwieland/32/74937_2.png) [@OliverWieland](https://discourse.nodered.org/u/OliverWieland)\
**Post date:** [26 January 2023 08:39 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/16 "2023-01-26T08:39:14Z")

</div>

Thank you all for your suggestions. I know there are a lot of possibilities to solve my problem.

However, the main reason for my post was the fact that the trigger node can currently be parameterized to do nothing, and that makes absolutely no sense from a user perspective.  
If that's the intention, then it should at least be clearly mentioned in the documentation. However, it would be better to either remove these settings or change the behavior so that the setting makes sense.  
Personally, I would lean towards the second option.

---

<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:** [26 January 2023 09:37 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/17 "2023-01-26T09:37:11Z")

</div>

... however - I have chosen to implement the first. The PR removes the option to repeat sending nothing (which we all agree makes no sense).

---

<div class="post-metadata">

**Author:** ![OliverWieland](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oliverwieland/32/74937_2.png) [@OliverWieland](https://discourse.nodered.org/u/OliverWieland)\
**Post date:** [26 January 2023 09:44 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/18 "2023-01-26T09:44:08Z")

</div>

Thank you. This makes the functionality more clear for the user, and that is exactly what I intended 🙂

---

<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:** [27 March 2023 09:44 UTC](https://discourse.nodered.org/t/trigger-node-how-to-delay-and-repeat-message/74117/19 "2023-03-27T09:44:39Z")

</div>

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