Extension: trigger node


I use the example below quite a lot when monitoring that my external services are a live and running. Without going into details of this special service, I wonder if it would be a good option for the trigger to being able to resend the out message to it's input?

The example below works as follow:

  • the external (Weather) service is expected to deliver required data at some defined interval to a mqtt topic
  • if this fails, the trigger node restarts the service and informs the user (me) that this has happened via Telegram

Now, if the restart would fail, a second service restart attempt would not happen so there's the reason for the function node passing the output message back to the input. Restarts would then continue (forever) until the service starts & runs properly again

The function node is just the default, returning the incoming msg



Interesting question. So the point is that you wanted to do the same without using the function node and possibly adding this as a optional feature in the node. I am not sure if such new capability would be feasible. How about using link nodes like below ?

PS: in your flow you already uses an input link. You just need one more for the loop :grin:


Given the simplicity of the link feedback vs the myriad of possible options that "opening up" the node config could offer I'm tempted to not touch it...


Yes, the linking is of course the most efficient way but using a "dummy" function node gives maybe a more clearer view of what is happening, a "tunnel" node just passing the same message is what is meant. Many ways doing the same, I just thought is was in the trigger node such a thing could eventually belong, and maybe also in the delay node but I respect of course the important concerns regarding unwanted myriads :wink:


@krambriw, I think the node-red-contrib-msg-resend node can be configured to do what you want. This flow might come close. (I've added some control so that it doesn't run forever while you experiment with it.)


How often do you use the trigger node this way?

If this is a single use case, than @Andrei proposal is the perfect solution.

Otherwise the node-red-contrib-dsm node can do it in a single node.
If you'd like to try it, I'll post the dsm solution.


Thank you all, very interesting discussion as always!

With NR, so many possible ways to solve tasks. Another one not (yet) possible would be if it was allowed to connect the output with the input directly (under the hood, NR could anyway use, in such case, hidden links).

I use this setup to monitor external services that are running "outside" of NR. In my little Home Automation system I have in total 7 RPi's and one Lenovo Laptop (for the purpose getting really fast DNN video analytics), all integrated via MQTT. Reason for this "massive" amount of distributed Pi's, why is something I sometimes question myself, is mainly "easier to connect wireless than installing a lot of cables"

In all of those computers I have one or more Python scripts that are fully monitored & restarted in this way if required. Thanks to NR!

Anyway, for now I think I just keep the configuration as is, using function nodes, but when I make a major revision, I will change into using links I think

Best regards, Walter


If you want to use the core nodes, I'd use a switch instead of a function node:



He's already using link nodes on the output ... so already has half the solution :slight_smile:


Sure! One thing I'm missing is a logic to stop the infinity loop.


Yes, all great possibilities. To add-on a logic that breaks the loop after x nbr's of attempts (using a join node) and if that doesn't help, the next action would eventually be a reboot. Also added a one-time trigger at the initial startup just "to get things going" again

EDIT: in the example below I can of course not reset the counter inside the join node (such method is not available) but I think I can live with that. If the counter starts to count up, a reboot might not be too bad


This feature is built in in my dsm-node solution :wink:
I'll add this use case to the dsm Wiki soon.


Just added the watchdog flow to the dsm Wiki Watchdog


I hope, it can help simplify the logic.