# How to add data to a message with different send times?

**URL:** <https://discourse.nodered.org/t/how-to-add-data-to-a-message-with-different-send-times/72731>\
**Category:** General\
**Tags:** function-node\
**Created:** [26 December 2022 15:06 UTC](https://discourse.nodered.org/t/how-to-add-data-to-a-message-with-different-send-times/72731 "2022-12-26T15:06:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![namexx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/namexx/32/72976_2.png) [@namexx](https://discourse.nodered.org/u/namexx)\
**Post date:** [26 December 2022 15:06 UTC](https://discourse.nodered.org/t/how-to-add-data-to-a-message-with-different-send-times/72731/1 "2022-12-26T15:06:32Z")

</div>

Hello I have to send a msg.payload that I need to add data with different send times.

Because i send data to server every 3 seconds and i need include all data in one message.

Example:

> message1 ="hi1"; //this message should be added every 3 seconds  
> message2 ="hi2"; //this message should be added every 6 seconds  
> message3 ="hi3";//this message should be added every 9 seconds
> 
> pseudo Code
> 
> if(message1.Time\>=3){msg.payload=msg.payload+message1;}  
> if(message2.Time\>=6){msg.payload=msg.payload+message2;}  
> if(message1.Time\>=9){msg.payload=msg.payload+message9;}
> 
> return msg;

---

<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 December 2022 17:32 UTC](https://discourse.nodered.org/t/how-to-add-data-to-a-message-with-different-send-times/72731/2 "2022-12-26T17:32:36Z")

</div>

Your requirements to "include all data in one message" and "send data every 3 seconds" are conflicting.

After 3 seconds "hi1\_1" message has arrived. Should you wait until "h2\_1" and "hi3\_1" arrive or send it without? If waiting, what do you want to do with "h1\_2" and "h1\_3"?

Is duplicated output data acceptable?  
At 12 seconds a "hi1\_4" message and "hi2\_2" message arrive - NOT precisely simultaneously.  
Sould you send  
"hi1\_4", "hi2\_1", "hi3\_1"  
then  
"hi1\_4", "hi2\_2", "hi3\_1"

Hmm. Given the season, should it be ho1, ho2, ho3? 😀

---

<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:** [24 February 2023 17:33 UTC](https://discourse.nodered.org/t/how-to-add-data-to-a-message-with-different-send-times/72731/3 "2023-02-24T17:33:10Z")

</div>

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