kfid路由窗口: 5类别映射企微客服链接(ROUTING_TARGETS配置化,弃用business_contacts个人名片)+ send_service_card新函数 + ContactCard支持service_url点击打开客服会话(行政→机票酒店前台/人力→共享服务/财务→报销服务台/法务→行政法务/物业→物业服务)
This commit is contained in:
@@ -823,25 +823,26 @@ async def _handle_routing(
|
||||
routing_confidence = 0.75 # 降级兜底给一个略高于阈值的置信度
|
||||
logger.info(f"路由意图检测(兜底): business_category={business_category}")
|
||||
|
||||
# 4. 查询联系人
|
||||
contact = await get_contact_by_category(db, business_category)
|
||||
if not contact:
|
||||
logger.warning(f"未找到 {business_category} 类别的联系人,跳过路由推荐")
|
||||
# 4. 查询路由目标窗口(v4.0 kfid 配置化)
|
||||
from app.services.routing_service import get_routing_target, send_service_card
|
||||
target = get_routing_target(business_category)
|
||||
if not target:
|
||||
logger.warning(f"未配置 {business_category} 类别的路由窗口,跳过路由推荐")
|
||||
return False
|
||||
|
||||
# 5. 构建路由说明文本
|
||||
category_display = business_category.replace("行政-物业", "物业")
|
||||
reason = (
|
||||
f"您的问题属于{category_display}业务范畴,不在IT服务台服务范围内 😊\n\n"
|
||||
f"为您推荐{category_display}服务相关联系人,您可以直接点击名片联系TA:"
|
||||
f"为您推荐「{target['service_name']}」,点击下方卡片即可咨询:"
|
||||
)
|
||||
|
||||
# 6. 发送名片三段式消息
|
||||
await send_contact_card(
|
||||
# 6. 发送服务窗口卡片消息(kfid 模式)
|
||||
await send_service_card(
|
||||
db=db,
|
||||
conversation=conversation,
|
||||
employee_id=employee_id,
|
||||
contact=contact,
|
||||
target=target,
|
||||
reason=reason,
|
||||
business_category=business_category,
|
||||
routing_confidence=routing_confidence,
|
||||
@@ -855,7 +856,7 @@ async def _handle_routing(
|
||||
message_content=content,
|
||||
business_category=business_category,
|
||||
routing_confidence=routing_confidence,
|
||||
contact=contact,
|
||||
contact=None,
|
||||
)
|
||||
|
||||
return True
|
||||
@@ -1073,31 +1074,32 @@ async def _step_routing_from_result(db, conversation, employee_id, content, resu
|
||||
logger.warning("[D1] 路由意图为 non_it_routing 但 business_category 为空,跳过")
|
||||
return False
|
||||
|
||||
# 查询联系人
|
||||
contact = await get_contact_by_category(db, business_category)
|
||||
if not contact:
|
||||
logger.warning(f"未找到 {business_category} 类别的联系人,跳过路由推荐")
|
||||
# 查询路由目标窗口(v4.0 kfid 配置化,替代 business_contacts 表查询)
|
||||
from app.services.routing_service import get_routing_target, send_service_card
|
||||
target = get_routing_target(business_category)
|
||||
if not target:
|
||||
logger.warning(f"未配置 {business_category} 类别的路由窗口,跳过路由推荐")
|
||||
return False
|
||||
|
||||
# 构建路由说明文本
|
||||
category_display = business_category.replace("行政-物业", "物业")
|
||||
reason = (
|
||||
f"您的问题属于{category_display}业务范畴,不在IT服务台服务范围内 😊\n\n"
|
||||
f"为您推荐{category_display}服务相关联系人,您可以直接点击名片联系TA:"
|
||||
f"为您推荐「{target['service_name']}」,点击下方卡片即可咨询:"
|
||||
)
|
||||
|
||||
# 发送名片三段式消息
|
||||
await send_contact_card(
|
||||
# 发送服务窗口卡片消息(kfid 模式)
|
||||
await send_service_card(
|
||||
db=db,
|
||||
conversation=conversation,
|
||||
employee_id=employee_id,
|
||||
contact=contact,
|
||||
target=target,
|
||||
reason=reason,
|
||||
business_category=business_category,
|
||||
routing_confidence=routing_confidence,
|
||||
)
|
||||
|
||||
# 记录路由事件
|
||||
# 记录路由事件(kfid 模式无 contact 对象,contact_name 存窗口名)
|
||||
await record_routing_event(
|
||||
db=db,
|
||||
conversation_id=str(conversation.id),
|
||||
@@ -1105,7 +1107,7 @@ async def _step_routing_from_result(db, conversation, employee_id, content, resu
|
||||
message_content=content,
|
||||
business_category=business_category,
|
||||
routing_confidence=routing_confidence,
|
||||
contact=contact,
|
||||
contact=None,
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user