Skip to content

Outputs: Javascript Node

TekMonks edited this page Mar 14, 2019 · 1 revision

The JS Output

The JS output node is used to implement custom outputs in Javascript. These nodes process messages based on custom logic or conditions.

This is one of the more important output nodes, as it allows any custom logic to be used to compose and output the message.

The code block below documents the format for the JS Route node.

"output": {
	"type":"js", 
	"dependencies":["route1"],
	"js": "<inline javascript code>",
	"module": "<path to JS code file>",
	"my_custom_property":"value_of_this_property"
}

Only one of js or module properties must be defined, depending upon whether the routing logic is written in-line or in a separate Javascript module.

If the module property is used then the module must implement this function

exports.start = (routeName, js, messageContainer, message) => {
    ....
    ....
}

Any custom properties can be passed into the JS route from the flow, and are available to the module via js.my_custom_property in the function show above, where my_custom_property is the name of the custom property.