How can I add two input port in the node I created

I need to have two input for one node I created .Yet it only allows to have one input . Is there a way to do that ?

Can't you just pass a msg object which contains all the needed information into your node?

Something like ..

msg.input1 = "input 1"
msg.input2 = "input 2"

Nodes are only allowed to have one input

I don't think so because I just want to add a second port without knowing what it will do or what kind of input it will be passed

Everyone else manages. I don't see your issue.

So if you are building your own custom node, simply document how the input data should be formatted.

The bottom line is, node-red doesn't support multiple inputs and likely never will.

Can you share some details about your node? Maybe the forum can provide a solution which is acceptable.

Ok I will explain you more what I need:
I created a node for machine learning which is train model and this node need two inputs: one for the model and another for the dataset

I created a node for machine learning which is train model and this node need two inputs: one for the model and another for the dataset

Do you expect these to be sent into your node at the same time or independently?

If you expect the inputs at separate times, then you could use a topic to identify the payload

e.g.

{
  topic: "model"
  payload: { /* model data */ } 
}

and

{
  topic: "dataset"
  payload: { /* dataset */ } 
}

If you expect the inputs at the same time simply send them together in one object

{
  topic: "dataset"
  payload: {
    model: { /* model data */ },
    dataset: { /* dataset data */ },
  }  
}

Even if you could have two inputs they won’t arrive at the same time.

With two msgs, you could have a join node create one msg, containing all the information (as @Steve-Mcl showed), that would go into your custom node.

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