# Create a new node with multiple inputs directly?

**URL:** <https://discourse.nodered.org/t/create-a-new-node-with-multiple-inputs-directly/15878>\
**Category:** Developing Nodes\
**Created:** [25 September 2019 08:19 UTC](https://discourse.nodered.org/t/create-a-new-node-with-multiple-inputs-directly/15878 "2019-09-25T08:19:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![HannanKan](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@HannanKan](https://discourse.nodered.org/u/HannanKan)\
**Post date:** [25 September 2019 08:19 UTC](https://discourse.nodered.org/t/create-a-new-node-with-multiple-inputs-directly/15878/1 "2019-09-25T08:19:39Z")

</div>

I **just** want to create a new node with multiple inputs. This node will:  
show multiple inputs' ports;  
generate {node\_id: output\_name} in its json,when linked with other node's output.

---

<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 September 2019 08:24 UTC](https://discourse.nodered.org/t/create-a-new-node-with-multiple-inputs-directly/15878/2 "2019-09-25T08:24:03Z")

</div>

Node-RED doesn't support multiple input ports

---

<div class="post-metadata">

**Author:** ![HannanKan](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@HannanKan](https://discourse.nodered.org/u/HannanKan)\
**Post date:** [25 September 2019 09:00 UTC](https://discourse.nodered.org/t/create-a-new-node-with-multiple-inputs-directly/15878/3 "2019-09-25T09:00:34Z")

</div>

I mean rewriting codes to support it.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [25 September 2019 09:06 UTC](https://discourse.nodered.org/t/create-a-new-node-with-multiple-inputs-directly/15878/4 "2019-09-25T09:06:03Z")

</div>

Just to clarify... you want to rewrite the entire node-red runtime and editor to support multiple inputs? Something we've said repeatedly (if you search the forum) is not supported?

You'll forgive me if, at a time we're focussed on getting 1.0 released, that I don't spend a day writing out everything that would need to be changed to do that.

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [25 September 2019 09:23 UTC](https://discourse.nodered.org/t/create-a-new-node-with-multiple-inputs-directly/15878/5 "2019-09-25T09:23:39Z")

</div>

Supporting only one input was a fundamental design choice (and a good one, IMO), otherwise the flow engine would have to be _a lot_ more complex.

There was a nice discussion about this topic a while ago here:

> [@Why don't Node-RED nodes allow multiple inputs?](https://discourse.nodered.org/t/why-dont-node-red-nodes-allow-multiple-inputs/10973):
>
> For clarity: I'm not asking how to implement multiple inputs to a function, I already know the workarounds. I want to know why Node-RED developers would inhibit such a functionality. It seems so obvious and natural to allow multiple inputs to a function. For example: say I want to create a function Divide(dividend, divisor) that returns dividend divided by divisor. In JavaScript this would be: function Divide(dividend, divisor) { return dividend / divisor } With Node-RED, the same functio…

---

<div class="post-metadata">

**Author:** ![pitus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pitus/32/28170_2.png) [@pitus](https://discourse.nodered.org/u/pitus)\
**Post date:** [18 September 2020 16:12 UTC](https://discourse.nodered.org/t/create-a-new-node-with-multiple-inputs-directly/15878/6 "2020-09-18T16:12:12Z")

</div>

The function example with 2 inputs to do a Division is not a good example as to why multiple-inputs would be beneficial (each input receives messages potentially at different time while the function would need access to both parameters simultaneously - a JOIN node does the trick for that).

However, here's a good (IMHO) reason to consider implementing multiple node inputs in the future (I understand that it's not a simple, localized change, so I imagine it would be a distant future, but I can help with this task):

1. Collapse a Group into a single box/node/subflow - currently a group may have multiple links on either side (ins and outs) as there could be multiple wires leading to it. Once converted to a subflow, it would require each message to be identifiable by topic or otherwise (to avoid collision when directing all inputs to a single port) and a split node inside the subflow to extract each input ...
2. Building a complex flow is quite messy right now as not everything can be done with subflows (although, I hope that single-instance subflows / nodes will be eventually implemented) - for example, I can't link to a subflow element, all inputs have to go through a single port - quite a mess to figure it all out. Object-oriented-like flows would allow for complex nodes to be defined on separate tabs (as 'subflows' or 'classes') and shown on the main flow as a single box with multiple inputs/outputs, possibly with a multi-line label that I'd also like to see). This nesting could be hierarchical, building a complex machinery from smaller and smaller blocks.
3. Multiple inputs could be implement as simply as supplying an array of messages on the current single port - similar to how send([...]) allows to address multiple outputs. Perhaps that would be enough to do the trick + visual layout of course?
