Centrali's new Workflow Automation feature makes it easy to build complex, multi-step processes. In this guide, we'll walk through three common patterns: order processing, approval workflows, and data synchronization.
Prerequisites
Before we begin, make sure you have:
- A Centrali workspace (v2.9.0 or later)
- Some functions ready to use (or we'll create them)
- Basic familiarity with the Centrali console
Pattern 1: Order Processing Pipeline
Let's build an order processing workflow that validates orders, processes payments, and sends confirmations.
Step 1: Create the Automation
Navigate to Automations and click + Automation:
- Name: Complete Order Processing Pipeline
- Slug: complete-order-processing-pipeline
- Trigger Type: Event (record created on your orders collection)
Step 2: Add the Validation Step
Click Add Step and choose Compute Step:
Step ID: validate-orderStep Name: Validate OrderFunction: [Select your validation function]Timeout: 30000ms
Your validation function should return an object like:
// Validation function example// api, triggerParams, and executionParams are available as globalsasync function run() {const order = executionParams.data;// Check inventoryconst inventory = await api.queryRecords('inventory', {filter: { productId: order.productId }});if (inventory.data[0]?.data?.quantity < order.quantity) {return { isValid: false, error: 'Insufficient inventory' };}// Validate shipping addressif (!order.shippingAddress?.zipCode) {return { isValid: false, error: 'Invalid shipping address' };}return { isValid: true, order };}
Step 3: Add a Decision Step
After validation, we need to check if the order is valid:
Step ID: check-validationStep Name: Check Validation ResultType: Decision Step
Add a case:
- Condition:
steps.validate-order.output.isValidequalstrue - Then go to: process-payment
Set the default (no case matches) to go to handle-validation-error.
Step 4: Add Payment Processing
Step ID: process-paymentStep Name: Process PaymentFunction: [Select your payment function]Timeout: 60000ms
Step 5: Add Error Handling
Step ID: handle-validation-errorStep Name: Handle Validation ErrorFunction: [Select your error handling function]
This function can update the order status and notify the customer.
Step 6: Add Confirmation
Step ID: send-confirmationStep Name: Send ConfirmationFunction: [Select your email function]
Complete Workflow
Your workflow should look like this:
[Event: Order Created]↓[Validate Order]↓[Check Validation] ──(invalid)──→ [Handle Error]↓ (valid)[Process Payment]↓[Send Confirmation]
Pattern 2: Approval Workflow with Timeout
Let's build a leave request approval system with a 48-hour timeout.
Step 1: Create the Automation
- Trigger Type: On-Demand (requests submitted via API)
Step 2: Notify the Approver
Step ID: notify-approverStep Name: Notify ApproverFunction: [Select your notification function]
The function receives the leave request data and sends an email to the manager.
Step 3: Add a Delay Step
Step ID: wait-for-responseStep Name: Wait for ResponseType: Delay StepDelay Duration: 172800000ms (48 hours)
Note: In a real system, you'd want to check for approval status periodically or use a webhook callback. For this example, we're simulating a wait period.
Step 4: Check Approval Status
Step ID: check-approvalStep Name: Check Approval StatusFunction: [Select your status check function]
This function queries the request record to see if it was approved:
async function run() {const requestId = executionParams.requestId;const request = await api.fetchRecord(requestId);return {status: request.data.approvalStatus,approved: request.data.approvalStatus === 'approved',requestId};}
Step 5: Decision Based on Status
Step ID: route-by-statusType: Decision Step
Cases:
steps.check-approval.output.statusequalsapproved→execute-approvedsteps.check-approval.output.statusequalsrejected→notify-rejection- Default →
escalate(timeout reached, no response)
Step 6: Handle Each Path
Add compute steps for:
execute-approved— Update calendar, send confirmationnotify-rejection— Notify the requester of rejectionescalate— Notify HR of unhandled request
Pattern 3: Data Synchronization
Let's build a workflow that syncs customer data to an external CRM when records are updated.
Step 1: Create the Automation
- Trigger Type: Event (record updated on customers collection)
Step 2: Transform Data
Step ID: transform-dataStep Name: Transform to CRM FormatFunction: [Select your transform function]
async function run() {const customer = executionParams.data;// Map Centrali fields to CRM fieldsreturn {crmPayload: {external_id: customer.id,first_name: customer.firstName,last_name: customer.lastName,email: customer.email,company: customer.companyName,phone: customer.phone,custom_fields: {plan_type: customer.subscriptionTier,signup_date: customer.createdAt}}};}
Step 3: Push to External API
Step ID: push-to-crmStep Name: Push to CRMFunction: [Select your API function]Timeout: 30000ms
async function run() {const payload = executionParams.crmPayload;const response = await api.httpPost('https://api.crm.example.com/contacts', payload, {headers: {'Authorization': 'Bearer ' + process.env.CRM_API_KEY}});if (response.status >= 400) {throw new Error(`CRM API error: ${response.status}`);}const result = await response.json();return { success: true, crmId: result.id };}
Important: The orchestration engine will automatically retry failed steps with exponential backoff, making your sync resilient to temporary API failures.
Step 4: Log the Result
Step ID: log-syncStep Name: Log Sync ResultFunction: [Select your logging function]
This creates an audit trail of all syncs.
Tips for Production Workflows
1. Use Meaningful Step IDs
Step IDs are used in decision conditions and debugging. Use descriptive names like validate-shipping-address instead of step-1.
2. Configure Timeouts Appropriately
- Fast operations (database queries): 5-10 seconds
- API calls: 30-60 seconds
- Complex processing: 2-5 minutes
3. Handle Errors Gracefully
Always plan for failures:
- Use decision steps to check for error states
- Add error handling steps that notify operators
- Consider retry strategies for transient failures
4. Monitor Your Runs
Check the Runs tab regularly:
- Look for failed runs and investigate root causes
- Monitor execution times to identify bottlenecks
- Use the Activity Log to understand timing
5. Test with On-Demand Triggers
Before enabling event or scheduled triggers:
- Create a version of your orchestration with an on-demand trigger
- Test with sample data
- Verify each step executes correctly
- Switch to the production trigger type
Summary
Centrali Automation makes it straightforward to build complex workflows:
- Order processing — Chain validation, payment, and notification steps
- Approval flows — Use delay steps and decisions for human-in-the-loop processes
- Data sync — Leverage automatic retry for reliable integrations
Check out the Automation documentation for more details and API reference.