File size: 8,229 Bytes
7ff371f 4054ee7 7ff371f 4054ee7 c11cb65 7ff371f c11cb65 7ff371f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# Category Definitions for all difficulties
CATEGORIES = {
"easy": {
0: "General",
1: "Billing",
2: "Support",
3: "Technical",
4: "HR"
},
"medium": {
0: "General",
1: "Billing",
2: "Billing-Dispute",
3: "Support",
4: "Technical",
5: "Technical-Bug",
6: "HR-Payroll",
7: "HR-Benefits",
8: "Legal",
9: "Executive"
},
"hard": {
0: "General", 1: "Billing", 2: "Billing-Dispute", 3: "Billing-Refund",
4: "Support-Urgent", 5: "Support-Normal", 6: "Technical", 7: "Technical-Bug",
8: "Technical-Feature", 9: "HR-Payroll", 10: "HR-Benefits", 11: "HR-Complaint",
12: "Legal", 13: "Legal-Contract", 14: "Legal-Compliance", 15: "Executive",
16: "Executive-Strategic", 17: "Finance", 18: "Marketing", 19: "Operations",
20: "Finance-Tax", 21: "Marketing-Social"
}
}
# Keyword overrides for early classification
CATEGORY_KWORDS = {
"Technical": ["crash", "crashes", "bug", "error", "not working", "broken", "upload fail",
"application", "software", "login fail", "404", "500", "exception",
"loading", "slow", "freeze", "hang", "install", "update failed", "glitch"],
"Billing": ["invoice", "charge", "charged", "payment", "refund", "subscription", "billing",
"amount", "price", "cost", "fee", "receipt", "transaction", "overcharged"],
"HR": ["leave", "salary", "policy", "maternity", "paternity", "holiday", "resignation",
"offer letter", "payslip", "appraisal", "human resources", "benefits"],
"Legal": ["legal", "lawsuit", "compliance", "gdpr", "contract", "terms", "court",
"attorney", "lawyer", "liability", "copyright", "trademark"],
"Marketing": ["ad", "campaign", "social media", "market", "promotion", "outreach"],
"Finance": ["budget", "expense", "tax", "audit", "fiscal"],
}
# Priority detection rules
PRIORITY_RULES = {
"urgent": ["urgent", "asap", "immediately", "critical", "emergency", "not working",
"broken", "down", "error", "failed", "crashes", "crash"],
"high": ["incorrect", "wrong", "missing", "cannot", "can't", "unable",
"problem", "issue", "complaint"],
"medium": ["review", "check", "update", "change", "request", "need", "want", "please"],
"low": ["inquiry", "question", "info", "information", "general", "curious", "wondering"]
}
# Department routing and SLAs
DEPARTMENT_MAP = {
"General": {"team": "General Enquiries", "email": "hello@company.com", "sla": "48h"},
"Billing": {"team": "Billing & Finance", "email": "billing@company.com", "sla": "24h"},
"Billing-Dispute": {"team": "Billing & Finance", "email": "billing@company.com", "sla": "24h"},
"Billing-Refund": {"team": "Billing & Finance", "email": "billing@company.com", "sla": "24h"},
"Support": {"team": "Customer Support", "email": "support@company.com", "sla": "12h"},
"Support-Urgent": {"team": "Customer Support", "email": "support@company.com", "sla": "4h"},
"Support-Normal": {"team": "Customer Support", "email": "support@company.com", "sla": "12h"},
"Technical": {"team": "Tech Support", "email": "techsupport@company.com","sla": "4h"},
"Technical-Bug": {"team": "Tech Support", "email": "techsupport@company.com","sla": "4h"},
"Technical-Feature": {"team": "Engineering", "email": "dev@company.com", "sla": "72h"},
"HR": {"team": "Human Resources", "email": "hr@company.com", "sla": "48h"},
"HR-Payroll": {"team": "Payroll Team", "email": "hr@company.com", "sla": "48h"},
"HR-Benefits": {"team": "Benefits Admin", "email": "hr@company.com", "sla": "48h"},
"HR-Complaint": {"team": "Employee Relations", "email": "hr@company.com", "sla": "24h"},
"Legal": {"team": "Legal & Compliance", "email": "legal@company.com", "sla": "72h"},
"Legal-Contract": {"team": "Legal & Compliance", "email": "legal@company.com", "sla": "72h"},
"Legal-Compliance": {"team": "Legal & Compliance", "email": "legal@company.com", "sla": "72h"},
"Executive": {"team": "Executive Office", "email": "exec@company.com", "sla": "48h"},
"Executive-Strategic": {"team": "Executive Office", "email": "exec@company.com", "sla": "48h"},
"Finance": {"team": "Finance", "email": "finance@company.com", "sla": "24h"},
"Finance-Tax": {"team": "Finance", "email": "finance@company.com", "sla": "48h"},
"Marketing": {"team": "Marketing", "email": "marketing@company.com", "sla": "48h"},
"Marketing-Social": {"team": "Marketing", "email": "marketing@company.com", "sla": "24h"},
"Operations": {"team": "Operations", "email": "ops@company.com", "sla": "24h"},
}
# Template mapping
REPLY_TEMPLATES = {
"General": """Dear Customer,
Thank you for your inquiry.
We have received your message and will respond within 48 hours.
Reference ID: {ref_id}
Priority: {priority}
Best regards,
General Enquiries Team""",
"Billing": """Dear Customer,
Thank you for contacting us regarding your billing inquiry.
We have received your request and our Billing & Finance team will review your account details within 24 hours.
What we'll do:
- Review your invoice/payment details
- Verify the transaction in question
- Send you a detailed resolution
Reference ID: {ref_id}
Priority: {priority}
Expected resolution: {sla}
If urgent, call: +1-800-BILLING
Best regards,
Billing & Finance Team""",
"Technical": """Dear Customer,
Thank you for reporting this technical issue.
Our Tech Support team has been notified and will respond within 4 hours.
Immediate steps you can try:
- Clear browser cache and retry
- Check our status page: status.company.com
- Restart the application
Reference ID: {ref_id}
Priority: {priority}
Expected resolution: {sla}
For critical issues: techsupport@company.com
Best regards,
Tech Support Team""",
"HR": """Dear Team Member,
Thank you for reaching out to Human Resources.
Your query has been received and will be handled with full confidentiality.
Our HR team will respond within 48 hours regarding:
- Policy clarifications
- Benefits & compensation
- Workplace concerns
Reference ID: {ref_id}
Priority: {priority}
Expected resolution: {sla}
Best regards,
Human Resources Team""",
"Support": """Dear Customer,
Thank you for contacting Customer Support.
We have logged your request and a support agent will be in touch within 12 hours.
Reference ID: {ref_id}
Priority: {priority}
Expected resolution: {sla}
Track your ticket: support.company.com/track/{ref_id}
Best regards,
Customer Support Team""",
}
# Hierarchy map - categories that are "close" get partial credit
CATEGORY_HIERARCHY = {
"Billing": ["Billing-Dispute", "Billing-Refund"],
"Billing-Dispute": ["Billing", "Billing-Refund"],
"Billing-Refund": ["Billing", "Billing-Dispute"],
"Support": ["Support-Urgent", "Support-Normal"],
"Support-Urgent": ["Support", "Support-Normal"],
"Support-Normal": ["Support", "Support-Urgent"],
"Technical": ["Technical-Bug", "Technical-Feature"],
"Technical-Bug": ["Technical", "Technical-Feature"],
"Technical-Feature": ["Technical", "Technical-Bug"],
"HR": ["HR-Payroll", "HR-Benefits", "HR-Complaint"],
"HR-Payroll": ["HR", "HR-Benefits"],
"HR-Benefits": ["HR", "HR-Payroll"],
"HR-Complaint": ["HR"],
"Legal": ["Legal-Contract", "Legal-Compliance"],
"Legal-Contract": ["Legal", "Legal-Compliance"],
"Legal-Compliance": ["Legal", "Legal-Contract"],
"Executive": ["Executive-Strategic"],
"Executive-Strategic": ["Executive"],
}
# Helper to find parent category
def get_parent_category(cat):
if "-" in cat:
return cat.split("-")[0]
return cat
# Helper to map any category to a template
def get_reply_template(cat):
parent = get_parent_category(cat)
return REPLY_TEMPLATES.get(cat, REPLY_TEMPLATES.get(parent, REPLY_TEMPLATES["General"]))
|