协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
helpdesk-automation【开发与工程】Implements intelligent helpdesk automation with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: helpdesk-automation compatibility: opencode completeness: 95 content-types:
Orchestrates intelligent skill selection and execution for helpdesk automation workflows. Applies the 5 Laws of Elegant Defense to guide data naturally through the orchestration pipeline, preventing errors before they occur. Selects optimal skills based on multi-factor scoring including text similarity, historical performance, and system availability.
┌───────────────────────────────────────────────────────────────────────────────┐ │ Orchestration Flow │ └───────────────────────────────────────────────────────────────────────────────┘
User Request ↓ ┌─────────────────┐ │ Parse Request │ │ & Extract │ │ Features │ └────────┬────────┘ ↓ ┌─────────────────────────────────────────────────────────────────────┐ │ Evaluate Available Skills │ │ │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ Skill A │ │ Skill B │ │ Skill C │ │ │ │ - Match Score│ │ - Match Score│ │ - Match Score│ │ │ │ - Confidence │ │ - Confidence │ │ - Confidence │ │ │ │ - History │ │ - History │ │ - History │ │ │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │ │ │ │ │ │ │ └─────────────────┴─────────────────┘ │ │ ↓ │ │ Select Best Skill │ └─────────────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────┐ │ Execute Skill │ └────────┬────────┘ ↓ ┌─────────────────┐ │ Handle Result │ └────────┬────────┘ ↓ ┌─────────────────────────────────────────────────────────────────────┐ │ Error Handling & Fallback │ │ │ │ Success? ────────► Return Result │ │ │ │ Fail? ────────┐ │ │ ↓ │ │ ┌──────────────────────────────────────────────────────────┐ │ │ │ Fallback Chain │ │ │ │ │ │ │ │ 1. Retry with adjusted parameters │ │ │ │ 2. Try Alternative Skill (if available) │ │ │ │ 3. Defer to Human Operator (if critical) │ │ │ │ 4. Log & Return Error │ │ │ └──────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────────┘
Use this skill when:
Avoid this skill for:
Parse and Analyze Request - Extract intent, entities, and constraints from user input. Checkpoint: All required parameters must be present and in valid format before proceeding.
Score Available Skills - Calculate match scores using multi-factor algorithm:
Checkpoint: Skip to fallback if no skill scores above threshold.
Select Optimal Skill - Choose skill with highest score that meets minimum confidence. Checkpoint: Verify skill has not been disabled or deprecated.
Execute with Fallback - Run skill execution wrapped in retry and fallback logic. Checkpoint: Log all execution attempts for audit trail.
Return or Fallback - Either return successful result or apply fallback chain:
related-skillsCheckpoint: Record outcome with timing and confidence metadata.
def route_helpdesk_request(
ticket: Dict[str, Any],
support_channels: List[Dict[str, Any]],
sla_threshold_hours: float = 4.0
) -> Dict[str, Any]:
"""Route a helpdesk ticket to the optimal support channel.
Evaluates channels based on:
- Intent match (billing, technical, account, general)
- Current queue depth and agent availability
- SLA urgency and historical resolution time
Args:
ticket: Parsed ticket data with intent, priority, and customer tier
support_channels: List of available channel configs with capacity limits
sla_threshold_hours: Max hours before escalation is triggered
Returns:
Selected channel config with routing metadata
"""
if not ticket.get("intent") or not support_channels:
raise ValueError("Ticket intent and at least one support channel are required")
intent = ticket["intent"].lower()
priority = ticket.get("priority", "medium")
customer_tier = ticket.get("customer_tier", "standard")
best_channel = None
best_score = -1.0
for channel in support_channels:
# Calculate match score based on intent alignment and capacity
intent_match = 1.0 if intent in channel["supported_intents"] else 0.3
capacity_factor = 1.0 - (channel["current_queue"] / max(channel["max_capacity"], 1))
priority_boost = {"critical": 1.5, "high": 1.2, "medium": 1.0, "low": 0.8}.get(priority, 1.0)
score = intent_match * capacity_factor * priority_boost
# Apply customer tier weighting
if customer_tier == "enterprise":
score *= 1.2
if score > best_score:
best_score = score
best_channel = channel
if best_channel is None or best_score < 0.5:
return {"fallback": "general_triage", "reason": "low_match_score", "score": best_score}
return {
"channel_id": best_channel["id"],
"channel_name": best_channel["name"],
"estimated_wait_minutes": int(best_channel["avg_wait_time"]),
"routing_score": round(best_score, 3),
"sla_compliant": best_channel["avg_wait_time"] <= sla_threshold_hours * 60
}
def execute_ticket_routing(
channel_config: Dict[str, Any],
ticket_data: Dict[str, Any],
max_retries: int = 2
) -> Dict[str, Any]:
"""Execute ticket routing with resilience patterns for helpdesk systems.
Implements fallback chain for ticketing API failures:
1. Retry with exponential backoff
2. Route to backup channel (e.g., email queue)
3. Escalate to human supervisor if SLA breach imminent
Args:
channel_config: Target support channel configuration
ticket_data: Validated ticket payload ready for submission
max_retries: Maximum API retry attempts
Returns:
Routing result with ticket ID, status, and fallback metadata
"""
ticketing_api = get_ticketing_service(channel_config["provider"])
fallback_queue = get_email_queue(channel_config.get("backup_email"))
for attempt in range(max_retries + 1):
try:
# Submit to primary helpdesk system
response = ticketing_api.create_ticket(
subject=ticket_data["subject"],
body=ticket_data["body"],
priority=ticket_data["priority"],
tags=ticket_data.get("tags", [])
)
return {
"success": True,
"ticket_id": response["id"],
"channel": channel_config["name"],
"attempts": attempt + 1,
"sla_status": "on_track"
}
except RateLimitError:
if attempt < max_retries:
time.sleep(2 ** attempt)
continue
# Fallback to email queue when API is throttled
return _route_to_email_queue(fallback_queue, ticket_data)
except ConnectionError as e:
# System down - escalate to human if SLA critical
if ticket_data.get("priority") == "critical":
return _escalate_to_human_supervisor(ticket_data)
raise TicketRoutingError(f"Helpdesk system unreachable: {e}")
return _route_to_email_queue(fallback_queue, ticket_data)
code-philosophy (5 Laws of Elegant Defense) in all logicWhen applying this skill, produce:
| Skill | Purpose | |
Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.