# The emerge node, built via Node-Maker

**URL:** https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023
**Category:** Share Your Nodes
**Created:** [21 November 2022 22:45 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023 "2022-11-21T22:45:17Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![Steveorevo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steveorevo/32/33290_2.png) [@Steveorevo](https://discourse.nodered.org/u/Steveorevo)
#### Post date: [21 November 2022 22:45 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023/1 "2022-11-21T22:45:17Z")

</div>

Created a simple but essential node using my [Node-Maker](https://github.com/steveorevo/node-maker) side project. Often times I need to submit a msg to a node with various properties present and filled out; these properties may come from various asynchronous and parallel flow segments. Counting messages and waiting to gather all these values into a single msg can be a burden. The emerge node can simplify that burden by combining msgs until all the needed properties are present and/or meet their pre-defined requirements before a single, new, msg "emerges" (is sent) along its merry way.

Built with Node-Maker, this has been a test to see how viable both projects will be in the near future (I've got a lot of flows and nodes to build).

Included in the repo you'll find _node-maker.json_, a flow file that created the emerge node without having to venture far from Node-RED itself.

> **[@steveorevo/node-red-emerge](https://flows.nodered.org/node/@steveorevo/node-red-emerge)**
>
> A node that merges msg objects until all defined properties are present / conditions met before passing the combined msg along.

---

<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: [22 November 2022 07:11 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023/2 "2022-11-22T07:11:37Z")

</div>

Did you consider submitting, initially, a feature request to enhance the join node for this? I can see that something like this could be a useful enhancement. If it met with approval then you could implement that, rather than a new node.

---

<div class="post-metadata">

### Author: ![Steveorevo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steveorevo/32/33290_2.png) [@Steveorevo](https://discourse.nodered.org/u/Steveorevo)
#### Post date: [22 November 2022 18:27 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023/3 "2022-11-22T18:27:51Z")

</div>

I did consider this. However, there are key reasons why a plugin node was a better route, even if it becomes apart of the join node or added to core itself:

- first off, I needed it (now)
- isolates changes
- gauges community necessity
- provides beta testing route
- opportunity for user feedback (before core)

I contribute to a number of open source projects; both large and small. For a project like Node-RED, with a proper plugin architecture, it’s ideal to implement features as plugins and then evaluate if they should become apart of core. Some commercial products do this (unfortunately at the expense of app developers; see “getting flux’d” in iOS, which “stole” night mode). But that’s no matter here because this is open source and I’m all for taking and modifying (attribution credit is welcome)!

I’m apart of the WordPress community and it’s become popular to rollout features as a separate add-on first that [we call it Canonical Plugins](https://wordpress.org/news/2009/12/canonical-plugins/).

This gives the opportunity for, say Nick and Dave to see how folks are using the project before making major changes to it. They can also evaluate user feedback, issues, and comments on the open source repo for it. Actually, very early in Node-RED development I created a credentials node and Nick bounced the idea of making such a feature apart of core; I think that’s how we have a credentials type input in subflows, a very cool feature.

So yes, the thought crossed my mind but it was faster to introduce via share-your-work a, “canonical node”. If it proves popular, Node-RED is MORE THAN WELCOME to take it, use it or modify it, or include it in the core palette. 🙂

---

<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: [22 November 2022 21:23 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023/4 "2022-11-22T21:23:03Z")

</div>

I was thinking more with a view to discussing the spec and coming up with a proposal that would be of most benefit to most people and that would be most compatible with the core node.

> [@Steveorevo](#):
>
> Node-RED is MORE THAN WELCOME to take it,

I was thinking more of a contribution to the core.

---

<div class="post-metadata">

### Author: ![Steveorevo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steveorevo/32/33290_2.png) [@Steveorevo](https://discourse.nodered.org/u/Steveorevo)
#### Post date: [22 November 2022 22:59 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023/5 "2022-11-22T22:59:45Z")

</div>

I think this is the process you’re referring to. I’ve opened discussion in core to facilitate feature requests before, but I’m 50/50 on success; the failures don’t get any replies. But I think it’s probably because the slack channel is a little stale? Seems like the forums is where it’s at now.

Always open to feedback. Thank you for your input!

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [22 November 2022 23:11 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023/6 "2022-11-22T23:11:59Z")

</div>

Yes, discussions much easier ( and long lasting) here on the forum. Having had a quick look at the node I can see that while it is an obvious candidate for a new mode in the join node, it is also somewhat different, such that it isn’t obvious ( to me) how to just drop it in, so yes happy to see it exist, and at same time discuss how it could be joined into join.

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [25 November 2022 10:32 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023/7 "2022-11-25T10:32:46Z")

</div>

I just tried this node out and it didn't seem to work for me  
I want to wait until 3 messages with different topics have arrived and then output but its not working for me  
What have I got wrong?

```auto
[{"id":"c999bddccf728078","type":"emerge","z":"a5b78a370366734b","name":"","grpRules":[{"ruleProperty":"topic","rulePropertyType":"msg","ruleOperation":"==","ruleValue":"red","ruleValueType":"str"},{"ruleProperty":"topic","rulePropertyType":"msg","ruleOperation":"==","ruleValue":"green","ruleValueType":"str"},{"ruleProperty":"topic","rulePropertyType":"msg","ruleOperation":"==","ruleValue":"blue","ruleValueType":"str"}],"ruleProperty":"payload","rulePropertyType":"msg","ruleOperation":"==","ruleValue":"","ruleValueType":"str","rulesTimeout":30,"timeoutAction":"0","x":310,"y":290,"wires":[["041a3ab2449d6513"]]},{"id":"041a3ab2449d6513","type":"debug","z":"a5b78a370366734b","name":"debug 23","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":500,"y":290,"wires":[]},{"id":"9d5e796efacbc1b6","type":"inject","z":"a5b78a370366734b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"red","payload":"","payloadType":"date","x":100,"y":270,"wires":[["c999bddccf728078"]]},{"id":"988004d53c37c84c","type":"inject","z":"a5b78a370366734b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"green","payload":"","payloadType":"date","x":110,"y":320,"wires":[["c999bddccf728078"]]},{"id":"541d960381417cb1","type":"inject","z":"a5b78a370366734b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"blue","payload":"","payloadType":"date","x":110,"y":380,"wires":[["c999bddccf728078"]]}]

```

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/b/abc49ed16277551b84867322ae7fdd5fd1f96270.png)

---

<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: [26 November 2022 15:11 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023/8 "2022-11-26T15:11:36Z")

</div>

I can't get it to do anything either.

---

<div class="post-metadata">

### Author: ![Steveorevo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steveorevo/32/33290_2.png) [@Steveorevo](https://discourse.nodered.org/u/Steveorevo)
#### Post date: [27 November 2022 03:36 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023/9 "2022-11-27T03:36:29Z")

</div>

Just updated to version 1.1.2, included is an example flow. Please post your minimal flow if you have encountered an issue and I can cross-check it with the current version.

---

<div class="post-metadata">

### Author: ![Steveorevo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steveorevo/32/33290_2.png) [@Steveorevo](https://discourse.nodered.org/u/Steveorevo)
#### Post date: [27 November 2022 03:41 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023/10 "2022-11-27T03:41:59Z")

</div>

Hi cymplecy, there seems to be some confusion as you're setting the topic three times. It's not possible for all those conditions to be true in order for the new message to emerge. In the example, the emerge node waits until three messages arrive:

1. msg.first\_name
2. msg.last\_name
3. msg.occupation

Only until all properties are present (because the msgs are _merged_) does a new message output containing:

```auto
{
    first_name: "Jack",
    last_name: "Burton",
    occupation: "truck driver"
}

```

Each of the properties have a different name and therefore, can eventually manifest as "not empty" in the rules.

Please let me know if that clarifies the issue or if you need further assistance.

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [27 November 2022 09:46 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023/11 "2022-11-27T09:46:06Z")

</div>

There is confusion 🙂  
I don't think this node does what I thought it did

Never mind 🙂

---

<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: [27 November 2022 10:44 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023/12 "2022-11-27T10:44:39Z")

</div>

I was also confused about what it did. I thought that @cymplecy's example would merge messages until it had received topic values equal to the values specified, and would provide a merge of all the other properties of the message. Perhaps you need to add to the help text to clarify that this is not correct. Also perhaps it should not allow the same property to be specified twice in that way.

The following also doesn't work for me, I don't know why.

```auto
[{"id":"0a5d142fe493b32a","type":"emerge","z":"c4b3f62035982a12","name":"wait for all user info","grpRules":[{"ruleProperty":"payload.first_name","rulePropertyType":"msg","ruleOperation":"!empty","ruleValue":"","ruleValueType":"str"},{"ruleProperty":"payload.last_name","rulePropertyType":"msg","ruleOperation":"!empty","ruleValue":"","ruleValueType":"str"},{"ruleProperty":"payload.occupation","rulePropertyType":"msg","ruleOperation":"!empty","ruleValue":"","ruleValueType":"str"}],"ruleProperty":"payload","rulePropertyType":"msg","ruleOperation":"==","ruleValue":"","ruleValueType":"str","rulesTimeout":30,"timeoutAction":"1","x":310,"y":100,"wires":[["4c5d7bca520c0054"]]},{"id":"621efb1c34f39daa","type":"inject","z":"c4b3f62035982a12","name":"first_name","props":[{"p":"payload.first_name","v":"Jack","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":100,"y":40,"wires":[["0a5d142fe493b32a"]]},{"id":"cb8c62f1de3d970e","type":"inject","z":"c4b3f62035982a12","name":"last_name","props":[{"p":"payload.last_name","v":"Burton","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":100,"y":100,"wires":[["0a5d142fe493b32a"]]},{"id":"5683ab4dc09a100f","type":"inject","z":"c4b3f62035982a12","name":"occupation","props":[{"p":"payload.occupation","v":"truck driver","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":100,"y":160,"wires":[["0a5d142fe493b32a"]]},{"id":"4c5d7bca520c0054","type":"debug","z":"c4b3f62035982a12","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":500,"y":100,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![Steveorevo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steveorevo/32/33290_2.png) [@Steveorevo](https://discourse.nodered.org/u/Steveorevo)
#### Post date: [27 November 2022 18:30 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023/13 "2022-11-27T18:30:53Z")

</div>

Your example is a perfect _ **bug** _ of what it's failing to do! Thank you for your feedback. The problem there is that it's doing a shallow merge; that is to say msg.payload is getting overwritten with a single property each time. Therefore the internal buffer is only containing _msg.payload.first\_name_ _ **or** _ _msg.payload.last\_name_ but not (Schrödinger's cat aside) both at the same time.

Had it been (sans payload) _msg.first\_name_ and _msg.last\_name_ that would have worked.

I've now implemented a **deep merge** routine that should provide the expected results and will now work with your example. Please see node-red-emerge version 1.2.0.

Thank you for your feedback!

---

<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: [11 December 2022 18:31 UTC](https://discourse.nodered.org/t/the-emerge-node-built-via-node-maker/71023/14 "2022-12-11T18:31:05Z")

</div>

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