Getting Started
Build your first event-driven workflow in 5 minutes
On this page
Your First Workflow
Let's build a simple payment processing workflow that validates transactions and routes them for approval.
Step 1: Create a Template
Create a new file templates/payment-workflow.json:
{
"id": "payment-workflow-v1",
"name": "Payment Processing Workflow",
"version": "3.0",
"scenario": {
"nodes": [
{
"nodeId": "payment_source",
"type": "DataSource",
"displayName": "Payment Events",
"position": { "x": 100, "y": 100 },
"interval": 1000,
"generation": {
"type": "constant",
"hardcodedValues": [
{ "amount": 50, "merchant": "Coffee Shop" },
{ "amount": 500, "merchant": "Electronics Store" },
{ "amount": 5000, "merchant": "Car Dealer" }
]
},
"outputs": [{
"name": "payment_output",
"destinationNodeId": "payment_validator",
"destinationInputName": "payment_input"
}]
},
{
"nodeId": "payment_validator",
"type": "ProcessNode",
"displayName": "Validate Payment",
"position": { "x": 400, "y": 100 },
"inputs": [{
"name": "payment_input",
"interface": { "type": "Any", "requiredFields": [] }
}],
"outputs": [{
"name": "validated_output",
"destinationNodeId": "approval_fsm",
"destinationInputName": "transaction_input",
"transformation": {
"type": "transform",
"formula": "({ ...token, validated: true, risk: token.data.amount > 1000 ? 'high' : 'low' })"
}
}]
},
{
"nodeId": "approval_fsm",
"type": "FSMProcessNode",
"displayName": "Approval State Machine",
"position": { "x": 700, "y": 100 },
"fsm": {
"states": [
{ "name": "PENDING", "isInitial": true },
{ "name": "AUTO_APPROVED", "isFinal": true },
{ "name": "MANUAL_REVIEW", "isFinal": true }
],
"transitions": [
{
"from": "PENDING",
"to": "AUTO_APPROVED",
"trigger": "token_received",
"condition": "token.data.risk === 'low'"
},
{
"from": "PENDING",
"to": "MANUAL_REVIEW",
"trigger": "token_received",
"condition": "token.data.risk === 'high'"
}
]
},
"inputs": [{
"name": "transaction_input",
"interface": { "type": "Any", "requiredFields": [] }
}],
"outputs": [{
"name": "approved_output",
"destinationNodeId": "payment_sink",
"destinationInputName": "final_input"
}]
},
{
"nodeId": "payment_sink",
"type": "Sink",
"displayName": "Completed Payments",
"position": { "x": 1000, "y": 100 },
"inputs": [{
"name": "final_input",
"interface": { "type": "Any", "requiredFields": [] }
}]
}
]
}
}Step 2: Upload to Firebase
Upload your template to Firebase Storage:
import * as admin from 'firebase-admin';
import * as fs from 'fs';
const bucket = admin.storage().bucket();
const template = JSON.parse(fs.readFileSync('templates/payment-workflow.json', 'utf8'));
await bucket.file('pled/templates/payment-workflow-v1.json').save(
JSON.stringify(template, null, 2),
{ contentType: 'application/json' }
);
console.log('✓ Template uploaded successfully');Step 3: View in Template Editor
Navigate to the template editor to see your workflow:
http://localhost:3000/template-editor/payment-workflow-v1Click "Run Simulation" to execute your workflow and watch payments flow through the approval process!
Key Concepts
Nodes
Building blocks of workflows. Each node has a specific purpose (generate data, transform, aggregate, route, store).
Tokens
Data packets that flow through your workflow. Each token carries data and metadata (timestamp, correlationIds).
Event Sourcing
All state changes are recorded as immutable events, enabling full audit trails and time-travel debugging.
FSM (Finite State Machine)
Track business objects through their lifecycle (e.g., order: created → paid → shipped → delivered).