5 min readUpdated Mar 2, 2026

runWorkflow Documentation

Purpose

The runWorkflow logic is designed to execute workflows identified by their ID, utilizing result caching for efficiency. It aims to optimize performance by avoiding redundant executions of workflows that have already produced results. Furthermore, it accommodates various operational modes (like preview and force execution) and manages dependencies using a determinate caching strategy.


Settings

This section provides an exhaustive overview of all settings used within the runWorkflow function, detailing their purposes, types, impacts on behavior, and default values.

1. workflowId

2. skipCache

3. previewMode

4. outputNodeId

5. forceSync


How It Works

The runWorkflow function begins by fetching parameters from the provided config or context objects. It validates the workflowId, ensuring it’s a numeric type and checking for null or undefined values. It generates a deterministic caching key based on whether a cache skip is requested and checks Redis for existing results.

If valid cached results exist, the function checks if the relevant data is still valid. If invalid, the function re-executes the workflow. Post-checks, the function queries the database to retrieve the workflow's details, including nodes and edges necessary for execution.

The function passes the relevant data to the executeWorkflow helper function, which handles the actual processing. After execution, if not in preview mode, results are cached for future requests.


Data Expectations

The runWorkflow function expects the following data:


AI Integrations

While there are no explicit AI integrations within the runWorkflow function itself, it is endowed with capabilities to utilize machine-learning models or AI engines through the workflows it executes. By manipulating workflow nodes that might call AI services, users could drive intelligent data transformations, insights, or predictions.


Billing Impacts

Executing the runWorkflow function and leveraging its features may incur costs based on the number of executions, the amount of data processed, and storage of results in Redis. Utilizing caching can minimize costs associated with redundant workflows; however, disabling cache (skipCache set to true) or heavy workloads may lead to increased expenses due to resource usage.


Use Cases & Examples

Use Case 1: Data Processing Automation

A company automates its reporting workflow to generate weekly summary reports. It schedules a workflow to execute every week, leveraging runWorkflow to produce the latest report based on current sales data.

Use Case 2: Real-time Preview

A data analyst reviews the output of a new experimental workflow without affecting the production cache. By using runWorkflow in previewMode, the analyst can see instant results from the trial execution, adjusting parameters before full-scale deployment.

Example Configuration

For the above use case of a real-time preview, the analyst might configure runWorkflow as follows:

javascript
const workflowConfig = {
    workflowId: '123',               // ID of the specific workflow to execute
    skipCache: false,                // Utilize caching
    previewMode: true,               // Enable preview mode to limit output
    outputNodeId: null,              // Retrieve results from all terminators
    forceSync: false                  // Default asynchronous behavior
};

const result = await runWorkflow(workflowConfig);
console.log('Workflow result preview:', result);

This example would generate a preview output of the workflow identified by ID 123, providing insight into its performance without committing changes to the cache.