Once you managed to create your first basic node through the "Your first node" guide, this is the place to build a more advanced node.

The node we will be building here returns a value on an output defined on the node. It relies on the nodeOutput "trigger" event to respond when another node requests data.

Setting up structure.json

Copy the following contents into your structure.json;

{  "name": "hellooutput" // the name of your node as visible in XIBLE  "type": "object"  "outputs": {          // outputs that connectors can be attached to    "strout": {         // name of the output      "type": "string"  // string output to another node    }  }}

Be sure to remove the comments (starting with // ...), as the JSON specification does not allow them.


With the structure setup, we can now specify how this node interacts with XIBLE and other nodes.

'use strict';// export a function to run when a flow containing this node initializesmodule.exports = (NODE) => {  // get the output string we created in structure.json  const strOut = NODE.getOutputByName('strout');  // when another node requests data from this output through a connector  // this is triggered  strOut.on('trigger', async (conn, state) => {    // return a value    // note that this concerns (and must be) a promise,    // since the arrow function declaration is async    return 'hello output';  });};

Run it

  • Restart your XIBLE to pick up the new node.
  • Create a new flow.
  • Open the node selector, by double clicking the editor.
    • Your "hellooutput" node should be in the list. If not, check your XIBLE logs.
    • Click your node to add it to the editor, you may drag it anywhere.
  • Add a "console.log" node.
    • Hook up the "value" input to the "strout" output of your "hellooutput" node.
  • Add a "xible.flow.onstart" node.
    • Hook up the output trigger of the "xible.flow.onstart" node to the input trigger of the "console.log" node.
  • Hit "Deploy". Or alternatively, double click the "console.log" node to run it in direct mode.