# Triggering on specific message

**URL:** <https://discourse.nodered.org/t/triggering-on-specific-message/33661>\
**Category:** General\
**Created:** [2 October 2020 08:12 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661 "2020-10-02T08:12:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![varunyc](https://avatars.discourse-cdn.com/v4/letter/v/8dc957/32.png) [@varunyc](https://discourse.nodered.org/u/varunyc)\
**Post date:** [2 October 2020 08:12 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/1 "2020-10-02T08:12:39Z")

</div>

Dear All,

I would like to have a functionality where in I need to run specific flow repeatedly when I receive specific type of message. Please let me know how to handle this in node red.

Is it possible to do this in trigger node. If so please let me know how to do this?

Thanks & Regards  
Varun

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 October 2020 08:23 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/2 "2020-10-02T08:23:03Z")

</div>

a simple example using switch node

```auto
[{"id":"91be1257.55f2","type":"inject","z":"4484ee28.caa3c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"a special message","payloadType":"str","x":210,"y":400,"wires":[["dc2b7cc9.db3fd8"]]},{"id":"187967a.a95e618","type":"inject","z":"4484ee28.caa3c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"not a special message","payloadType":"str","x":220,"y":440,"wires":[["dc2b7cc9.db3fd8"]]},{"id":"dc2b7cc9.db3fd8","type":"switch","z":"4484ee28.caa3c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"a special message","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":400,"wires":[["269a25ff.79887a"]]},{"id":"269a25ff.79887a","type":"debug","z":"4484ee28.caa3c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":590,"y":360,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![varunyc](https://avatars.discourse-cdn.com/v4/letter/v/8dc957/32.png) [@varunyc](https://discourse.nodered.org/u/varunyc)\
**Post date:** [2 October 2020 08:31 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/3 "2020-10-02T08:31:11Z")

</div>

Hi,

Thanks for the response. But how to input specific message to inject node?

Thanks & Regards  
Varun

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 October 2020 08:37 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/4 "2020-10-02T08:37:32Z")

</div>

You don't you remove inject and feed your message into the switch node. The injects where to show what happens with different message values.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 October 2020 08:43 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/6 "2020-10-02T08:43:38Z")

</div>

Post you code between back ticks to make it easy to copy and paste.  
e.g.  
```  
code  
```  
becomes

```auto
code

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 October 2020 08:46 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/8 "2020-10-02T08:46:18Z")

</div>

edit previous by clicking pencil icon, then add back ticks before and after code, on their own line.

