# Multiple Messages on different outputs with delay

**URL:** <https://discourse.nodered.org/t/multiple-messages-on-different-outputs-with-delay/62911>\
**Category:** General\
**Created:** [21 May 2022 09:59 UTC](https://discourse.nodered.org/t/multiple-messages-on-different-outputs-with-delay/62911 "2022-05-21T09:59:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sahsha](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sahsha/32/43845_2.png) [@sahsha](https://discourse.nodered.org/u/sahsha)\
**Post date:** [21 May 2022 09:59 UTC](https://discourse.nodered.org/t/multiple-messages-on-different-outputs-with-delay/62911/1 "2022-05-21T09:59:39Z")

</div>

Help! I need to get output with delay for each msg.

```auto
var msg1 = { payload:"first out of output 1" };
var msg2 = { payload:"second out of output 1" };
var msg3 = { payload:"third out of output 1" };
var msg4 = { payload:"only message from output 2" };
return [[ msg1, msg2, msg3], msg4 ];

```

Will it work like this 👇. Tried but didn't worked 🤷‍♂️

```auto
var msg1 = { payload:"first out of output 1" };
var msg2 = { payload:"second out of output 1" };
var msg3 = { payload:"third out of output 1" };
var msg4 = { payload:"only message from output 2" };
[ 
    [ 
      setTimeout(function(){node.send(msg1);},1000), 
      setTimeout(function(){node.send(msg2);},2000), 
      setTimeout(function(){node.send(msg3);},3000) 
     ], 
      setTimeout(function(){node.send(msg4);},4000) 
];

```

---

<div class="post-metadata">

**Author:** ![sahsha](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sahsha/32/43845_2.png) [@sahsha](https://discourse.nodered.org/u/sahsha)\
**Post date:** [21 May 2022 10:20 UTC](https://discourse.nodered.org/t/multiple-messages-on-different-outputs-with-delay/62911/2 "2022-05-21T10:20:43Z")

</div>

Found one alternate with delay node. But I want to achieve it in **function node**.

> [@Delay inside function node between messages?](https://discourse.nodered.org/t/delay-inside-function-node-between-messages/3736/5):
>
> This should do what you want, using just the delay node. [{"id":"55680c13.4953a4","type":"debug","z":"7920414b.cfa4f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":650,"y":120,"wires":[]},{"id":"85c8db46.a1272","type":"function","z":"7920414b.cfa4f8","name":"","func":"// msg.delay is in milliseconds\nvar msg1 = { payload:\"first out of output 1\", delay:10000 };\n// if msg.delay is undefined, the delay node uses default\nvar msg2 = { payload:\"…

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [21 May 2022 10:24 UTC](https://discourse.nodered.org/t/multiple-messages-on-different-outputs-with-delay/62911/3 "2022-05-21T10:24:19Z")

</div>

> [@sahsha](#):
>
> ```auto
> var msg1 = { payload:"first out of output 1" };
> var msg2 = { payload:"second out of output 1" };
> var msg3 = { payload:"third out of output 1" };
> var msg4 = { payload:"only message from output 2" };
> [ 
> [ 
> setTimeout(function(){node.send(msg1);},1000), 
> setTimeout(function(){node.send(msg2);},2000), 
> setTimeout(function(){node.send(msg3);},3000) 
> ], 
> setTimeout(function(){node.send(msg4);},4000) 
> ];
> 
> ```

try...

```auto
var msg1 = { payload:"first out of output 1" };
var msg2 = { payload:"second out of output 1" };
var msg3 = { payload:"third out of output 1" };
var msg4 = { payload:"only message from output 2" };
setTimeout(function(){node.send([msg1,null]);},1000), 
setTimeout(function(){node.send([msg2,null]);},2000), 
setTimeout(function(){node.send([msg3,null]);},3000) 
setTimeout(function(){node.send([null,msg4]);},4000) 

```

Though to be honest, this kinda misses the point of a visual flow designer and low-code!

---

<div class="post-metadata">

**Author:** ![sahsha](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sahsha/32/43845_2.png) [@sahsha](https://discourse.nodered.org/u/sahsha)\
**Post date:** [21 May 2022 10:34 UTC](https://discourse.nodered.org/t/multiple-messages-on-different-outputs-with-delay/62911/4 "2022-05-21T10:34:00Z")

</div>

Thankyou 👍

This will help me organize my flows better 😅

> [@Steve-Mcl](#):
>
> Though to be honest, this kinda misses the point of a visual flow designer and low-code!

---

<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:** [4 June 2022 10:34 UTC](https://discourse.nodered.org/t/multiple-messages-on-different-outputs-with-delay/62911/5 "2022-06-04T10:34:30Z")

</div>

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