客服路由
使用客服路由模板,把客服消息路由到正确的部门,评估其紧急程度,并在需要时升级给人工。
目标:每条传入的客服消息都带着紧急程度进入正确的队列,而需要人工处理的消息——愤怒的客户、法律威胁、数据丢失、取消订阅——跳过自动回答。
创建决策
模板 → 客服路由 → 创建决策:
| 部分 | 内容 |
|---|---|
| State | message(string,必填)、plan(string) |
department | choice——billing(发票、扣费、退款、支付方式)、technical(缺陷、错误、集成、故障)、account(登录、访问、用户、设置)、sales(升级、新套餐、报价)、other——最低置信度 0.6 |
urgency | score——low、normal、high、urgent |
human_required | probability——这需要人工处理而不是自动回答吗?是:愤怒的客户、法律威胁、数据丢失、取消订阅。否:文档就能回答的简单问题。 |
| 策略 | 1. human_required ≥ 0.7 → escalate |
| Fallback | escalate——用于 other 以及置信度低于 60% 的 department |
调用
curl -X POST https://api.dcision.io/v1/decisions/support-routing \
-H "Authorization: Bearer $DCISION_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: ticket-55120" \
-d '{ "state": { "message": "I was charged twice this month and need a refund today.", "plan": "pro" } }'{
"decision_id": "dec_Rb6Tn2Wq8Lx4Mk9Pz1Cv",
"execution_id": "exec_Ys3Fp7Kd1Qw9Bn5Lt2Gh",
"schema": "support-routing",
"version": 1,
"result": { "department": "billing", "urgency": "high", "human_required": 0.82 },
"confidence": { "department": 0.9375, "urgency": 0.61, "human_required": 0.64 },
"scores": { "urgency": 3.11 },
"action": "escalate",
"action_reason": { "type": "policy", "rule": 0 },
"metrics": { "latency_ms": 356, "engine": "jev", "model": "jev-1.13.0", "estimated_cost_usd": 0.00001386, "input_tokens": 330, "output_tokens": 33 }
}human_required 为 0.82,高于规则 0 的 0.7 阈值,因此行动为 escalate。一个操作类问题(“如何导出发票?”)通常会得到较低的 human_required 和 continue。决策无法归类的消息——department 的置信度低于 60%——会采用 fallback 行动 escalate,并带有 action_reason.type = "low_confidence"。
采取行动
import os
import requests
def route_ticket(ticket):
response = requests.post(
"https://api.dcision.io/v1/decisions/support-routing",
headers={
"Authorization": f"Bearer {os.environ['DCISION_API_KEY']}",
"Idempotency-Key": f"ticket-{ticket['id']}",
},
json={"state": {"message": ticket["message"], "plan": ticket["plan"]}},
timeout=10,
)
if not response.ok:
return helpdesk.assign(ticket, queue="triage") # a person decides on errors
decision = response.json()
queue = decision["result"]["department"]
if queue == "other":
queue = "triage"
priority = decision["result"]["urgency"]
if decision["action"] == "escalate":
return helpdesk.assign(ticket, queue=queue, priority=priority, agent="human")
return helpdesk.auto_reply(ticket, queue=queue, priority=priority)调优
-
与你的队列保持一致:把部门重命名或添加为选项,并描述它们的边界(“退款归 billing,即使是技术故障导致的”)。
-
利用套餐信息:添加诸如“Enterprise 客户的 SLA 为 1 小时”之类的
context——plan字段已经在状态中。 -
无论
human_required如何,都升级紧急工单——基于回答,或基于加权级别,以便同时捕获偏向紧急的工单:{ "field": "urgency", "on": "score", "operator": "gte", "value": 3.5, "action": "escalate" } -
调整路由下限:
department自带"minConfidence": 0.6。调高它会把更多不明确的消息交给 fallback 行动,调低它则会自动化更多消息。 -
在同一次调用中回答更多问题:添加诸如
refund_requested或has_reproducible_steps之类的推测性问题——参见推测式扇出及其ticket-triage模板。 -
如果消息包含个人数据,不要让它进入日志:在决策的设置中关闭
storeInput。