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
- Go to Integrations > Modules
- Find Workflow Automation in the Automation category
- Click Enable
2. Run Migrations
cd backend
php artisan tenants:migrate
3. Create Your First Workflow
- Navigate to Workflows in the sidebar
- Click Create Workflow
- Give it a name and description
- Start adding nodes from the palette
4. Build Your Workflow
- Add a Trigger: Drag a trigger node (Manual, Schedule, or Webhook) to the canvas
- Add Actions: Drag action nodes (Send Email, HTTP Request, etc.)
- Connect Nodes: Click and drag from output handles to input handles
- Configure: Double-click nodes to set their configuration
- Save: Click Save to persist your workflow
5. Execute
- Click Run to execute manually
- 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:
- Create Execution Record - Status:
pending - Find Entry Points - Nodes marked as triggers
- 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
- 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
- Node Types - Deep dive into all node types
- Execution Engine - How workflows execute
- API Reference - Complete API documentation
- Extending Workflows - Add custom nodes
- Examples - Common workflow patterns