Hello. How can i start execution in node red from another app with node-red api? RED.nodes.startFlow?
Flows in the runtime can be triggered by many events.
You can start a flow by (including but not limited to) an http endpoint, a TCP in, an MQTT in node, a telegram message, a physical input.
What are you actually trying to achieve?
I have implemented the creation functionality flow functionality but I need the generated flow to start performing its internal functionality after creation
What does this mean? Did you create a flow externally to node-red and post it via a the admin endpoints? Or did you use the node-red editor to create your flow?
And, since a flow is event based (i.e. sending a
msg through the wires) it works by sending a msg into it, what do you mean exactly by "start execution"? trigger it once? trigger it repeatedly?
Look, I have a functional that creates the same type of flows with help RED.nodes.addFlow(), they have a certain logic. And I need this logic to be executed after creating flow
It would have been useful to include that information in the first place.
As I don't know what that function does I can only suggest you try building your flow with an inject set to trigger on start up - see if that works.
As I said in a previous post, flows are always executing in the runtime, waiting for a msg to trigger them.
Apart from that, I can't help further.
Basically all I need is to run inject and that's it all
Presumably once you load your flows then you will do a reload of NR to enable them
If you have as the first node an inject node that is set to inject once on startup then it will send whatever (by default timestamp) you have configured it for to get your node going.
I can not believe if you have created a flow programatically you need to ask a question at this level (and quite rudely too)
If that had been your first question, I would have told you the inject nodes have a http endpoint that you can call to operate it. That's how the inject button works in the node-red editor. Take a look at the inject html src code in the node-red repo for how it does it then replicate that functionality in your express application.
Its not difficult api has method
That is, in general, it is possible to implement it?
Deleting based on feedback...
Hi @paulkeates - I'm not sure that response is warranted.
@Snoz3f - can you explain a bit more about what you are doing? If you have a flow that is started by an Inject node, then there will be an HTTP Admin endpoint you could use to trigger it. If you use devtools in the browser when manually triggering an inject node, you'll see how it works.
But it would probably be better to use another node type here - such as an HTTP In node so you can completely control the end point used to trigger your flow.
Let me explain in order what I want to achieve. I have a generator of the same type of flow, it is located on the express server. It all perform the same logic with different data, then it save the result in mongo. The only thing I need to achieve is that after generating flow, it starts and executes its logic.
A flow is "started" as soon as it gets deployed in the runtime. This is what the
addFlow API you've asked about is doing.
So I'm not sure what else you are asking, without more information about the flow you are adding and what node it begins with.
It starts with the timestamp node. Look my whole goal is to run timestamp from the code. The whole stream is just a regular html parser. It makes a request and receives all the data that it has collected. And then mongo saves them.
I don't know what node that is. Can you be more specific? Or maybe share a screenshot of a flow.
But still I'm not clear what your question is. If you want to trigger a flow from outside of Node-RED, then pick a node that exposes itself in some way you can call it. Such as an http end point, or tcp listener, or mqtt subscriber.
Diplomatically: I believe the 'timestamp node' is the inject node.
It dynamically changes the label to 'timestamp' once it is placed on the flow.
They may be asking how can they 'loop' or restart the processing in order to iterate against the endpoint and 'scrape' the data & save it to Mongo... ?
Something like an inject followed by repeat:
Indeed, that is likely. But I was hoping to get @Snoz3f to confirm that so we can at least start from a common point of terminology - the Inject node.
But any thing is just speculation and guesses that may, or may not, help move the discussion forward. What we really need are actual details from @Snoz3f.
Yes its inject. For some reason, the node sometimes changes its name.