Skip to content

Router

The Router module routes the data flow to different modules based on the value of a specific field or the evaluation of conditions. It first evaluates the configured field (for example data.type) and looks for an exact match in the defined routes. If there is no exact match, it attempts to evaluate each route key as a JavaScript expression. If no route matches, it redirects to the defaultPath. It is useful for directing the flow to different branches based on data type, category, or any dynamic value.

ParameterTypeRequiredDescription
fieldtextYesJavaScript expression that is evaluated to obtain the value to compare. E.g.: data.type, data.status.
routestext (JSON)YesJSON object where keys are values or conditions to compare, and values are the destination module names. E.g.: {"value1": "module_A", "value2": "module_B"}.
defaultPathtextNoName of the module to redirect to if no route matches.
{
"nextModule": "modulo_destino",
"data": { "datos_originales": "sin_modificar" },
"_meta_": {
"routerField": "valor_evaluado",
"routerPath": "modulo_destino",
"routerDefault": false
}
}
{
"label": "Router",
"field": "data.tipo",
"routes": "{\"factura\": \"procesarFactura\", \"pedido\": \"procesarPedido\", \"devolucion\": \"procesarDevolucion\"}",
"defaultPath": "procesoGenerico"
}
  • The field value is evaluated with eval(), so it can be any valid JavaScript expression (e.g.: data.type, data.items.length).
  • Routes are first compared by exact match with the field value.
  • If there is no exact match, each route key is evaluated as a boolean JavaScript expression.
  • If routes is a string, it is automatically parsed as JSON.
  • Data passes without modification to the next node; the Router does not transform data.
  • The _meta_ includes information about the selected route and whether the defaultPath was used.
  • Decision - binary true/false evaluation
  • Switch - evaluation of multiple conditions with operators
  • Merge - to reunite branches separated by the Router