Variables & Templating
figranium uses a powerful variable system to make tasks reusable and dynamic.
Variable Syntax#
Anywhere in a task (URL, Selectors, Action Values, Scripts), you can reference a variable using the {$varName} syntax.
Example:
- Variable:
query= "figranium automation" - Action: Type into
input[name="q"] - Value:
{$query}
When executed, figranium replaces {$query} with "figranium automation".
Defining Variables#
- Task Variables: Define default values in the Editor > Variables section.
- Types: String, Number, Boolean.
- Runtime Variables: Pass overrides via the API when triggering a task.
POST /api/tasks/:id/apibody:{"variables": {"query": "new value"}}
Special Variables#
figranium provides several built-in variables:
{$now}: Current ISO timestamp.block.output: The result of the previous action (e.g., text from ajavascriptblock).loop.index: The current index in aforeachloop.loop.item: The current item in aforeachloop.loop.text: The text content of the current loop item.loop.html: The HTML content of the current loop item.
Dynamic Usage#
You can use variables to build complex logic:
- URL Templating:
https://example.com/search?q={$query} - Selectors:
.item[data-id="{$itemId}"] - Scripts:
const user = "{$username}";
Persistent Variables#
The set action allows you to update variables during execution.
- Action:
set - Var Name:
counter - Value:
{$counter} + 1(JavaScript expression)
This value persists for the remainder of the task execution.