Class RobotThreadRoutingStrategy
java.lang.Object
com.bytedesk.service.routing_strategy.AbstractThreadRoutingStrategy
com.bytedesk.service.routing_strategy.RobotThreadRoutingStrategy
@Component("robotThreadStrategy")
public class RobotThreadRoutingStrategy
extends AbstractThreadRoutingStrategy
机器人线程路由策略
功能特点: - 纯机器人接待,不支持转人工 - 自动创建和管理机器人会话 - 支持会话复用和重新初始化
处理流程: 1. 验证机器人配置 2. 检查现有会话 3. 创建或复用会话 4. 发送欢迎消息
- Since:
- 1.0.0
- Author:
- jackning 270580156@qq.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.springframework.context.ApplicationEventPublisher
private final MessageRestService
private final QueueMemberRestService
private final QueueService
private final RobotRestService
private final ThreadRestService
private final VisitorThreadService
Fields inherited from class com.bytedesk.service.routing_strategy.AbstractThreadRoutingStrategy
DEFAULT_OFFLINE_MESSAGE, DEFAULT_WELCOME_MESSAGE, ESTIMATED_WAIT_TIME_PER_PERSON, MESSAGE_CACHE_MINUTES, QUEUE_NEXT_MESSAGE, QUEUE_WAITING_MESSAGE_TEMPLATE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate MessageProtobuf
createAndSaveWelcomeMessage
(String content, ThreadEntity thread) 创建并保存欢迎消息createRobotThread
(VisitorRequest request) 创建机器人会话createThread
(VisitorRequest visitorRequest) 创建线程的核心方法 由具体实现类负责处理不同类型的线程创建逻辑private ThreadEntity
getOrCreateRobotThread
(VisitorRequest request, RobotEntity robotEntity, String topic) 获取或创建机器人会话private MessageProtobuf
getRobotContinueMessage
(RobotEntity robotEntity, ThreadEntity thread) 获取机器人继续对话消息private RobotEntity
getRobotEntity
(String robotUid) 获取机器人实体private String
getRobotWelcomeMessage
(RobotEntity robotEntity) 获取机器人欢迎消息protected ThreadRestService
获取线程服务实例 由具体实现类提供private MessageProtobuf
handleExistingRobotThread
(RobotEntity robotEntity, ThreadEntity thread) 处理现有的机器人会话private boolean
isExistingRobotThread
(ThreadEntity thread) 检查是否为现有的机器人会话private MessageProtobuf
processNewRobotThread
(VisitorRequest request, ThreadEntity thread, RobotEntity robotEntity) 处理新的机器人会话private void
publishRobotThreadEvent
(ThreadEntity savedThread) 发布机器人线程事件private void
updateQueueMemberForRobot
(QueueMemberEntity queueMemberEntity) 更新队列成员状态为机器人自动接受Methods inherited from class com.bytedesk.service.routing_strategy.AbstractThreadRoutingStrategy
executeWithExceptionHandling, generateQueueMessage, getThreadByUid, getValidOfflineMessage, getValidWelcomeMessage, handleStrategyException, isActiveThread, isClosedThread, isMessageInCacheTime, isNewThread, logThreadStatusChange, saveThread, validateThread, validateUid
-
Field Details
-
robotRestService
-
threadRestService
-
visitorThreadService
-
queueService
-
queueMemberRestService
-
applicationEventPublisher
private final org.springframework.context.ApplicationEventPublisher applicationEventPublisher -
messageRestService
-
-
Constructor Details
-
RobotThreadRoutingStrategy
public RobotThreadRoutingStrategy()
-
-
Method Details
-
getThreadRestService
Description copied from class:AbstractThreadRoutingStrategy
获取线程服务实例 由具体实现类提供- Specified by:
getThreadRestService
in classAbstractThreadRoutingStrategy
- Returns:
- ThreadRestService实例
-
createThread
Description copied from class:AbstractThreadRoutingStrategy
创建线程的核心方法 由具体实现类负责处理不同类型的线程创建逻辑- Specified by:
createThread
in classAbstractThreadRoutingStrategy
- Parameters:
visitorRequest
- 访客请求信息- Returns:
- 消息协议对象
-
createRobotThread
创建机器人会话- Parameters:
request
- 访客请求- Returns:
- 消息协议对象
-
getRobotEntity
获取机器人实体 -
getOrCreateRobotThread
private ThreadEntity getOrCreateRobotThread(VisitorRequest request, RobotEntity robotEntity, String topic) 获取或创建机器人会话 -
isExistingRobotThread
检查是否为现有的机器人会话 -
handleExistingRobotThread
处理现有的机器人会话 -
processNewRobotThread
private MessageProtobuf processNewRobotThread(VisitorRequest request, ThreadEntity thread, RobotEntity robotEntity) 处理新的机器人会话 -
getRobotWelcomeMessage
获取机器人欢迎消息 -
updateQueueMemberForRobot
更新队列成员状态为机器人自动接受 -
publishRobotThreadEvent
发布机器人线程事件 -
createAndSaveWelcomeMessage
创建并保存欢迎消息 -
getRobotContinueMessage
private MessageProtobuf getRobotContinueMessage(RobotEntity robotEntity, @Nonnull ThreadEntity thread) 获取机器人继续对话消息
-