You can use the blocks action in a trigger to create a complex response to an event or a button click. This response is created by dragging and connecting visual blocks. This gives you the full power of a programming language without having to learn syntax.
To get started with block programming create a new trigger and select the blocks action. On the action configuration, you will see the blocks editor. On the left you will see the categories of blocks you can use to construct a program, starting with Control Flow. Clicking on one of these category headers will reveal the blocks available in that category. You then drag the chosen block to the main canvas. You can also get a tooltip by hovering over a block, or if you right click on a block then a help link is available on some blocks.
Blocks can be connected into different ways: vertically, which indicates that one block will run after the other. Only some blocks, which have notches at the top and the bottom can be connected horizontally. These are the blocks that denote action steps or what programmers call “statements”.
Some blocks can also be connected horizontally, which means that values are computed. Blocks that can yield values has notches on the left-hand side; other blocks require values to specify their function, which means that they have notches on the right or internally. The blocks should assemble like a jigsaw, such that only combinations that make sense fit together. However, it is possible to construct nonsensical block assemblies.
The different categories of blocks are:
- Control flow: blocks that introduce loops or conditional expressions. These have an inner flow that is only executed depending on a condition, in the case of the if block or an inner flow that is repeated multiple times.
- Logic: blocks for Boolean (true or false) values and expressions.
- Math: blocks for numbers and for arithmetic expressions.
- Text: blocks for string constants, and a block for the name of the current channel (table name if the event type is table related).
- Lists: blocks for manipulating lists.
- Actions: blocks for printing to the console (process standard output come out but captured if you do a test run) and for emitting new events
- Variables: creating new variables with a given value, or retrieving a value in a variable