> [@Newbies forum/section?](https://discourse.nodered.org/t/newbies-forum-section/3025/14):
>
> For real newbies… How to interact with the forum for nulls like me. blush how to put an image in a post… Simply use the upload icon and drag the file. Or copy the image in the clipboard and paste it in the post. blush How to share code in the forum, a node-red node should be selected first, otherwise the Export menu item may be disabled. and then use Export-\>Clipboard. Then Select, for example, “Current Flow and compact”. And Export to clipboard . [image] Go to your post,…

---

<div class="post-metadata">

**Author:** ![varunyc](https://avatars.discourse-cdn.com/v4/letter/v/8dc957/32.png) [@varunyc](https://discourse.nodered.org/u/varunyc)\
**Post date:** [2 October 2020 08:50 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/9 "2020-10-02T08:50:08Z")

</div>

```auto
[{"id":"e5b745ac.4ac7b8","type":"inject","z":"31a9ecb9.4a4704","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"10 15 * * *","once":false,"onceDelay":0.1,"x":110,"y":860,"wires":[["b80bd9cc.48b1e8"]]},{"id":"b80bd9cc.48b1e8","type":"function","z":"31a9ecb9.4a4704","name":"","func":"msg.payload = \"Another varun happy\";\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":820,"wires":[["b52400a5.2c6a6","e6a98594.c681e8"]]},{"id":"b52400a5.2c6a6","type":"debug","z":"31a9ecb9.4a4704","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":710,"y":820,"wires":[]},{"id":"e6a98594.c681e8","type":"delay","z":"31a9ecb9.4a4704","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":500,"y":940,"wires":[["6a769ec6.b1356"]]},{"id":"6a769ec6.b1356","type":"function","z":"31a9ecb9.4a4704","name":"","func":"msg.payload1 = \"Delay varun happy\";\nmsg.payload = 12;\nmsg.delay=2 * 60000;\nreturn msg;","outputs":1,"noerr":0,"x":650,"y":940,"wires":[["b9992d9b.61344","9fb624dd.a0c388"]]},{"id":"b9992d9b.61344","type":"debug","z":"31a9ecb9.4a4704","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":670,"y":1020,"wires":[]},{"id":"9fb624dd.a0c388","type":"delay","z":"31a9ecb9.4a4704","name":"","pauseType":"delayv","timeout":"3","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":140,"y":760,"wires":[["a2c86b9c.508448"]]},{"id":"a2c86b9c.508448","type":"function","z":"31a9ecb9.4a4704","name":"","func":"msg.payload2 = \"xxxxxxxxx\";\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":740,"wires":[["7af5576e.690058","b80bd9cc.48b1e8"]]},{"id":"7af5576e.690058","type":"debug","z":"31a9ecb9.4a4704","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":740,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![varunyc](https://avatars.discourse-cdn.com/v4/letter/v/8dc957/32.png) [@varunyc](https://discourse.nodered.org/u/varunyc)\
**Post date:** [2 October 2020 08:54 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/10 "2020-10-02T08:54:30Z")

</div>

Hope now your able to copy the code. I wanted to have complete control over variable delay node in my code. That is I want to trigger or stop sending message to subsequent flow based on specific message.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 October 2020 09:02 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/11 "2020-10-02T09:02:17Z")

</div>

Yes to copy flow i can now click copy icon, also no messy code all over thread, maybe you could tidy up the mess?

As to what you are attempting, more info is required as i am not getting it.

---

<div class="post-metadata">

**Author:** ![varunyc](https://avatars.discourse-cdn.com/v4/letter/v/8dc957/32.png) [@varunyc](https://discourse.nodered.org/u/varunyc)\
**Post date:** [2 October 2020 09:07 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/12 "2020-10-02T09:07:18Z")

</div>

Ok Sorry for the messy code. I was trying lot of options.Let me tell my requirement.

Requirement:

1. At specific time inject node will trigger to turn OFF water dispensing system.
2. after 10mins I shall turn it on again the water dispensing system.
3. Step 1 and 2 should repeat till specific time is reached after that it stop looping till next day,

This what I wanted to achieve. I tried using trigger node. Which helps to loop but I was not have any control to stop it after specific time is reached.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 October 2020 09:16 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/13 "2020-10-02T09:16:29Z")

</div>

so how do you turn it on? what device?

---

<div class="post-metadata">

**Author:** ![varunyc](https://avatars.discourse-cdn.com/v4/letter/v/8dc957/32.png) [@varunyc](https://discourse.nodered.org/u/varunyc)\
**Post date:** [2 October 2020 09:19 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/15 "2020-10-02T09:19:40Z")

</div>

> [@E1cid](#):
>
> ```auto
> [{"id":"86ccce84.e6c08","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"fbff5ba2.744b78","type":"trigger","z":"86ccce84.e6c08","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"10","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":290,"y":60,"wires":[["59cc72c8.23504c"]]},{"id":"59cc72c8.23504c","type":"function","z":"86ccce84.e6c08","name":"ON","func":"msg.payload =\"varun\";\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":60,"wires":[["b34c1395.444da","903c65aa.89fa78"]]},{"id":"903c65aa.89fa78","type":"delay","z":"86ccce84.e6c08","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":540,"y":140,"wires":[["ae48183c.56da68"]]},{"id":"e90b8642.0ee058","type":"inject","z":"86ccce84.e6c08","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"*/10 19 * * *","once":false,"onceDelay":0.1,"x":90,"y":60,"wires":[["fbff5ba2.744b78"]]},{"id":"b34c1395.444da","type":"debug","z":"86ccce84.e6c08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":650,"y":60,"wires":[]},{"id":"ae48183c.56da68","type":"function","z":"86ccce84.e6c08","name":"OFF","func":"msg.payload =\"XYZ\";\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":140,"wires":[["fbff5ba2.744b78"]]}]
> 
> ```

I am using Raspberry pi to control device

---

<div class="post-metadata">

**Author:** ![varunyc](https://avatars.discourse-cdn.com/v4/letter/v/8dc957/32.png) [@varunyc](https://discourse.nodered.org/u/varunyc)\
**Post date:** [2 October 2020 09:20 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/16 "2020-10-02T09:20:53Z")

</div>

e.g.

```auto
[{"id":"86ccce84.e6c08","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"fbff5ba2.744b78","type":"trigger","z":"86ccce84.e6c08","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"10","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":290,"y":60,"wires":[["59cc72c8.23504c"]]},{"id":"59cc72c8.23504c","type":"function","z":"86ccce84.e6c08","name":"ON","func":"msg.payload =\"varun\";\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":60,"wires":[["b34c1395.444da","903c65aa.89fa78"]]},{"id":"903c65aa.89fa78","type":"delay","z":"86ccce84.e6c08","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":540,"y":140,"wires":[["ae48183c.56da68"]]},{"id":"e90b8642.0ee058","type":"inject","z":"86ccce84.e6c08","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"*/10 19 * * *","once":false,"onceDelay":0.1,"x":90,"y":60,"wires":[["fbff5ba2.744b78"]]},{"id":"b34c1395.444da","type":"debug","z":"86ccce84.e6c08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":650,"y":60,"wires":[]},{"id":"ae48183c.56da68","type":"function","z":"86ccce84.e6c08","name":"OFF","func":"msg.payload =\"XYZ\";\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":140,"wires":[["fbff5ba2.744b78"]]}]

```

This is what I wanted to achieve along with I wanted to stop further trigger after sometime. To turn ON and OFF I am using raspberry pi. Sorry I am very new to this.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [2 October 2020 09:25 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/17 "2020-10-02T09:25:37Z")

</div>

Before you go too far, could you tidy-up some of the postings above (AKA mess).  
Just use the pencil icon to edit your posts and delete the unformatted listings.  
It will make reading the thread a lot easier for people.

---

<div class="post-metadata">

**Author:** ![varunyc](https://avatars.discourse-cdn.com/v4/letter/v/8dc957/32.png) [@varunyc](https://discourse.nodered.org/u/varunyc)\
**Post date:** [2 October 2020 09:31 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/18 "2020-10-02T09:31:05Z")

</div>

Sorry for lot of messy post as I started using this recently . Now I cleaned it up.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [2 October 2020 09:31 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/19 "2020-10-02T09:31:52Z")

</div>

Thanks - but I think you may have missed one.

---

<div class="post-metadata">

**Author:** ![varunyc](https://avatars.discourse-cdn.com/v4/letter/v/8dc957/32.png) [@varunyc](https://discourse.nodered.org/u/varunyc)\
**Post date:** [2 October 2020 09:41 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/20 "2020-10-02T09:41:33Z")

</div>

FYI : In the code which I pasted in that I haven't used pi node as I am debugging it. Once I am able to control the trigger I shall add gpio node after ON/OFF.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 October 2020 10:07 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/22 "2020-10-02T10:07:50Z")

</div>

try

```auto
[{"id":"61395a9c.5bfb0c","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"355132d6.866d56","type":"function","z":"61395a9c.5bfb0c","name":"turn on water","func":"msg.payload =\"varun\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":710,"y":140,"wires":[["7ebbbd4.b12a344"]]},{"id":"d2f7044f.164028","type":"delay","z":"61395a9c.5bfb0c","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":630,"y":60,"wires":[["355132d6.866d56"]]},{"id":"f4740e08.ff8138","type":"inject","z":"61395a9c.5bfb0c","name":"start time","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"06 11 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"str","x":90,"y":62,"wires":[["85bc7f14.7bd23"]]},{"id":"7ebbbd4.b12a344","type":"debug","z":"61395a9c.5bfb0c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":770,"y":280,"wires":[]},{"id":"feb4da3d.3183a8","type":"inject","z":"61395a9c.5bfb0c","name":"finish time","props":[{"p":"reset","v":"true","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"07 11 * * *","once":false,"onceDelay":0.1,"topic":"","x":160,"y":100,"wires":[["85bc7f14.7bd23"]]},{"id":"85bc7f14.7bd23","type":"trigger","z":"61395a9c.5bfb0c","name":"","op1":"1","op2":"1","op1type":"str","op2type":"str","duration":"-10","extend":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":360,"y":60,"wires":[["6a1eb1ff.550e2"]]},{"id":"6a1eb1ff.550e2","type":"function","z":"61395a9c.5bfb0c","name":"turn off water","func":"msg.payload =\"xyz\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":410,"y":140,"wires":[["d2f7044f.164028","7ebbbd4.b12a344"]]}]

```

---

<div class="post-metadata">

**Author:** ![varunyc](https://avatars.discourse-cdn.com/v4/letter/v/8dc957/32.png) [@varunyc](https://discourse.nodered.org/u/varunyc)\
**Post date:** [2 October 2020 10:21 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/23 "2020-10-02T10:21:54Z")

</div>

Thanks for the response. When I tested it , It is not stooping at finish time in the above flow

---

<div class="post-metadata">

**Author:** ![varunyc](https://avatars.discourse-cdn.com/v4/letter/v/8dc957/32.png) [@varunyc](https://discourse.nodered.org/u/varunyc)\
**Post date:** [2 October 2020 10:29 UTC](https://discourse.nodered.org/t/triggering-on-specific-message/33661/24 "2020-10-02T10:29:48Z")

</div>

Finish node is sending message to trigger node. But it is not stopping. Is there any specific message I need to send to trigger node to understand and stop

[Next page](https://discourse.nodered.org/t/triggering-on-specific-message/33661.md?page=2)
