Introduction to Workflows

What are Workflows?

A workflow is a state machine-based system for modeling and executing complex business processes. Unlike simple data transformation pipelines, workflows manage processes that have multiple states, conditional transitions, and long-running operations that may span hours, days, or weeks.

The Ambience Workflow module provides a visual designer, a powerful execution engine, and deep integration with the ETL system to create sophisticated business process automation.

Why Use Workflows?

State-Dependent Business Processes

Many business processes cannot be modeled as simple linear pipelines. They require:

  • Multiple states - A leave request might be Draft, Pending Approval, Approved, Rejected, or Cancelled
  • Conditional transitions - Different approval paths based on leave duration, employee grade, or manager availability
  • Event-driven progression - External events (approvals, rejections, timeouts) trigger state changes
  • Long-running operations - Processes that wait for human input or external system responses
  • Audit requirements - Complete history of who did what and when

Workflows excel at modeling these scenarios.

Key Benefits

Visual Design & Maintenance - Design complex processes visually using the Workflow Designer - State diagrams are self-documenting and easy to understand - Non-technical stakeholders can review and validate process flows - Changes are visible and traceable

Separation of Concerns - Process logic (states, transitions) separate from data transformation (ETL chains) - Business analysts can modify process flows without touching data logic - ETL developers can optimize transformations without affecting process structure

Audit Trail & Compliance - Every state transition is logged with user, timestamp, and event - Complete history stored in elxHistory field - Configurable audit logging for public and private data changes - Supports compliance requirements (SOX, GDPR, etc.)

Event-Driven Architecture - Workflows respond to events from REST API, ETL chains, or scheduled timers - Decouple event sources from process logic - Support for deferred/scheduled events (reminders, escalations, timeouts)

Scalability & Reusability - One workflow definition supports unlimited instances - Instances isolated in separate database collections - Workflow definitions can be exported, versioned, and reused

When to Use Workflows vs ETL Chains

Use Workflows When Use ETL Chains When
Process has multiple states Linear data transformation
Human interaction required Fully automated processing
Long-running (hours/days/weeks) Short-running (seconds/minutes)
Conditional branching based on state Conditional branching based on data
Audit trail is critical Audit trail is optional
Process may pause and resume Process runs to completion
External events drive progression Data availability drives progression

Integration: Workflows and ETL chains work together. Workflows use ETL chains for data transformation at state transitions, and ETL chains can create workflow instances and send events.

Common Use Cases

Approval Workflows

  • Leave requests, expense claims, purchase orders
  • Document review and approval
  • Access requests and provisioning
  • Contract approvals

Document Lifecycle Management

  • Draft → Review → Approved → Published → Archived
  • Version control and approval gates
  • Expiration and renewal processes

Issue Tracking & Ticketing

  • New → Open → In Progress → Resolved → Closed
  • Assignment, escalation, and SLA tracking
  • Reopening and reassignment

Onboarding & Offboarding

  • Employee onboarding checklists
  • System access provisioning
  • Equipment allocation and return
  • Multi-step compliance processes

Multi-Step Form Wizards

  • Complex data entry with validation at each step
  • Save and resume capability
  • Conditional steps based on previous answers

Long-Running Business Processes

  • Order fulfillment (order → payment → shipping → delivery)
  • Loan applications (application → verification → approval → disbursement)
  • Insurance claims processing
  • Customer support case management

Architecture Overview

┌─────────────────┐
│ Workflow        │  Design workflows visually
│ Designer        │  (States, Transitions, ETL integration)
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│ Workflow        │  Stored definition
│ Definition      │  (JSON in MongoDB)
└────────┬────────┘
         │
         │ (instantiate)
         ▼
┌─────────────────┐
│ Workflow        │  Runtime instance
│ Instance        │  (State + Data in MongoDB)
└────────┬────────┘
         │
         │ (events via REST API or ETL)
         ▼
┌─────────────────┐
│ Workflow        │  Event processing
│ Engine          │  State transitions
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│ ETL Chains      │  Data transformation
│                 │  Business logic execution
└─────────────────┘

Next Steps