Approval Workflow

Learn how it works

State Diagram

Draft

Initial request creation

Submitted

Awaiting decision

approve
reject

Approved

Final

Request approved

Rejected

Final

Request rejected

Current State
Next State

Step 1 of 3: Initialize

Create a new approval request in draft state

Guard Evaluation

N/A (initialization)

✓ PASS

Effect

Set initial state data

The state machine is created in its initial state (draft) with the initial data payload. No transitions have occurred yet.

State Data After Transition → draft

{
  "requestId": "REQ-001",
  "title": "New Equipment Purchase",
  "requestor": "alice@company.com",
  "amount": 5000
}

Key Concepts

State Transitions

State machines move from one state to another via events. Each transition has a source state, target state, and event type.

Guards

Guards are JSON Logic expressions that must evaluate to true for a transition to occur.

Effects

Effects modify the state data when a transition executes using the merge operation.

Final States

States marked as final prevent further transitions. Once reached, the workflow is complete.

Ready to try it yourself?

Switch to Interactive Playground mode to create a real state machine on the metagraph!