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.

This time, an input is included to fetch data from another node. To achieve this, we will be using the nodeInput.getValues(state) method.

Setting up structure.json

Copy the following contents into your structure.json;

{  "name": "helloinput"  // the name of your node as visible in XIBLE  "type": "action"  "inputs": {           // inputs that connectors can be attached to    "trigger": {        // name of the input      "type": "trigger" // triggered by an output trigger from another node    }    "strin": {          // name of the input      "type": "string"  // string input from 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 input string we created in structure.json  const strIn = NODE.getInputByName('strin');  // get the input trigger we created in structure.json  const triggerIn = NODE.getInputByName('trigger');  // when another node triggers this input through a connector  triggerIn.on('trigger', async (conn, state) => {    // fetch the values from the string input    // note that getValues always returns a promise with an array    const strs = await strIn.getValues(state);    // log each value    strs.forEach((str) => {      console.log(str);      // add a status message visible in the editor      NODE.addStatus({        message: str,    // set the message        timeout: 3000    // remove the status message after 3 seconds      });    });  });};

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 "helloinput" 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 "xible.flow.onstart" node.
    • Hook up the output trigger of the "xible.flow.onstart" node to the input trigger of your "helloinput" node.
  • Add a "string" node.
    • Hook up the "result" output to the "strin" input of your "helloinput" node.
    • Set the value of the "string" node to "hello world" or anything you like.
  • Hit "Deploy". Or alternatively, double click your "helloinput" node to run it in direct mode.