Skip to content

Round Robin Task

Overview

The Round Robin Task cycles sequentially through a list of values, returning the next item each time it runs. Unlike random selection, it guarantees fair, even distribution by remembering its position and rotating through all options systematically.

When to use this task:

  • Fair lead distribution to sales team
  • Rotate through multiple workers or queues
  • Cycle time slots or appointment windows
  • Team rotation for on-call duty
  • Campaign variant rotation
  • Load balancing across endpoints
  • Scheduled resource allocation

Key Features:

  • Sequential, deterministic cycling
  • State persistence (remembers position)
  • Automatic wrapping to start
  • Fair distribution guaranteed
  • Database-backed position tracking
  • Works with any list type

Quick Start

1. Add Round Robin task
2. Enter comma-separated list
3. Task cycles through list in order
4. Automatically wraps to first item
5. Save

Configuration

List of Values

Values: rep1@company.com, rep2@company.com, rep3@company.com
Values: Queue A, Queue B, Queue C, Queue D
Values: Monday, Tuesday, Wednesday, Thursday, Friday

Format: - Comma-separated values - Any data type (emails, names, IDs, URLs) - Position persists across executions - Cycles back to start automatically

How Cycling Works

List: A, B, C

Execution 1 → Returns: A (position 0)
Execution 2 → Returns: B (position 1)
Execution 3 → Returns: C (position 2)
Execution 4 → Returns: A (position 0, wrapped)
Execution 5 → Returns: B (position 1)
...

Position stored in database, survives restarts.

Output Fields

Field Description Example
task_30001_run Success status true
task_30001_run_text Message showing selection Selected: rep2@company.com
task_30001_response The selected value rep2@company.com

Real-World Examples

Example 1: Fair Lead Distribution

Scenario: Distribute incoming leads evenly across sales team

Workflow: 1. Form Submission - Lead inquiry 2. Phone Formatter - Format phone 3. Round Robin - Assign next sales rep 4. New Client - Create lead with rep 5. Workflow Note - Create follow-up task 6. Email - Notify assigned rep

Sales Team Rotation:

Values: sarah.johnson@company.com, michael.chen@company.com, jessica.rodriguez@company.com, david.kim@company.com, emily.martinez@company.com

Create Lead:

Company: {{task_55001_company}}
Status: New Lead
Responsible Manager: {{task_30001_response}}

Contact:
First Name: {{task_55001_first_name}}
Surname: {{task_55001_last_name}}
Email: {{task_55001_email}}
Cell: {{task_7001_formatted}}

Create Follow-Up Task:

Type: Call
Client ID: {{task_13001_client_id}}
Due: today
Priority: High
User Tags: {{task_30001_response}}

Note: New Lead - Contact Within 1 Hour

Lead: {{task_55001_full_name}} at {{task_55001_company}}
Phone: {{task_7001_formatted}}
Email: {{task_55001_email}}

Budget: ${{task_55001_budget}}
Timeline: {{task_55001_timeline}}
Products: {{task_55001_products}}

Source: {{task_55001_utm_source}}
Campaign: {{task_55001_utm_campaign}}

Inquiry:
{{task_55001_message}}

Notify Rep:

To: {{task_30001_response}}
Subject: New Lead Assigned: {{task_55001_company}}

Hi,

A new lead has been assigned to you via round-robin distribution:

Company: {{task_55001_company}}
Contact: {{task_55001_full_name}}
Phone: {{task_7001_formatted}}
Email: {{task_55001_email}}
Budget: ${{task_55001_budget}}

This lead is part of fair rotation. Please contact within 1 hour.

[View in CRM: Client {{task_13001_client_id}}]

Example 2: Support Ticket Queue Rotation

Scenario: Distribute support tickets across multiple queues for processing

Workflow: 1. Email Trigger - Support email received 2. Match to Client - Find customer 3. AI Prompt - Classify ticket category 4. Round Robin - Assign processing queue 5. Webhook Out - Send to queue system 6. Workflow Note - Create ticket record

Processing Queues:

Values: queue-general-1, queue-general-2, queue-general-3, queue-general-4

Send to Queue:

