ตรรกะการจัดเส้นทางและยกระดับทิกเก็ต
จำแนกเจตนา ส่งต่อไปยังเอเจนต์ผู้เชี่ยวชาญ และกำหนดเงื่อนไขการยกระดับ
ตรรกะการจัดเส้นทางและยกระดับทิกเก็ต เป็นบทเรียน AI Agents ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน AI Agents และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส AI Agents มีบทเรียนทั้งหมด 4 บทเรียน
ปัญหาการกำหนดเส้นทาง
เจ้าหน้าที่บริการลูกค้าได้รับข้อความหลากหลายหลายพันข้อความต่อวัน ทั้งข้อโต้แย้งเรื่องการเรียกเก็บเงิน การรีเซ็ตรหัสผ่าน ข้อบกพร่องของผลิตภัณฑ์ ความล่าช้าในการจัดส่ง และคำขอฟีเจอร์ การส่งทุกข้อความไปยังตัวจัดการเดียวกันทำให้ตอบได้ช้าและมีคุณภาพต่ำ
การกำหนดเส้นทางรายการแจ้งปัญหา จะแบ่งประเภทของแต่ละข้อความและส่งไปยังทีมที่เหมาะสมที่สุดในการแก้ไข
การจำแนกเจตนาด้วย LLM
ชั้นกำหนดเส้นทางจะเรียกใช้ LLM พร้อมพรอมต์การจำแนกประเภท โมเดลจะส่งคืนผลลัพธ์ที่มีโครงสร้าง พร้อมป้ายกำกับ intent และคะแนน confidence
import openai, json
client = openai.OpenAI(api_key='YOUR_OPENAI_KEY')
INTENTS = ['billing', 'technical_support', 'returns_refunds',
'account_access', 'shipping', 'general_inquiry']
def classify_intent(message: str) -> dict:
prompt = (
f'Classify this customer message into exactly one intent.\n'
f'Intents: {INTENTS}\n'
f'Message: "{message}"\n'
f'Respond with JSON: {{"intent": "...", "confidence": 0.0-1.0}}'
)
resp = client.chat.completions.create(
model='gpt-4o-mini',
messages=[{'role': 'user', 'content': prompt}],
response_format={'type': 'json_object'}
)
return json.loads(resp.choices[0].message.content)การส่งต่อไปยังคิวผู้เชี่ยวชาญ
เมื่อทราบเจตนาแล้ว ให้ส่งรายการแจ้งปัญหาไปยังคิวผู้เชี่ยวชาญที่เหมาะสม แต่ละคิวมีแม่แบบการตอบกลับ SLA ของตนเอง และกฎการยกระดับ
ROUTING_MAP = {
'billing': 'queue_billing',
'technical_support': 'queue_tech',
'returns_refunds': 'queue_returns',
'account_access': 'queue_tech',
'shipping': 'queue_fulfillment',
'general_inquiry': 'queue_general'
}
def route_ticket(ticket: dict) -> str:
result = classify_intent(ticket['message'])
intent = result['intent']
confidence = result['confidence']
queue = ROUTING_MAP.get(intent, 'queue_general')
ticket['intent'] = intent
ticket['confidence'] = confidence
ticket['queue'] = queue
return queueเกณฑ์ระดับความมั่นใจสำหรับการยกระดับ
หากตัวจำแนกไม่แน่ใจ (ระดับความมั่นใจต่ำกว่า 0.7) การกำหนดเส้นทางอัตโนมัติอาจไม่ถูกต้อง รายการแจ้งปัญหาที่มีระดับความมั่นใจต่ำควรถูกยกระดับให้มนุษย์คัดแยกด้วยตนเอง แทนที่จะส่งไปยังผู้เชี่ยวชาญโดยอัตโนมัติ
CONFIDENCE_THRESHOLD = 0.70
def route_with_escalation(ticket: dict) -> dict:
result = classify_intent(ticket['message'])
intent = result['intent']
confidence = result['confidence']
if confidence < CONFIDENCE_THRESHOLD:
return {
'ticket_id': ticket['id'],
'action': 'escalate_to_human',
'reason': f'Low confidence: {confidence:.2f}',
'suggested_intent': intent
}
queue = ROUTING_MAP.get(intent, 'queue_general')
return {
'ticket_id': ticket['id'],
'action': 'route_to_queue',
'queue': queue,
'intent': intent,
'confidence': confidence
}การยกระดับลำดับความสำคัญตาม SLA
แม้รายการแจ้งปัญหาที่กำหนดเส้นทางโดยอัตโนมัติก็อาจละเมิด SLA ได้หากไม่ได้รับการแก้ไขภายในเวลา งานเบื้องหลังจะตรวจสอบอายุของรายการเทียบกับเป้าหมาย SLA และยกระดับรายการที่เกินกำหนดไปยังคิวหัวหน้างาน
from datetime import datetime, timezone
SLA_HOURS = {
'queue_billing': 4,
'queue_tech': 8,
'queue_returns': 24,
'queue_fulfillment': 12,
'queue_general': 48
}
def check_sla_breach(ticket: dict) -> bool:
created = datetime.fromisoformat(ticket['created_at'])
age_hours = (datetime.now(timezone.utc) - created).total_seconds() / 3600
sla = SLA_HOURS.get(ticket['queue'], 24)
if age_hours > sla and ticket['status'] == 'open':
ticket['queue'] = 'queue_supervisor_escalation'
ticket['escalation_reason'] = f'SLA breach: {age_hours:.1f}h > {sla}h'
return True
return False
if __name__ == '__main__':
from datetime import datetime, timedelta, timezone
old_ticket = {
'created_at': (datetime.now(timezone.utc) - timedelta(hours=10)).isoformat(),
'queue': 'queue_billing',
'status': 'open',
}
breached = check_sla_breach(old_ticket)
print(f'SLA breached: {breached}')
if breached:
print('Escalation reason:', old_ticket['escalation_reason'])
การกำหนดเส้นทางหลายป้ายกำกับสำหรับรายการแจ้งปัญหาที่ซับซ้อน
ข้อความบางรายการเกี่ยวข้องกับหลายด้าน เช่น 'คำสั่งซื้อของฉันมาถึงในสภาพเสียหายและฉันถูกเรียกเก็บเงินสองครั้ง' ตัวจำแนกหลายป้ายกำกับจะส่งคืนหลายเจตนา จากนั้นจะสร้างสำเนารายการแจ้งปัญหาไว้ในทั้งสองคิว และเจ้าหน้าที่จะประสานงานกันเพื่อแก้ไข
def classify_multi_intent(message: str) -> list[dict]:
prompt = (
f'A customer message may have multiple intents.\n'
f'Intents: {INTENTS}\n'
f'Message: "{message}"\n'
f'Return JSON array: [{{"intent": "...", "confidence": 0.0}}]\n'
f'Include only intents with confidence > 0.5'
)
resp = client.chat.completions.create(
model='gpt-4o-mini',
messages=[{'role': 'user', 'content': prompt}],
response_format={'type': 'json_object'}
)
data = json.loads(resp.choices[0].message.content)
return data.get('intents', [])
# Route to multiple queues
def route_multi(ticket: dict) -> list[str]:
intents = classify_multi_intent(ticket['message'])
return [ROUTING_MAP.get(i['intent'], 'queue_general') for i in intents]การดึงข้อมูลเมตาของรายการแจ้งปัญหา
ก่อนกำหนดเส้นทาง ให้ดึงข้อมูลเมตาจากข้อความเพื่อช่วยผู้เชี่ยวชาญ เช่น หมายเลขคำสั่งซื้อ ชื่อผลิตภัณฑ์ และรหัสบัญชี วิธีนี้ช่วยให้แก้ไขปัญหาได้เร็วขึ้น เพราะไม่ต้องเริ่มด้วยคำถามเพื่อขอข้อมูลเพิ่มเติม
def extract_metadata(message: str) -> dict:
prompt = (
f'Extract structured metadata from this customer message.\n'
f'Return JSON: {{"order_id": null, "product": null, "account_email": null}}\n'
f'Use null for fields not mentioned.\n'
f'Message: "{message}"'
)
resp = client.chat.completions.create(
model='gpt-4o-mini',
messages=[{'role': 'user', 'content': prompt}],
response_format={'type': 'json_object'}
)
return json.loads(resp.choices[0].message.content)
meta = extract_metadata('My order #A12345 for the blue headphones never arrived.')
print(meta) # {'order_id': 'A12345', 'product': 'blue headphones', 'account_email': None}การเพิ่มลำดับความสำคัญตามความรู้สึก
ลูกค้าที่โกรธมีแนวโน้มเลิกใช้บริการมากกว่า ให้ตรวจจับความรู้สึกเชิงลบและเพิ่มลำดับความสำคัญของรายการแจ้งปัญหา เพื่อให้ลูกค้าที่ไม่พอใจได้รับคำตอบเร็วขึ้น แม้เวลาตาม SLA จะยังไม่หมด
def detect_sentiment(message: str) -> str:
prompt = f'Classify sentiment as positive/neutral/negative.\nMessage: "{message}"\nReturn JSON: {{"sentiment": "..."}}'
resp = client.chat.completions.create(
model='gpt-4o-mini',
messages=[{'role': 'user', 'content': prompt}],
response_format={'type': 'json_object'}
)
return json.loads(resp.choices[0].message.content)['sentiment']
def set_priority(ticket: dict) -> str:
sentiment = detect_sentiment(ticket['message'])
if sentiment == 'negative':
ticket['priority'] = 'high'
elif sentiment == 'positive':
ticket['priority'] = 'low'
else:
ticket['priority'] = 'normal'
return ticket['priority']การกำหนดลำดับการยกระดับ
กำหนดลำดับการยกระดับที่ชัดเจนเพื่อให้ทุกคิวมีทางสำรอง เมื่อคิวด่านหน้าแก้ไขปัญหาไม่สำเร็จภายใน SLA รายการแจ้งปัญหาจะย้ายไปยังระดับ 2 จากนั้นระดับ 3 (ผู้เชี่ยวชาญอาวุโส) และต่อไปยังหัวหน้างาน
ESCALATION_CHAIN = {
'queue_tech': 'queue_tech_tier2',
'queue_tech_tier2': 'queue_tech_senior',
'queue_tech_senior': 'queue_supervisor_escalation',
'queue_billing': 'queue_billing_senior',
'queue_billing_senior': 'queue_supervisor_escalation',
'queue_returns': 'queue_supervisor_escalation',
'queue_fulfillment': 'queue_supervisor_escalation',
'queue_general': 'queue_supervisor_escalation',
'queue_supervisor_escalation': None # terminal — human manager
}
def escalate(ticket: dict) -> str | None:
next_queue = ESCALATION_CHAIN.get(ticket['queue'])
if next_queue:
ticket['queue'] = next_queue
return next_queue
if __name__ == '__main__':
ticket = {'queue': 'queue_tech'}
for _ in range(3):
nxt = escalate(ticket)
print(f"Escalated to: {ticket['queue']}")
if nxt is None:
break
กระบวนการกำหนดเส้นทางทั้งหมด
รวมการจำแนกประเภท การดึงข้อมูลเมตา การวิเคราะห์ความรู้สึก และการตรวจสอบ SLA ไว้ในกระบวนการเดียวที่ทำงานกับรายการแจ้งปัญหาทุกเรื่องที่เข้ามา
def process_ticket(raw_ticket: dict) -> dict:
ticket = dict(raw_ticket)
# Step 1: Classify and route
routing = route_with_escalation(ticket)
ticket.update(routing)
# Step 2: Extract metadata
ticket['metadata'] = extract_metadata(ticket['message'])
# Step 3: Set priority from sentiment
ticket['priority'] = set_priority(ticket)
# Step 4: Check if already breaching SLA
if ticket.get('created_at'):
check_sla_breach(ticket)
return ticket
result = process_ticket({
'id': 'T001',
'message': 'I was charged twice for my subscription last month!',
'created_at': '2026-05-28T10:00:00+00:00',
'status': 'open'
})
print(result)การตรวจสอบความแม่นยำของการกำหนดเส้นทาง
ติดตามความแม่นยำของการกำหนดเส้นทางโดยสุ่มรายการแจ้งปัญหาที่กำหนดเส้นทางอัตโนมัติบางส่วนให้มนุษย์ตรวจสอบ เมื่อผู้เชี่ยวชาญส่งรายการแจ้งปัญหาไปยังคิวอื่น นั่นถือเป็นข้อผิดพลาดในการกำหนดเส้นทาง ให้นำข้อผิดพลาดกลับไปใช้ปรับปรุงพรอมต์หรือปรับจูนตัวจำแนก
import random
def log_routing_decision(ticket: dict, final_queue: str):
was_correct = ticket.get('queue') == final_queue
if not was_correct:
print(f'[ROUTING_ERROR] ticket={ticket["id"]} '
f'predicted={ticket["queue"]} actual={final_queue} '
f'confidence={ticket.get("confidence", 0):.2f}')
# Specialist reassigns ticket: log the discrepancy
def specialist_reassign(ticket: dict, new_queue: str):
log_routing_decision(ticket, new_queue)
ticket['queue'] = new_queue
return ticket
if __name__ == '__main__':
ticket = {'id': 'T-1001', 'queue': 'queue_billing', 'confidence': 0.62}
specialist_reassign(ticket, 'queue_tech')
ระดับความมั่นใจเท่าใดจึงควรยกระดับให้มนุษย์แทนการกำหนดเส้นทางอัตโนมัติ
การเลือกระดับความมั่นใจที่เหมาะสมเป็นการสร้างสมดุลระหว่างอัตราการทำงานอัตโนมัติกับความแม่นยำของการกำหนดเส้นทาง หากกำหนดเกณฑ์สูงเกินไป จะยกระดับงานมากเกินจำเป็น หากต่ำเกินไป จะทำให้ส่งรายการไปผิดเส้นทาง
สรุปการกำหนดเส้นทางรายการแจ้งปัญหา
การกำหนดเส้นทางรายการแจ้งปัญหาที่มีประสิทธิผลประกอบด้วย การจำแนกเจตนาด้วย LLM พร้อม เกณฑ์ระดับความมั่นใจ สำหรับการยกระดับให้มนุษย์ การดึงข้อมูลเมตา เพื่อแก้ไขปัญหาได้เร็วขึ้น การจัดลำดับความสำคัญตามความรู้สึก สำหรับลูกค้าที่มีความเสี่ยง และ ลำดับการยกระดับตาม SLA เพื่อให้มั่นใจว่าไม่มีรายการแจ้งปัญหาใดตกหล่น
คำถามที่พบบ่อย
บทเรียน “ตรรกะการจัดเส้นทางและยกระดับทิกเก็ต” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ตรรกะการจัดเส้นทางและยกระดับทิกเก็ต” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส AI Agents ให้อัปเกรดเป็น CoddyKit PRO คอร์ส AI Agents มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ตรรกะการจัดเส้นทางและยกระดับทิกเก็ต”
จำแนกเจตนา ส่งต่อไปยังเอเจนต์ผู้เชี่ยวชาญ และกำหนดเงื่อนไขการยกระดับ คุณปฏิบัติ AI Agents ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน AI Agents หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน AI Agents บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน
บทเรียน “ตรรกะการจัดเส้นทางและยกระดับทิกเก็ต” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน AI Agents นี้ได้ไหม
ได้ บทเรียน AI Agents ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- ตรรกะการจัดเส้นทางและยกระดับทิกเก็ต
- การผสาน CRM: Salesforce และ HubSpot
- โพรโทคอลการส่งต่องานให้มนุษย์
- การจัดการบริบทและประวัติลูกค้า