# Timeout Function for E-Mail Alert

**URL:** <https://discourse.nodered.org/t/timeout-function-for-e-mail-alert/43409>\
**Category:** General\
**Created:** [30 March 2021 15:35 UTC](https://discourse.nodered.org/t/timeout-function-for-e-mail-alert/43409 "2021-03-30T15:35:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FelixHSWT](https://avatars.discourse-cdn.com/v4/letter/f/bc79bd/32.png) [@FelixHSWT](https://discourse.nodered.org/u/FelixHSWT)\
**Post date:** [30 March 2021 15:35 UTC](https://discourse.nodered.org/t/timeout-function-for-e-mail-alert/43409/1 "2021-03-30T15:35:52Z")

</div>

Hello, I recently got into Node-Red and Javascript for a project, most of the stuff I did so far worked well but I am struggling to set up an Email-alert or more specifically the timeout for that alert (in order to not get spammed by Node-Red). The sending of the Email if a condition is met works but I would like to add a timeout that, if the condition is met, it sends the email and then stops the function from running again for x-amount of time (lets say 10 minutes/600000 milliseconds). I would be very thankful if anyone could help me with my problem. Below is the flow for the function i have so far (working e-mail alert without timeout).  
Required Nodes: [node-red-node-email (node) - Node-RED](https://flows.nodered.org/node/node-red-node-email)

```auto
[{"id":"5c52b845.9f7ea8","type":"e-mail","z":"fa544ea.0c724b","server":"smtp.gmail.com","port":"465","secure":true,"tls":true,"name":"","dname":"E-Mail-Out","x":670,"y":940,"wires":[]},{"id":"cf426062.d581c","type":"inject","z":"fa544ea.0c724b","name":"<500 Alarm","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"400","payloadType":"num","x":230,"y":940,"wires":[["bd20c11.581384"]]},{"id":"192561a2.ae71ae","type":"inject","z":"fa544ea.0c724b","name":">=500 kein Alarm","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"600","payloadType":"num","x":240,"y":1000,"wires":[["bd20c11.581384"]]},{"id":"cf430d54.2ff45","type":"debug","z":"fa544ea.0c724b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":1000,"wires":[]},{"id":"bd20c11.581384","type":"function","z":"fa544ea.0c724b","name":"","func":"if (msg.payload < 500)\n{\n msg.payload = 'Value under 500';\n msg.topic = 'Alarm';\n return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":460,"y":960,"wires":[["5c52b845.9f7ea8","cf430d54.2ff45"]]}]

```

---

<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:** [30 March 2021 16:20 UTC](https://discourse.nodered.org/t/timeout-function-for-e-mail-alert/43409/2 "2021-03-30T16:20:15Z")

</div>

Hi Felix, welcome to the forum!

Have you looked at the `trigger` node? It's part of the code nodes. Set it to send the existing msg object, wait for 10 minutes then send nothing.

 ![Screen Shot 2021-03-30 at 12.19.35 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/c/3c5add7665ad3e06c4fc3f2e317e92761a852331.png)

See if that does what you want.

---

<div class="post-metadata">

**Author:** ![FelixHSWT](https://avatars.discourse-cdn.com/v4/letter/f/bc79bd/32.png) [@FelixHSWT](https://discourse.nodered.org/u/FelixHSWT)\
**Post date:** [30 March 2021 19:48 UTC](https://discourse.nodered.org/t/timeout-function-for-e-mail-alert/43409/3 "2021-03-30T19:48:28Z")

</div>

It seems to work now. Thank you so much honestly, I struggled like 8 hours with this issue and tried so much (mainly new import nodes and solving it with javascript). Amazing that I found help here so quickly. Have a great time and thanks again!

---

<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:** [13 April 2021 19:48 UTC](https://discourse.nodered.org/t/timeout-function-for-e-mail-alert/43409/4 "2021-04-13T19:48:54Z")

</div>

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