URL: https://queue-system.company.com/api/v1/tickets
Method: POST
Headers:
  Authorization: Bearer {{api_token}}
  Content-Type: application/json

Body:
{
  "queue": "{{task_30001_response}}",
  "customer_id": "{{task_15001_client_id}}",
  "subject": "{{task_2001_subject}}",
  "category": "{{task_38001_category}}",
  "priority": "{{task_38001_priority}}",
  "content": "{{task_2001_body}}",
  "from_email": "{{task_2001_from_email}}",
  "assigned_at": "{{current_timestamp}}"
}

Create Ticket Record:

Type: To-Do
Client ID: {{task_15001_client_id}}
Due: today
Priority: Medium

Note: Support Ticket Queued

Queue: {{task_30001_response}}
From: {{task_2001_from_email}}
Subject: {{task_2001_subject}}
Category: {{task_38001_category}}

Ticket will be processed by next available agent in {{task_30001_response}}.

Example 3: Campaign Variant Rotation

Scenario: Rotate through email template variants for continuous testing

Workflow: 1. Schedule Trigger - Daily at 9 AM 2. MySQL Query - Get subscribers 3. Round Robin - Select campaign variant 4. Loop - For each subscriber 5. Email - Send with selected variant

Campaign Variants:

Values: template-short-v1, template-medium-v2, template-long-v3, template-visual-v4

Get Subscribers:

SELECT subscriber_id, email, first_name, last_name, segment
FROM email_subscribers
WHERE active = 1 
AND last_email_sent < DATE_SUB(NOW(), INTERVAL 7 DAY)
LIMIT 1000

Send Email Campaign:

Loop through: {{task_43001_rows}}

To: {{task_29001_row.email}}
Template: {{task_30001_response}}

Variables:
- first_name: {{task_29001_row.first_name}}
- last_name: {{task_29001_row.last_name}}
- segment: {{task_29001_row.segment}}
- variant: {{task_30001_response}}
- unsubscribe_url: https://company.com/unsub/{{task_29001_row.subscriber_id}}

Log Campaign Send:

MySQL Query (in loop):
INSERT INTO campaign_sends 
(subscriber_id, variant, sent_date)
VALUES ({{task_29001_row.subscriber_id}}, 
        '{{task_30001_response}}', 
        NOW())

Result: Each daily campaign uses different variant, ensuring all templates tested equally over time.

Example 4: On-Call Duty Rotation

Scenario: Rotate weekly on-call assignments across engineering team

Workflow: 1. Schedule Trigger - Every Monday 8 AM 2. Round Robin - Assign next engineer 3. MySQL Query - Update on-call schedule 4. Email - Notify team of rotation 5. Webhook Out - Update PagerDuty/OpsGenie

Engineering Team:

Values: alex.engineering@company.com, sarah.devops@company.com, mike.backend@company.com, lisa.frontend@company.com, james.fullstack@company.com

Update Schedule:

INSERT INTO oncall_schedule 
(engineer_email, week_start, week_end, assigned_date)
VALUES ('{{task_30001_response}}',
        CURDATE(),
        DATE_ADD(CURDATE(), INTERVAL 7 DAY),
        NOW())

Notify Team:

To: engineering-team@company.com
Subject: On-Call Rotation: Week of {{current_date}}

This week's on-call engineer: {{task_30001_response}}

Rotation Schedule:
- Current: {{task_30001_response}}
- Duration: {{current_date}} to {{current_date_plus_7_days}}

Emergency Contact:
- Email: {{task_30001_response}}
- Slack: @{{task_30001_response_username}}
- Phone: Check internal directory

[View Full Schedule]

Update Alerting System:

URL: https://api.pagerduty.com/oncalls
Method: POST

Body:
{
  "oncall_user": "{{task_30001_response}}",
  "start": "{{current_timestamp}}",
  "end": "{{timestamp_plus_7_days}}",
  "escalation_policy": "engineering-primary"
}

Example 5: Multi-Region Load Balancing

Scenario: Distribute API requests across regional data centers

Workflow: 1. Webhook In - API request received 2. Round Robin - Select region 3. Variable - Store selected region 4. Webhook Out - Forward to regional endpoint 5. MySQL Query - Log routing

