Skip to content

How to add new Blocks

Davide Zanella edited this page May 17, 2019 · 2 revisions

If you want to add a new custom block to use it in the workflow graph editor you have to do the following things:

  • navigate to the src/blocks folder and create a new folder with the name you want to assign to your block

  • create your block's code inside that folder

  • create a file called index.js inside your block folder with this structure:

    const start = async (blockData, input) => {
      let output;
    
      //implement your logic here
    
      return output;
    };
    
    module.exports = start;
    
    

    The blockData parameter contains the property of your custom block (later will explain how to set them) and the input parameter is an object where keys are the labels of the previous blocks in the workflow graph. For example, in you want to get the input from the previous block label as previousBlock you can access them in this way: input['previousBlock']. After elaborating the input, each block have to return an output value which would be stored and passed to the successive block as an input.

  • Add a new element of the entity block-types. You have to choose the same name of the folder previously created inside the blocks one. You can set other type of properties and in particular custom parameters of the block, the sames that you can retrieve from the blockData parameter.

    refs: Do block example, Lambda block example

Clone this wiki locally