Expression
🎯 Purpose
An Expression is used to filter clients participating in a campaign.
It is a script written in JavaScript or Python that evaluates a specific client's data and returns true or false.
Only clients for whom the result is true will be included in the campaign execution.
⚙️ Using the JavaScript/Python Engine
The timveroOS platform supports script execution in both JavaScript and Python via the ScriptManager component.
The CampaignExecutionService compiles the expression with:
Script script = scriptManager.compile(expression);And evaluates it for each client with:
Object evaluationResult = script.eval(Map.of("client", client));💡 The script runs in a sandboxed environment with no access to unsafe resources.
Compilation or runtime errors are wrapped in a ScriptException and logged.
🔐 Security
Scripts are executed with strict limitations:
Restricted classes
Execution timeouts
No external system access
Any error (e.g., NullPointerException, syntax error) is captured in an ExceptionEntity and shown in the UI as EXCEPTION_OCCURRED.
🧪 Expression Example
client.age > 25 && client.income > 3000 && client.country == "UK"This expression selects clients who are:
Older than 25
Have an income over 3000
Live in the United Kingdom
📌 Code Usage Example
private Optional<Client> evaluateClient(Script script, UUID clientId) throws ScriptException {
Client client = clientRepository.getReferenceById(clientId);
Object result = script.eval(Map.of("client", client));
return Boolean.TRUE.equals(result) ? Optional.of(client) : Optional.empty();
}Last updated
Was this helpful?