Regional Endpoints:

Values: https://us-east.api.company.com, https://us-west.api.company.com, https://eu-central.api.company.com, https://ap-southeast.api.company.com

Store Region:

Variable Name: target_region
Value: {{task_30001_response}}

Forward Request:

URL: {{task_30001_response}}/v1/process
Method: {{task_46001_method}}
Headers:
  Authorization: Bearer {{task_46001_auth_token}}
  X-Forwarded-For: {{task_46001_ip_address}}
  X-Request-ID: {{task_46001_request_id}}
  X-Routed-Via: round-robin-lb

Body: {{task_46001_body}}

Log Distribution:

INSERT INTO api_routing_log
(request_id, target_region, source_ip, timestamp, method, endpoint)
VALUES ('{{task_46001_request_id}}',
        '{{task_30001_response}}',
        '{{task_46001_ip_address}}',
        NOW(),
        '{{task_46001_method}}',
        '{{task_46001_endpoint}}')

Monitoring Query (separate workflow):

-- Check distribution balance
SELECT target_region, COUNT(*) as request_count
FROM api_routing_log
WHERE timestamp > DATE_SUB(NOW(), INTERVAL 1 HOUR)
GROUP BY target_region

Best Practices

List Design

  1. Equal capacity items - All options should handle similar load
  2. Active items only - Remove unavailable options promptly
  3. Reasonable size - 3-10 items typical, more for specific cases
  4. Update carefully - Changing list resets position
  5. Document rotation - Track who/what is in rotation

Fair Distribution

  1. One task per workflow - Multiple round robins create separate rotations
  2. Consistent execution - Run same workflow for fair distribution
  3. Monitor balance - Check if distribution is even
  4. Handle failures - Failed assignments still increment position
  5. Reset when needed - Contact admin to reset position if needed

Performance

  1. Database-backed - Position stored reliably
  2. Fast execution - Minimal overhead
  3. Concurrent safe - Database handles simultaneous requests
  4. State survives restarts - Position persists across system restarts

vs Random Task

Use Round Robin when: - Fair distribution required - Need to guarantee everyone gets turn - Predictable cycling needed - Balanced load important

Use Random when: - True randomness needed - A/B testing - No fairness requirement - Independent selections

Troubleshooting

Same Value Returned Multiple Times

Issue: Not cycling properly

Causes: - Multiple separate workflows using round robin - Different task configurations - Database position not updating

Solution: - Use single workflow for consistent rotation - Check task configuration is identical - Verify database connectivity

Skipped Values

Issue: Some list items never selected

Cause: List was modified while task running

Solution: - Don't modify list during active use - Position may become misaligned with new list - Contact admin to reset position if needed

Position Not Persisting

Issue: Always returns first item

Cause: Database write failure or task misconfiguration

Solution: - Check database connection - Verify task has unique ID - Review system logs for errors

Uneven Distribution

Issue: Some team members get more leads

Causes: - Multiple entry points to workflow - Manual assignments mixed with automation - Recent list changes

Solution: - Consolidate to single workflow - Use round robin exclusively (no manual overrides) - Monitor distribution with reporting

Need to Reset Position

Issue: Want to start from beginning

Solution: - Contact system administrator - Position stored in task_mapping table - Can be manually reset if needed

Frequently Asked Questions

Can I reset the position?

Not directly in the workflow. Contact administrator to reset position in database.

What happens if I change the list?

Position continues from current index. If new list is shorter, position may wrap immediately.

Can I see current position?

No direct output. Position managed internally. Monitor by logging selections.

Does it work with empty lists?

No, list must have at least one item.

Can I weight the distribution?

Not directly. Repeat values in list to simulate weighting:

# 60% Rep1, 40% Rep2
Values: rep1, rep1, rep1, rep2, rep2

What if a list item is unavailable?

Task still returns that item and increments. Handle unavailability in subsequent If task or webhook.

Can multiple workflows share position?

No, each task instance maintains its own position.


  • Random - For non-deterministic selection
  • Key Match - Map selected value to actions
  • Loop - Process items in list
  • Variable - Store selected value for reuse
  • If Task - Conditional logic based on selection
  • MySQL Query - Track distribution statistics