Skip to main content

Overview

Technical reference for Workflow Builder React components, hooks, and types in the FW core.

React Components

WorkflowCanvas

Visual canvas for designing workflows with React Flow.
Props:
  • nodes: Node[] - Array of workflow nodes
  • edges: Edge[] - Array of connections between nodes
  • onNodesChange: (changes: NodeChange[]) => void - Node state changes
  • onEdgesChange: (changes: EdgeChange[]) => void - Edge state changes
  • onNodeClick?: (event: React.MouseEvent, node: Node) => void - Node click handler
  • onPaneClick?: () => void - Canvas click handler
  • onDrop?: (event: React.DragEvent) => void - Node drop handler
  • onDragOver?: (event: React.DragEvent) => void - Drag over handler

NodePalette

Sidebar with draggable node types.
Features:
  • Categorized node groups (Triggers, Actions, Control Flow, etc.)
  • Drag-to-add interface
  • Search/filter capability
  • Collapsible categories

NodePropertiesPanel

Configuration panel for selected node.
Props:
  • selectedNode: Node | null - Currently selected node
  • onNodeUpdate: (nodeId: string, data: any) => void - Update handler
  • onDeleteNode: (nodeId: string) => void - Delete handler

ExecutionTrace

Timeline visualization of workflow execution.
Props:
  • executionId: string - Execution record ID
  • execution: WorkflowExecution - Execution data with node states

WorkflowValidation

Pre-execution validation and error display.
Props:
  • nodes: Node[] - Workflow nodes to validate
  • edges: Edge[] - Workflow edges to validate
  • onValidate?: (result: ValidationResult) => void - Validation callback
ValidationResult:

ErrorDisplay

Error presentation component.
Props:
  • error: WorkflowError | string - Error to display
  • variant?: 'inline' | 'card' - Display style (default: ‘inline’)

React Hooks

useWorkflowDefinition

Fetch and save workflow canvas state.
Parameters:
  • ruleId: string - Automation rule ID
Returns:
  • definition: WorkflowDefinition | null - Current canvas state
  • isLoading: boolean - Loading state
  • isSaving: boolean - Saving state
  • saveDefinition: (nodes, edges, viewport?) => Promise<void> - Save function

useWorkflowExecution

Manage workflow execution state.
Parameters:
  • executionId: string - Execution record ID
Returns:
  • execution: WorkflowExecution | null - Execution data
  • isLoading: boolean - Loading state
  • pauseExecution: () => Promise<void> - Pause function
  • resumeExecution: () => Promise<void> - Resume function
  • cancelExecution: () => Promise<void> - Cancel function

useWorkflowApprovals

Fetch and manage approval tasks.
Parameters:
  • organizationId: string - Organization ID
Returns:
  • approvals: WorkflowApproval[] - Pending approvals
  • isLoading: boolean - Loading state
  • approveTask: (id, notes?) => Promise<void> - Approve function
  • rejectTask: (id, notes?) => Promise<void> - Reject function

useSubflows

Manage reusable subflows.
Parameters:
  • organizationId: string - Organization ID
Returns:
  • subflows: Subflow[] - Available subflows
  • isLoading: boolean - Loading state
  • createSubflow: (data) => Promise<void> - Create function
  • updateSubflow: (id, data) => Promise<void> - Update function
  • deleteSubflow: (id) => Promise<void> - Delete function

useExecutionTrace

Fetch real-time execution trace.
Parameters:
  • executionId: string | null - Execution record ID
Returns:
  • React Query result with execution data
  • Auto-polling while execution status is ‘running’ or ‘paused’

useWorkflowVersions

Manage workflow version history, rollback, and comparison.
Parameters:
  • ruleId: string | undefined - Automation rule ID
Returns:
  • versions: WorkflowVersion[] - All versions for the rule (newest first)
  • isLoading: boolean - Loading state for initial fetch
  • error: Error | null - Error state
  • getVersion: (version: number) => Promise<WorkflowVersion | null> - Fetch specific version
  • createVersion: (options: CreateVersionOptions) => Promise<number> - Create new version snapshot
  • isCreatingVersion: boolean - Creating version loading state
  • rollback: (options: RollbackOptions) => Promise<void> - Rollback to previous version
  • isRollingBack: boolean - Rollback loading state
  • compareVersions: (versionA: number, versionB: number) => Promise<VersionDiff> - Compare two versions
Types:
Examples:

TypeScript Types

Node Types


Workflow Execution Types


Subflow Types


Edge Function API

POST /automation-executor

Execute workflow based on trigger data. Endpoint: https://{project-ref}.supabase.co/functions/v1/automation-executor Headers:
Request Body:
Response:

Database Schema

fw_workflow_definitions

fw_workflow_executions

fw_subflows


Examples

Creating a Simple Workflow Programmatically


Triggering a Workflow


Monitoring Execution


Best Practices

Performance

  • Keep workflows under 50 nodes for optimal performance
  • Use parallel execution for independent actions
  • Set reasonable maxIterations on loops
  • Lazy load node configuration forms

Error Handling

  • Always validate workflows before execution
  • Provide default/else paths in branches
  • Set timeouts on approval nodes
  • Use try-catch in custom functions

Security

  • Validate all user inputs
  • Use RLS policies on all tables
  • Sanitize dynamic values in emails/webhooks
  • Audit approval decisions

Maintainability

  • Use descriptive node labels
  • Extract reusable logic into subflows
  • Document complex workflows
  • Version control workflow definitions

Support

For additional API documentation and support:
  • Review workflow examples in workflow-examples.md
  • Check the user guide in workflow-builder-guide.md
  • Contact technical support for assistance