Workflow Automation Module

The Workflow Automation module provides a powerful visual builder for creating automated workflows similar to n8n or Zapier. Design complex automation sequences with a drag-and-drop interface, connect nodes with conditional logic, and execute workflows automatically or on-demand.

Overview

Key Features:

  • Visual Builder: Drag-and-drop canvas powered by React Flow
  • Node System: Triggers, Actions, Conditions, and Transformers
  • Extensible: Any module can register custom nodes
  • Execution Engine: Async execution with retry logic and detailed logging
  • Multiple Triggers: Manual, scheduled (cron), webhooks, or events
  • Conditional Logic: Branch workflows with If/Else and Switch nodes
  • Data Transformation: Map, filter, and transform data between nodes
  • Execution History: Full audit trail with per-node logs

Architecture Overview

                     ┌─────────────────────────────────────────┐
                     │           WORKFLOW BUILDER              │
                     │         (React Flow Canvas)             │
                     └─────────────────┬───────────────────────┘
                                       │
                                       ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                            BACKEND API                                   │
│  ┌──────────────┐   ┌──────────────┐   ┌──────────────────────────────┐│
│  │WorkflowService│   │ExecutionEngine│   │      NodeRegistry          ││
│  │  - CRUD       │   │  - Execute   │   │  - Node discovery          ││
│  │  - Validate   │   │  - Retry     │   │  - Compatibility check     ││
│  │  - Export     │   │  - Log       │   │  - Module extension        ││
│  └──────────────┘   └──────────────┘   └──────────────────────────────┘│
└─────────────────────────────────────────────────────────────────────────┘
                                       │
                                       ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                           DATABASE                                       │
│  workflows → workflow_nodes → workflow_connections                      │
│  workflow_executions → workflow_execution_logs                          │
└─────────────────────────────────────────────────────────────────────────┘

Quick Start

1. Enable the Module

  1. Go to Integrations > Modules
  2. Find Workflow Automation in the Automation category
  3. Click Enable

2. Run Migrations

cd backend
php artisan tenants:migrate

3. Create Your First Workflow

  1. Navigate to Workflows in the sidebar
  2. Click Create Workflow
  3. Give it a name and description
  4. Start adding nodes from the palette

4. Build Your Workflow

  1. Add a Trigger: Drag a trigger node (Manual, Schedule, or Webhook) to the canvas
  2. Add Actions: Drag action nodes (Send Email, HTTP Request, etc.)
  3. Connect Nodes: Click and drag from output handles to input handles
  4. Configure: Double-click nodes to set their configuration
  5. Save: Click Save to persist your workflow

5. Execute

  1. Click Run to execute manually
  2. Or activate the workflow for automatic execution

Node Categories

Nodes are organized into four categories:

Category Color Purpose Examples
Trigger Green Start workflow execution Manual, Schedule, Webhook, Order Created
Action Blue Perform operations Send Email, HTTP Request, Delay
Condition Yellow Branch workflow logic If/Else, Switch
Transformer Purple Transform data Map, Filter, Set Variable

Built-in Nodes

Triggers (3)

Node Description
Manual Trigger Start workflow manually via UI or API
Schedule Trigger Run on a cron schedule
Webhook Trigger Receive HTTP POST requests

Actions (4)

Node Description
Send Email Send email to recipients
HTTP Request Make external API calls
Delay Wait for specified duration
Set Variable Store value in workflow context

Conditions (2)

Node Description
If/Else Binary branching (true/false)
Switch Multi-way branching

Transformers (2)

Node Description
Map Transform data structure
Filter Filter array items

Module Extensions

Other modules can register their own workflow nodes. Currently implemented:

Orders Module

Node Category Description
Order Created Trigger Fires when new order is created
Order Status Changed Trigger Fires when order status changes
Update Order Status Action Change order status

See Extending Workflows for how to add nodes from your module.

Execution Flow

When a workflow runs:

  1. Create Execution Record - Status: pending
  2. Find Entry Points - Nodes marked as triggers
  3. Execute Recursively:
    • Execute trigger node with input data
    • Log input/output to execution log
    • Follow connections to next nodes
    • Handle conditional branching
    • Retry on failure if configured
  4. Complete/Fail - Mark execution with final status
Manual Trigger → HTTP Request → If/Else → [true]  → Send Email
                                        → [false] → Set Variable → ...

Workflow States

Status Description
Draft Being edited, cannot be executed automatically
Active Ready to run, triggers will fire
Paused Temporarily disabled
Archived Soft-deleted, not shown by default

Trigger Types

Type When it Fires
Manual User clicks Run or calls execute API
Schedule Cron expression matches current time
Webhook HTTP POST to webhook URL
Event System event (order created, etc.)

Data Flow

Data flows through the workflow as a JSON object:

// Trigger output
{
  "order_id": "123",
  "customer_email": "john@example.com",
  "total": 99.99
}

// Each node receives previous output as input
// and can add/modify data

// After Send Email node
{
  "order_id": "123",
  "customer_email": "john@example.com",
  "total": 99.99,
  "_email_sent": true,
  "_email_to": "john@example.com",
  "_sent_at": "2025-01-16T10:30:00Z"
}

Expressions

Use {{path.to.value}} syntax in node configuration to reference data:

To: {{customer_email}}
Subject: Order {{order_id}} Confirmation
Body: Your order total is ${{total}}

Dashboard Widgets

The module provides two dashboard widgets:

Workflow Statistics

  • Total workflows (active/paused/draft)
  • Executions today/this week/this month
  • Success/failure rates

Recent Executions

  • Latest execution results
  • Click to view details
  • Real-time updates

Next Steps