Mandala
Tools

Delay

Pause workflow execution for a specified duration

The Delay tool provides precise timing control within your workflows by pausing execution for a specified duration. This is essential for implementing rate limiting, coordinating sequential actions, waiting for external processes, or creating scheduled intervals between operations.

With the Delay tool, you can:

  • Pause execution: Stop workflow execution for milliseconds, seconds, minutes, or hours
  • Rate limiting: Control the frequency of API calls to respect service limits
  • Coordination: Wait for external services to process data before continuing
  • Polling intervals: Create gaps between repeated checks or status updates
  • User experience: Add intentional delays for better UX (e.g., showing loading states)

The Delay tool is ideal for scenarios like waiting between API rate-limited requests, coordinating multi-step processes that depend on external timing, implementing retry logic with backoff, or creating timed sequences in automation workflows.

Usage Instructions

Add a delay to your workflow by specifying the duration in milliseconds, seconds, minutes, or hours. The workflow will pause at this point and resume after the specified time has elapsed.

Configuration

Duration Parameters

The Delay tool accepts a single parameter that defines how long to pause:

  • Duration (required): Time to wait before continuing workflow execution
    • Type: Number (integer or decimal)
    • Units: Automatically detected or specified
    • Examples: 1000 (1 second in ms), 5 (5 seconds), 2.5 (2.5 seconds)

Time Units

Specify delays in various time units for flexibility:

UnitExampleDescription
Milliseconds1000Fine-grained control (1000ms = 1 second)
Seconds30Most common unit for typical delays
Minutes5Longer delays for batch processing
Hours2Extended delays for scheduled tasks

Examples

API Rate Limiting

# Wait 1 second between API calls to respect rate limits
- type: delay
  duration: 1000  # 1 second in milliseconds

Polling with Intervals

# Check status every 5 seconds
- type: api
  url: "https://api.example.com/job/{{jobId}}/status"
  
- type: delay
  duration: 5  # 5 seconds

- type: condition
  expression: "{{status}} !== 'complete'"
  ifTrue: "check_status"  # Loop back to check again

Multi-Step Coordination

# Send email, wait 30 seconds, then send SMS
- type: gmail
  to: "user@example.com"
  subject: "Your code is ready"
  
- type: delay
  duration: 30  # 30 seconds

- type: twilio_sms
  to: "+1234567890"
  message: "Check your email for details"

Batch Processing

# Process items with 2-minute delays between batches
- type: function
  code: |
    // Process batch of items
    return processBatch(items.slice(0, 100))
    
- type: delay
  duration: 120  # 2 minutes

- type: function
  code: |
    // Process next batch
    return processBatch(items.slice(100, 200))

Retry with Backoff

# Retry failed API call with exponential backoff
- type: api
  url: "https://api.example.com/data"
  
- type: condition
  expression: "{{response.status}} !== 200"
  ifTrue: "retry_delay"
  
- type: delay
  id: "retry_delay"
  duration: "{{Math.pow(2, retryCount) * 1000}}"  # 1s, 2s, 4s, 8s...

Common Use Cases

1. Rate Limit Compliance

Respect API rate limits by adding delays between requests:

  • Social media APIs (Twitter, Instagram)
  • Email service providers
  • Payment gateways
  • Search engines

2. Polling External Services

Wait between status checks for asynchronous operations:

  • File processing completion
  • Job queue status
  • Payment verification
  • Webhook delivery confirmation

3. User Experience Optimization

Create better UX with intentional timing:

  • Show loading animations
  • Prevent rapid-fire submissions
  • Smooth transitions between steps
  • Progressive disclosure

4. Batch Processing

Space out bulk operations:

  • Import large datasets
  • Send mass notifications
  • Generate reports
  • Clean up resources

5. Scheduled Sequences

Create timed workflows:

  • Drip campaigns
  • Reminder sequences
  • Staged rollouts
  • Time-based automation

Advanced Patterns

Dynamic Delays

Calculate delay duration based on workflow state:

- type: delay
  duration: "{{retryCount * 1000}}"  # Increase delay with each retry

Conditional Delays

Only delay when certain conditions are met:

- type: condition
  expression: "{{needsDelay}}"
  ifTrue: "apply_delay"
  
- type: delay
  id: "apply_delay"
  duration: 5000

Jittered Delays

Add randomness to prevent thundering herd:

- type: delay
  duration: "{{1000 + Math.random() * 2000}}"  # Random 1-3 seconds

Performance Considerations

Maximum Delay Duration

  • Recommended maximum: 1 hour per delay block
  • For longer delays, consider using the Schedule trigger instead
  • Very long delays may impact workflow execution costs

Minimum Delay Duration

  • Minimum practical delay: 100ms
  • Delays under 100ms may have timing variance
  • Use larger values for reliable timing

Accuracy

  • Delays are accurate to within ~50-100ms
  • Network latency and system load may affect precision
  • Critical timing should account for variance

Best Practices

  1. Be Explicit: Use clear, round numbers (1000, 5000) rather than calculated values when possible
  2. Consider Costs: Long delays keep workflows active—use triggers for hours/days delays
  3. Add Context: Comment why delays are needed (rate limiting, coordination, etc.)
  4. Test Timing: Verify delays work correctly in your specific use case
  5. Handle Failures: Plan for what happens if delays are interrupted
  6. Use Appropriate Units: Match units to your use case (ms for precision, seconds for typical delays)

Limitations

  • Cannot pause indefinitely (use Schedule trigger for calendar-based delays)
  • Delays are not resumable if workflow is stopped
  • Maximum recommended delay: 1 hour
  • Timing precision: ±50-100ms
  • Schedule: Trigger workflows at specific times or intervals
  • Condition: Branch execution based on timing conditions
  • Loop: Repeat operations with delays between iterations

Notes

  • Category: tools
  • Type: delay
  • Version: 1.0.0
  • Execution: Blocks workflow thread during delay
Delay