Workflow Editor
The Workflow Editor is a visual designer for creating and editing workflows. It provides a drag-and-drop interface built on ReactFlow.
Opening the Editor
import { WorkflowEditor } from "@xond/workflow";
function WorkflowEditPage({ workflowId }: { workflowId: string }) {
return (
<div className="h-screen w-screen">
<WorkflowEditor id={workflowId} />
</div>
);
}
Editor Interface
The editor consists of:
- Toolbar (left side) – Node types you can drag onto canvas
- Canvas (center) – Where you design your workflow
- Properties Panel (right side) – Configure selected node/edge
- Controls – Zoom, pan, minimap
Node Types
Start Node
Entry point of the workflow. Must have exactly one output handle.
Properties:
- Code – Unique identifier
- Name – Display name
- Description – Workflow description
Usage:
- Drag from toolbar
- Connect output handle to first State or Decision node
State Node
Regular step in the workflow. Can have UI forms and actions.
Properties:
- Code – Unique identifier
- Name – Step name
- Label – Short label
- Description – Step description
- UI Type – Form type to display
- Run Type – "0" for UI (manual), "1" for Exec (automatic)
- Actions – Array of action buttons
Usage:
- Drag from toolbar
- Connect input handle from previous node
- Connect output handle(s) to next node(s)
- Configure UI and actions in properties panel
Decision Node
Conditional branching based on workflow values.
Properties:
- Code – Unique identifier
- Name – Decision name
- Conditions – Array of conditions to evaluate
- Output Handles – Multiple handles for different outcomes
Usage:
- Drag from toolbar
- Add conditions (e.g.,
value.field === "value") - Connect output handles to different paths
- Each handle represents a condition outcome
End Node
Exit point of the workflow.
Properties:
- Code – Unique identifier
- Name – End point name
- Description – Completion message
Usage:
- Drag from toolbar
- Connect input handle from final State node
- Workflow completes when this node is reached
Adding Nodes
- Drag node type from toolbar onto canvas
- Position node where you want it
- Click node to select and configure it
Connecting Nodes
- Hover over output handle (right side of node)
- Drag to input handle (left side of target node)
- Release to create edge
Configuring Nodes
Basic Configuration
- Select node by clicking it
- Properties panel opens on right side
- Fill in properties:
- Code (required)
- Name (required)
- Label
- Description
UI Configuration
For State nodes, configure the UI:
Select UI Type:
MODEL_FORM– Auto-generated form from modelCUSTOM_FORM– Custom React componentOTP_FORM– OTP input formPASSWORD_FORM– Password inputPIN_FORM– PIN code inputDISCLAIMER_PAGE– Terms and conditionsEND_PAGE– Completion page
For MODEL_FORM:
- Select Model (e.g., "Person", "Product")
- Form will be auto-generated
For CUSTOM_FORM:
- Enter Form Class name (must be registered in FormRegistryContext)
- Component will be loaded dynamically
Actions Configuration
Add action buttons below the UI form:
- Click "Add Action"
- Configure action:
- Action Type:
NEXT– Proceed to next nodeSKIP– Skip to specified handleSUBMIT– Submit data to API endpointVERIFY– Verify data (e.g., OTP)FUNCTION– Execute custom function
- Handle – Output handle to follow (for NEXT/SKIP)
- URL – API endpoint (for SUBMIT)
- Label – Button label
- Action Type:
Decision Node Configuration
For Decision nodes:
Add Conditions:
- Field to compare
- Comparison operator (equals, not equals, greater than, etc.)
- Value to compare against
Configure Output Handles:
- Each handle represents a condition outcome
- Connect handles to different paths
Configuring Edges
Edges connect nodes and can have conditions:
- Select edge by clicking it
- Configure properties:
- Label (optional)
- Condition (for conditional edges)
Saving Workflows
- Click "Save" button in toolbar
- Workflow is validated:
- Start node must have exactly one output
- Decision nodes must have at least two outputs
- All nodes must be connected
- If valid, workflow is saved to database
Workflow Validation
The editor validates workflows before saving:
- ✅ Start node has exactly one output handle
- ✅ Decision nodes have at least two output handles
- ✅ State nodes have max one output handle
- ✅ All nodes are connected
- ✅ No circular references
Keyboard Shortcuts
- Delete – Delete selected nodes/edges
- Ctrl/Cmd + Z – Undo
- Ctrl/Cmd + Y – Redo
- Ctrl/Cmd + S – Save workflow
Best Practices
- Use descriptive codes – Make node codes meaningful (e.g., "personal-data", "otp-verification")
- Add descriptions – Help users understand each step
- Test workflows – Create test instances to verify flow
- Keep workflows simple – Avoid overly complex branching
- Document decisions – Add descriptions to decision nodes explaining conditions
Next Steps
- Learn about node configuration in detail
- Explore workflow execution
- Create custom forms