# Merge different messages with same TOPIC

**URL:** https://discourse.nodered.org/t/merge-different-messages-with-same-topic/56367
**Category:** General
**Created:** [10 January 2022 00:06 UTC](https://discourse.nodered.org/t/merge-different-messages-with-same-topic/56367 "2022-01-10T00:06:34Z")
**Posts on this page:** 6
**Page:** 2

<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: [10 January 2022 12:42 UTC](https://discourse.nodered.org/t/merge-different-messages-with-same-topic/56367/21 "2022-01-10T12:42:37Z")

</div>

As colin suggested should work with a delay node

Or you can use a trigger node to discard the duplicate msg's  
Here is an example, I have simulated the incoming messages with a split node and a change node. It will send six msg's. If you run it only the first message from each topic makes it through

```auto
[{"id":"b558a74069d392f3","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"topic\":\"location\",\"payload\":1},{\"topic\":\"location\",\"payload\":2},{\"topic\":\"cockpit\",\"payload\":1},{\"topic\":\"cockpit\",\"payload\":2},{\"topic\":\"battery_status\",\"payload\":1},{\"topic\":\"battery_status\",\"payload\":2}]","payloadType":"json","x":110,"y":1160,"wires":[["b6b78434.a8e5f8"]]},{"id":"b6b78434.a8e5f8","type":"split","z":"c791cbc0.84f648","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":230,"y":1160,"wires":[["c3cc285a.0ec518"]]},{"id":"c3cc285a.0ec518","type":"change","z":"c791cbc0.84f648","name":"simulate incoming msg's","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload.topic","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"payload.payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":1160,"wires":[["1bd65871.8f7048"]]},{"id":"1bd65871.8f7048","type":"trigger","z":"c791cbc0.84f648","name":"","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"250","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"topic","topic":"topic","outputs":1,"x":210,"y":1220,"wires":[["b44fcbe216010fe7"]]},{"id":"b44fcbe216010fe7","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":430,"y":1220,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![IAlves2022](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ialves2022/32/53866_2.png) [@IAlves2022](https://discourse.nodered.org/u/IAlves2022)
#### Post date: [10 January 2022 22:47 UTC](https://discourse.nodered.org/t/merge-different-messages-with-same-topic/56367/22 "2022-01-10T22:47:43Z")

</div>

First of all thank you all for all the reply's.

Probably I'm messing with this question and not been able to understand really what i need. I'm new to node-red, I've saw what a guy did a really cool dashboard with this node so i'm trying to apply something similar to what i need.

So I've tried the change node solution, that fairly looks what i need, in other way, because sooner in the flow i will need this properties isolated from the rest to display in the flow, but i'm getting messy responses.

The option with the delay node, i don't want to drop messages, because if there are any change on the battery-status i want the dashboard to be updated with the info.

And the trigger node to discard the messages it was the only that retrieve me the response that i wanted, one message per topic. So i will continue to create the rest of the flow for the dashboard to check if is this solution that i really need (i even don't now if i really now what i need!)

So once again, sorry for all this mess, I'm new in node-red and exploring and learning new things, sorry for the messy questions.

Best regards

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [11 January 2022 09:35 UTC](https://discourse.nodered.org/t/merge-different-messages-with-same-topic/56367/23 "2022-01-11T09:35:35Z")

</div>

> [@IAlves2022](#):
>
> And the trigger node to discard the messages it was the only that retrieve me the response that i wanted

Just for the record, using a Delay node (configured correctly) will have exactly the same effect as the Trigger node, which also drops later messages when they come in close together. Using a Trigger node is the neater solution though.

---

<div class="post-metadata">

### Author: ![IAlves2022](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ialves2022/32/53866_2.png) [@IAlves2022](https://discourse.nodered.org/u/IAlves2022)
#### Post date: [11 January 2022 10:42 UTC](https://discourse.nodered.org/t/merge-different-messages-with-same-topic/56367/24 "2022-01-11T10:42:17Z")

</div>

I believe so, but for me was the easiest to configure, and its not dropping the messages.

lets see in the future!

Thank you all

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [11 January 2022 10:56 UTC](https://discourse.nodered.org/t/merge-different-messages-with-same-topic/56367/25 "2022-01-11T10:56:41Z")

</div>

> [@IAlves2022](#):
>
> its not dropping the messages.

If you configured it correctly, with the same timeout as the trigger (which I see is 250ms) then it will behave exactly the same.

---

<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: [12 March 2022 10:57 UTC](https://discourse.nodered.org/t/merge-different-messages-with-same-topic/56367/26 "2022-03-12T10:57:16Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/merge-different-messages-with-same-topic/56367.md?page=1)
