# How implement two inputs for node?

**URL:** https://discourse.nodered.org/t/how-implement-two-inputs-for-node/84633
**Category:** Developing Nodes
**Tags:** function-node
**Created:** [17 January 2024 09:12 UTC](https://discourse.nodered.org/t/how-implement-two-inputs-for-node/84633 "2024-01-17T09:12:13Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![VugarWeb777](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vugarweb777/32/84654_2.png) [@VugarWeb777](https://discourse.nodered.org/u/VugarWeb777)
#### Post date: [17 January 2024 09:12 UTC](https://discourse.nodered.org/t/how-implement-two-inputs-for-node/84633/1 "2024-01-17T09:12:13Z")

</div>

how implement two inputs for node ?  
node-red version 3.1.1

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [17 January 2024 09:39 UTC](https://discourse.nodered.org/t/how-implement-two-inputs-for-node/84633/2 "2024-01-17T09:39:30Z")

</div>

I believe this has been raised many (MANY) times before.

A possible solution is to make _input 1_ and _input 2_ messages have a different attribute.

eg: `msg.indentifier == 1` and `msg.identifier == 2` for the two different messages.

Then parse the message structure to determine _who_ sent it.

Also understand that nodes only accept ONE MESSAGE AT A TIME, so two inputs wouldn't really work.

And - back to what I was saying - you WILL HAVE TO store one of the messages in context so when the second one arrives, it has the other one.

## Other thought!

Use a `join` node to receive two messages before onsending it.  
Then BOTH messages arrive at the same time.

But that may not work if there is/are overlaps in the message structures.

---

<div class="post-metadata">

### Author: ![VugarWeb777](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vugarweb777/32/84654_2.png) [@VugarWeb777](https://discourse.nodered.org/u/VugarWeb777)
#### Post date: [17 January 2024 10:19 UTC](https://discourse.nodered.org/t/how-implement-two-inputs-for-node/84633/3 "2024-01-17T10:19:00Z")

</div>

if you create a custom node with two inputs, it still won't work ? is it limited in the node-red source code itself ?

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [17 January 2024 10:21 UTC](https://discourse.nodered.org/t/how-implement-two-inputs-for-node/84633/4 "2024-01-17T10:21:47Z")

</div>

No a node with two inputs won't work.

Node-red is not synchronous.  
Messages arrive at unknown times.

So there will be a problem that one message arrives and it (your node) then has to wait for the second message to arrive.

I offered two ways around that.

I shall say though:  
I am still very much in/at the shallow end of knowledge.

---

<div class="post-metadata">

### Author: ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)
#### Post date: [17 January 2024 10:21 UTC](https://discourse.nodered.org/t/how-implement-two-inputs-for-node/84633/5 "2024-01-17T10:21:59Z")

</div>

Node-RED makes the hard limit of zero or one input to a node - there is no such thing as a 2 input node.

It's an inbuilt assumption.

---

<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: [17 January 2024 11:31 UTC](https://discourse.nodered.org/t/how-implement-two-inputs-for-node/84633/6 "2024-01-17T11:31:14Z")

</div>

For reference, just a small selection, where this has been discussed: 😅

- [Why don't Node-RED nodes allow multiple inputs?](https://discourse.nodered.org/t/why-dont-node-red-nodes-allow-multiple-inputs/10973)
- [Create a new node with multiple inputs directly?](https://discourse.nodered.org/t/create-a-new-node-with-multiple-inputs-directly/15878)
- [Suggestion: A simple way to implement multiple input nodes](https://discourse.nodered.org/t/suggestion-a-simple-way-to-implement-multiple-input-nodes/66630)
- [Tagging msg and multiple inputs](https://discourse.nodered.org/t/tagging-msg-and-multiple-inputs/21914)
- [Logic nodes with multiple inputs?](https://discourse.nodered.org/t/logic-nodes-with-multiple-inputs/41692)

---

<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: [17 March 2024 11:31 UTC](https://discourse.nodered.org/t/how-implement-two-inputs-for-node/84633/7 "2024-03-17T11:31:22Z")

</div>

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