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.ApplicationEventPublisherprivate final MessageRestServiceprivate final QueueMemberRestServiceprivate final QueueServiceprivate final RobotRestServiceprivate final ThreadRestServiceprivate final VisitorThreadServiceFields inherited from class com.bytedesk.service.routing_strategy.AbstractThreadRoutingStrategy
ESTIMATED_WAIT_TIME_PER_PERSON, MESSAGE_CACHE_MINUTES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate MessageProtobufcreateAndSaveWelcomeMessage(WelcomeContent wc, ThreadEntity thread) 创建并保存欢迎消息createRobotThread(VisitorRequest request) 创建机器人会话createThread(VisitorRequest visitorRequest) 创建线程的核心方法 由具体实现类负责处理不同类型的线程创建逻辑private ThreadEntitygetOrCreateRobotThread(VisitorRequest request, RobotEntity robotEntity, String topic) 获取或创建机器人会话private MessageProtobufgetRobotContinueMessage(VisitorRequest request, RobotEntity robotEntity, ThreadEntity thread) 获取机器人继续对话消息private RobotEntitygetRobotEntity(String robotUid) 获取机器人实体private StringgetRobotWelcomeMessage(VisitorRequest visitorRequest, RobotEntity robotEntity) protected ThreadRestService获取线程服务实例 由具体实现类提供private MessageProtobufhandleExistingRobotThread(VisitorRequest request, RobotEntity robotEntity, ThreadEntity thread) 处理现有的机器人会话private booleanisDraftEnabled(VisitorRequest visitorRequest) 获取机器人欢迎消息private booleanisExistingRobotThread(ThreadEntity thread) 检查是否为现有的机器人会话private MessageProtobufprocessNewRobotThread(VisitorRequest request, ThreadEntity thread, RobotEntity robotEntity) 处理新的机器人会话private voidpublishRobotThreadEvent(ThreadEntity savedThread) 发布机器人线程事件private voidupdateQueueMemberForRobot(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:
getThreadRestServicein classAbstractThreadRoutingStrategy- Returns:
- ThreadRestService实例
-
createThread
Description copied from class:AbstractThreadRoutingStrategy创建线程的核心方法 由具体实现类负责处理不同类型的线程创建逻辑- Specified by:
createThreadin classAbstractThreadRoutingStrategy- Parameters:
visitorRequest- 访客请求信息- Returns:
- 消息协议对象
-
createRobotThread
创建机器人会话- Parameters:
request- 访客请求- Returns:
- 消息协议对象
-
getRobotEntity
获取机器人实体 -
getOrCreateRobotThread
private ThreadEntity getOrCreateRobotThread(VisitorRequest request, RobotEntity robotEntity, String topic) 获取或创建机器人会话 -
isExistingRobotThread
检查是否为现有的机器人会话 -
handleExistingRobotThread
private MessageProtobuf handleExistingRobotThread(VisitorRequest request, RobotEntity robotEntity, ThreadEntity thread) 处理现有的机器人会话 -
processNewRobotThread
private MessageProtobuf processNewRobotThread(VisitorRequest request, ThreadEntity thread, RobotEntity robotEntity) 处理新的机器人会话 -
isDraftEnabled
获取机器人欢迎消息 -
getRobotWelcomeMessage
-
updateQueueMemberForRobot
更新队列成员状态为机器人自动接受 -
publishRobotThreadEvent
发布机器人线程事件 -
createAndSaveWelcomeMessage
创建并保存欢迎消息 -
getRobotContinueMessage
private MessageProtobuf getRobotContinueMessage(VisitorRequest request, RobotEntity robotEntity, @Nonnull ThreadEntity thread) 获取机器人继续对话消息
-