Understanding Assignment Rules
Assignment rules in Frappe Helpdesk:- Automatically assign tickets to agents or teams based on conditions
- Balance workload across team members
- Route by expertise to ensure proper skill matching
- Operate in priority order when multiple rules match
- Support scheduling for time-based assignments
Assignment Rule Components
Based on the Assignment Rule doctype and implementation:Basic Settings
- Rule Name: Descriptive identifier
- Description: Purpose and scope of the rule
- Priority: Order of evaluation (higher priority = evaluated first)
- Disabled: Toggle to deactivate without deleting
Assignment Conditions
- Assign Condition: When to assign tickets (JSON or Python expression)
- Unassign Condition: When to remove assignments
- Document Type: Always “HD Ticket” for Frappe Helpdesk
Assignees
- Users: List of agents who can receive assignments
- Assignment Strategy: How to distribute tickets among users
Creating Assignment Rules
Create New Rule
Click “New Assignment Rule” and configure:
- Name: e.g., “Bug Reports to QA Team”, “VIP Customers to Senior Agents”
- Description: Brief explanation of what this rule handles
- Priority: Higher number = evaluated first (use 1-10 range)
- Document Type: HD Ticket (pre-selected)
Define Assignment Conditions
Specify when this rule should assign tickets:Using Portal View (Recommended):Using Python Expression:
- Use the visual condition builder in the portal
- Automatically generates JSON format
- Easier for non-technical users
Add Assignees
In the Assignment Rule User table, add agents:
- Click “Add Row”
- Search for agent by name or email
- Add multiple agents for round-robin distribution
- Order matters: first agent receives first matching ticket
Configure Assignment Strategy
Choose how tickets are distributed:
- Round Robin: Rotate assignments evenly among all users
- Load Balancing: Assign to user with fewest open tickets
- Based on Field: Use a ticket field to determine assignee
Set Unassign Conditions (Optional)
Define when to automatically remove assignments:This helps keep agent workload counts accurate.
Assignment rules are evaluated in priority order. If multiple rules match, the highest priority rule is applied. Implementation:
helpdesk/api/assignment_rule.py:5-29Assignment Conditions
Condition Format
Conditions can be specified in two formats: JSON Format (Portal-Generated):Available Fields
You can use any field from the HD Ticket doctype:subject,descriptionstatus,priority,ticket_typeagent_group,raised_by,customervia_customer_portal,is_first_ticketsla,template- Custom fields you’ve added
Condition Validation
The system validates conditions on save (seehelpdesk/extends/assignment_rule.py:15-30):
- JSON format must be valid
- Python expressions must be syntactically correct
- Use the portal view to avoid syntax errors
Assignment Strategies
Round Robin
Distributes tickets evenly across all users in the assignment list:- First ticket → First user
- Second ticket → Second user
- Last ticket → Last user
- Next ticket → Back to first user
Load Balancing
Assigns tickets to the agent with the fewest currently open tickets:- Counts open tickets assigned to each user
- Assigns to user with lowest count
- Helps prevent agent overload
Based on Field
Uses a ticket field value to determine the assignee:- Match agent based on ticket property
- Useful for territory, product, or customer-based routing
- Requires field to contain agent ID or email
Agent Groups and Teams
Assignment rules work in conjunction with agent groups:Team-Based Assignment
Create Agent Groups
Define teams in Settings > Teams:
- Support Team
- QA Team
- Billing Team
- Technical Team
Restricting by Agent Group
In HD Settings, you can configure:- Restrict Tickets by Agent Group: Agents only see tickets for their groups
- Assign Within Team: Ensure tickets stay within assigned team
- Do Not Restrict Tickets Without Group: Allow flexible handling of ungrouped tickets
hd_settings.json:11-15 for these configuration options.
Assignment Scheduling
Route tickets based on time of day or day of week:Time-Based Rules
Define Shift Schedules
Create assignment rules for different shifts:
- Morning shift (8 AM - 4 PM)
- Evening shift (4 PM - 12 AM)
- Night shift (12 AM - 8 AM)
Weekend and Holiday Routing
Priority and Rule Order
Assignment rules are evaluated in priority order:Priority Best Practices
- Highest Priority (9-10): Urgent or VIP customer rules
- High Priority (7-8): Time-sensitive or critical tickets
- Medium Priority (4-6): Specific routing by type or category
- Low Priority (1-3): General catch-all rules
- Base Priority (0): Default fallback rule
Base Support Rotation
The system automatically creates a base assignment rule:- Named “Base Support Rotation”
- Priority: 0
- Serves as catch-all for unmatched tickets
- Referenced in HD Settings (
hd_settings.json:90-95)
Manual Assignment Override
Agents can manually assign or reassign tickets:Manual Assignment
Select Agent
Search for and select the agent. Only agents (users with HD Agent role) can be assigned.
Self-Assignment
Agents can assign tickets to themselves:Workload Distribution
Preventing Overload
Use load balancing to distribute work fairly:- Count Open Tickets: System counts tickets per agent
- Assign to Least Loaded: New ticket goes to agent with fewest open tickets
- Rebalance on Status Change: Counts update when tickets are resolved
Capacity Limits
While not built-in, you can implement capacity limits:Unassignment Automation
Automatically remove assignments when conditions are met:Unassign on Resolution
Unassign on Transfer
Unassign on Escalation
Notifications
When tickets are assigned:- Agent Notification: Assigned agent receives an in-app notification
- Notification Type: “Assignment” notification (see
hd_ticket.py:232-241) - Email Notification: Optional email alert based on agent preferences
Testing Assignment Rules
Create Test Tickets
Create tickets that match your rule conditions:
- Set ticket_type, priority, etc. to match conditions
- Use different combinations to test all rules
Verify Assignments
Check that tickets are assigned to the expected agents:
- Review assignment history
- Verify correct rule was applied
- Check assignment strategy (round-robin, load balancing)
Test Edge Cases
Try scenarios like:
- No matching rules (should use base rotation)
- Multiple matching rules (should use highest priority)
- All agents at capacity
- Unassign conditions
Common Assignment Patterns
By Ticket Type
By Customer Tier
By Priority
By Channel
By First-Time Customer
By Agent Group
Best Practices
Rule Design
- Start Simple: Begin with basic rules and add complexity as needed
- Use Clear Names: Descriptive names help with troubleshooting
- Document Conditions: Add descriptions explaining rule logic
- Test Thoroughly: Verify rules work as expected before going live
- Monitor Performance: Track metrics to ensure rules are effective
Condition Writing
- Use Portal Builder: Visual builder prevents syntax errors
- Keep Conditions Simple: Complex logic is harder to maintain
- Avoid Hardcoding: Use dynamic lookups instead of static values
- Handle Null Values: Check for existence before comparing
- Test Edge Cases: Verify behavior with missing or unusual data
Team Management
- Balance Workload: Use load balancing for fair distribution
- Match Expertise: Route tickets to qualified agents
- Cross-Train Teams: Avoid single points of failure
- Set Capacity Limits: Prevent agent overload
- Review Regularly: Adjust rules as team composition changes
Maintenance
- Audit Rules Quarterly: Review and update outdated rules
- Remove Unused Rules: Delete or disable rules no longer needed
- Update Assignee Lists: Keep agent lists current
- Monitor Assignment Metrics: Track which rules are most active
- Gather Team Feedback: Ask agents if routing is effective
Troubleshooting
Tickets Not Assigned
Issue: New tickets aren’t being assigned automatically Solutions:- Check that assignment rules are enabled
- Verify conditions match ticket properties
- Ensure assignee list includes active agents
- Review rule priority order
- Check for validation errors in conditions
Wrong Agent Assigned
Issue: Tickets go to incorrect agents Solutions:- Review rule conditions for accuracy
- Check priority order of rules
- Verify ticket field values match expected
- Test conditions with sample data
- Review agent group membership
Uneven Distribution
Issue: Some agents get too many tickets Solutions:- Use load balancing instead of round-robin
- Check if agent is in multiple assignment rules
- Review manual assignment overrides
- Verify all agents are active
- Consider implementing capacity limits
Rules Not Evaluating
Issue: Assignment rules don’t seem to run Solutions:- Check that document type is “HD Ticket”
- Verify rule is not disabled
- Check for syntax errors in conditions
- Review system logs for errors
- Ensure base support rotation exists