Listening on node events

Hello everyone,
I have embedded nodered. I’m working with the runtime-api.
I can launch the runtime and a flow and I'm able to find and send messages to a flow.

I want to send a message to node A and listen to what is coming to node B.
I tried to use node.on("input", (msg) => {}) but with no luck maybe I misunderstood something.

my code:

let http = require('http');
let express = require("express");
let RED = require("node-red");

// Create a server
let server = http.createServer(express());

// Create the settings object - see default settings.js file for other options
let settings = {
    httpNodeRoot: "/api",
    functionGlobalContext: { },    // enables global context
    // logging:"off"

// Initialise the runtime with a server and settings

let flows=[{"id":"84378caad4a2edd5","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"a8b383355363e036","type":"inject","z":"84378caad4a2edd5","name":"entry","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"123","payloadType":"str","x":430,"y":80,"wires":[["25cef7ec4e5ffb25"]]},{"id":"25cef7ec4e5ffb25","type":"debug","z":"84378caad4a2edd5","name":"debug","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":700,"y":100,"wires":[]}]
RED.start().then( async () => {
    await RED.runtime.flows.setFlows({flows: {flows}})
    let {flows: nodeObjects} = await RED.runtime.flows.getFlows({user:'admin'});
    let inputNodeObject = nodeObjects.find((f) => ( == 'entry'))
    let outputNodeObject = nodeObjects.find((f) => ( == 'debug'))

    await RED.runtime._.nodes.load()
    let inputNode = (await RED.runtime._.nodes.getNode(;
    let outputNode = (await RED.runtime._.nodes.getNode(;

    inputNode.send({payload: "world hello"});

    outputNode.on("input", (msg) => {`-----------------------------------`);`msg:`);;

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