One-agent enterprise wechat intelligent robot system based on dynamic routing of user identity and exclusive isolation service method
Patent Information
- Application Number
- CN202611041129.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-14
- Publication Date
- 2026-10-13
AI Technical Summary
[0004]第一,多用户共享同一Agent的会话上下文与数据存储空间,导致不同用户的对话历史、问答记录无法有效隔离,易引发上下文混淆、回答内容错乱及信息污染,同时存在企业业务数据泄露的风险
[0044](1)彻底解决多用户信息交叉,杜绝AI问答错乱
Smart Images

Figure CN122909304A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of artificial intelligence, enterprise digital office and intelligent robot technology, specifically to a one-person-one-agent enterprise WeChat intelligent robot system and a dedicated isolation service method based on dynamic routing of user identity. Background Technology
[0002] As an enterprise-level communication and office collaboration platform, WeChat Work has become a core business tool in the digital transformation of many enterprises. Building intelligent chatbots based on the WeChat Work ecosystem leverages its unified employee authentication system to verify unique user identities, providing a foundation for refined services and access control. Simultaneously, by combining large language models and AI intelligent agent technology, it can achieve natural language understanding, logical reasoning, and plug-in skill expansion, adapting to the office needs of multiple positions such as R&D, sales, administration, and management. WeChat Work's unified message callback and long-connection push mechanism also provides stable ecosystem support for the chatbot's real-time message interaction.
[0003] Currently, most mainstream enterprise WeChat intelligent robot systems in the industry adopt an architecture design where a single Agent instance serves all users. Under this architecture, all enterprise users share the same Agent process, session memory space, and skill plugin set. This design has the following technical drawbacks:
[0004] First, multiple users sharing the same agent's session context and data storage space makes it impossible to effectively isolate the dialogue history and question-and-answer records of different users, which can easily lead to context confusion, disordered answers, and information pollution, while also posing a risk of leakage of enterprise business data.
[0005] Second, the service entry points are fragmented, lacking personalization capabilities. It's impossible to configure exclusive skills and personalized memories for different positions and users; only general Q&A services can be provided. To provide differentiated services for different positions or departments, multiple independent bots typically need to be created, requiring users to switch between different entry points, resulting in a fragmented experience. Administrators also need to maintain multiple sets of bot credentials and callback addresses, significantly increasing operational costs.
[0006] Third, the intelligent agent skill configuration is in a globally shared mode, meaning that all users load the same set of plug-in skills, which makes it impossible to achieve user-level or job-level skill differentiation configuration, and it is difficult to meet the refined and personalized office service needs of enterprises.
[0007] Fourth, the single-instance architecture suffers from performance bottlenecks. Resource scheduling is rigid, and as the number of users grows, the ability to handle concurrent requests is limited. It cannot be elastically scaled up according to the number of users, and response latency, service lag, and failures occur frequently in high-concurrency scenarios, making it unsuitable for large-scale use cases of medium and large enterprises.
[0008] Fifth, the system has extremely poor scalability. Skill updates, plugin iterations, and service debugging will affect all users, making it impossible to achieve customized upgrades for individual users or departments.
[0009] The aforementioned architectural flaws essentially stem from the global single-instance reuse mode, which suffers from issues such as lack of session isolation, insufficient personalization capabilities, poor system scalability, and rigid resource scheduling. These problems severely restrict the reliability and applicability of WeChat Work's intelligent robots in enterprise-level scenarios. Summary of the Invention
[0010] To overcome the aforementioned deficiencies in the existing technology, this application proposes a novel one-person-one-agent enterprise WeChat intelligent robot system and a dedicated isolation service method based on dynamic routing of user identity. Figure 1 This diagram compares the traditional single-agent architecture with the architecture of this invention. This solution breaks through the inherent limitations of the traditional single-agent architecture in the industry, achieving user-level session isolation, skill isolation, and memory isolation, comprehensively improving the security, personalization, stability, and scalability of enterprise intelligent robots. It is especially suitable for the development of lightweight, highly secure, and highly customizable intelligent office robots within enterprises.
[0011] More precisely, this invention relies on the enterprise WeChat message push capability and AI intelligent agent technology to realize dynamic distribution of user identity under a single robot entry point and exclusive instance isolation service for one person and one agent. It solves the core pain points of traditional enterprise WeChat intelligent robots, such as cross-information of multiple users, context confusion, and inability to differentiate skills configuration. It is an innovative technical solution for personalized isolation service of enterprise-level AI intelligent robots.
[0012] Specifically, this application provides the following technical solutions:
[0013] The first aspect of this application provides a user-identity-based, one-agent enterprise WeChat intelligent robot system, such as... Figure 4 As shown, the system includes:
[0014] The Enterprise WeChat unified interaction layer is configured to use a single Enterprise WeChat robot as the only global interaction entry point, receive messages sent by all users within the enterprise, and push the messages to the Hermes gateway routing layer via a WebSocket long connection.
[0015] The Hermes gateway routing layer is configured to parse the received message frame, extract the unique user identifier carried in it, query the preset user-Agent routing mapping table, and distribute the current message to the corresponding Agent instance according to the query result;
[0016] The multi-Agent instance service layer is configured with multiple independently running Agent instances and at least one public Agent instance. Each Agent instance is deployed independently in its own runtime environment and has an independent session management space, an independent memory storage unit, and an independent skill plugin set. It is used to process user messages routed to this instance in isolation and generate response data. Session data, memory data, and skill configurations between different Agent instances are not visible to each other.
[0017] The Hermes gateway routing layer is also configured to send the response data back to the WeChat unified interaction layer, and the unified interaction layer will push the response data to the corresponding user client.
[0018] Furthermore, in the WeChat intelligent robot system of this application, the Hermes gateway routing layer includes:
[0019] The identity resolution module is used to parse and extract the userid field of the sending user from the standard WeChat Enterprise message frame, as a unique identifier for the user;
[0020] The routing matching module is used to query a preset user-Agent routing mapping table based on the user's unique identifier to determine the target Agent instance;
[0021] The message forwarding module is used to forward user messages to the target Agent instance, and when the target Agent instance is unavailable, to route user messages to a preset public Agent instance.
[0022] Furthermore, the WeChat intelligent robot system of this application also includes a message queue management unit, which is configured to maintain an exclusive message processing queue for each user, process multiple messages from the same user in the order of receipt, and execute message queues of different users independently and in parallel.
[0023] Furthermore, in the Enterprise WeChat intelligent robot system of this application, the Hermes gateway routing layer also includes a reply deduplication unit, which is configured to manage the deduplication of reply messages waiting to be pushed based on the unique identifier of the streaming reply. New replies with the same identifier overwrite old replies, and reply messages are pushed to the Enterprise WeChat unified interaction layer in a batch refresh manner.
[0024] And an availability check unit, configured to detect the running status of the target Agent instance before distributing user messages to the target Agent instance, and to perform message forwarding only when the target Agent instance is online and available.
[0025] Furthermore, in the WeChat intelligent robot system of this application, the user-Agent routing mapping table supports one-to-one binding and many-to-one binding, wherein one-to-one binding means that one user is uniquely bound to one dedicated Agent instance, and many-to-one binding means that multiple users are jointly bound to the same dedicated Agent instance.
[0026] Furthermore, in the WeChat intelligent robot system of this application, the public Agent instance is configured to receive user messages distributed by the Hermes gateway routing layer that are not bound to a dedicated Agent instance, and to provide a generalized fallback question and answer service.
[0027] The second aspect of this application provides a method for a dedicated isolation service based on dynamic routing of user identity and a single agent, implemented using the aforementioned WeChat intelligent robot system. Figure 5 As shown, it includes the following steps:
[0028] S1. System Initialization: Configure a unique robot and WebSocket connection credential in the WeChat management backend, deploy the Hermes gateway routing layer, initialize the user-Agent routing mapping table, and create multiple independently running Agent instances according to the enterprise's job requirements, and configure differentiated skill plugin sets for each instance.
[0029] S2. Unified Message Reception: The Enterprise WeChat unified interaction layer receives all users' conversation messages through the unique robot and pushes all messages to the Hermes gateway routing layer through a WebSocket long connection.
[0030] S3. User Identity Resolution: The Hermes gateway routing layer parses the received message frame and extracts the unique identity identifier of the message sender.
[0031] S4. Dynamic route matching: The Hermes gateway routing layer uses the unique identifier as an index to query the user-Agent route mapping table to determine whether the current user has been bound to a dedicated Agent instance.
[0032] S5. Message Distribution Processing: If the current user has bound a dedicated Agent instance, the message will be routed to the dedicated Agent instance bound to the user; if not, the message will be routed to the preset public Agent instance; the target Agent instance calls its own independent session history, memory data and skill plugin set to perform reasoning processing on the user message and generate response data.
[0033] S6. Response Feedback Push: The Hermes gateway routing layer receives the response data returned by the target Agent instance, sends it back to the WeChat unified interaction layer, and the unified interaction layer pushes the response data to the corresponding user's WeChat client.
[0034] Furthermore, in the method of this application, before the target Agent instance processes the user message in step S5, it also includes: adding the current user message to a dedicated message processing queue maintained independently for the user, and processing each message in the queue serially according to the message receiving order;
[0035] When the target Agent instance processes user messages, different Agent instances process their respective received user messages in parallel, and messages from different users under the same Agent instance do not block each other.
[0036] Furthermore, in the method of this application, before the Hermes gateway routing layer sends back the response data in step S6, it also includes: deduplicating multiple replies to be pushed based on the unique identifier of the streaming reply, with the new reply with the same identifier overwriting the old reply, and pushing it to the WeChat unified interaction layer in a batch refresh manner.
[0037] Furthermore, the method in this application also includes a route binding management step: the administrator configures or changes the binding relationship between users and Agent instances through a visual interface or API interface, and synchronizes the updated binding relationship to the user-Agent route mapping table, ensuring that the same user is bound to only one Agent instance when the binding is changed.
[0038] A third aspect of this application provides an electronic device, including: a memory and a processor;
[0039] Memory: Used to store computer programs;
[0040] Processor: Used to execute the computer program to implement the steps of the aforementioned method for one-person-one-agent exclusive isolation service based on dynamic routing of user identity.
[0041] A fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, it implements the steps of the aforementioned method for a one-person-one-agent exclusive isolation service based on dynamic routing of user identity.
[0042] In summary, this invention's user-identity-based dynamic routing-based one-person-one-agent enterprise WeChat intelligent robot system breaks through the industry's long-standing single-agent global reuse architecture. Through five innovative designs—unified entry routing, accurate user identity parsing, dynamic user-agent routing distribution, complete isolation of multiple agent instances, and differentiated configuration of user-level skills—it thoroughly solves the industry pain points of traditional enterprise WeChat intelligent robots, such as overlapping user information, contextual confusion, skill homogenization, and cumbersome operation and maintenance. While ensuring a unified, simple, and barrier-free user experience, this system achieves comprehensive personalized intelligent services through session isolation, memory isolation, and skill isolation. It is the first innovative solution in the industry to realize user-level differentiated configuration of intelligent agent plugins. The system possesses core advantages of high security, high availability, high scalability, and low operation and maintenance costs. It can be widely adapted to various enterprise digital intelligent office scenarios, effectively improving enterprise office efficiency and intelligence levels. It provides a new technical paradigm for the personalized and large-scale deployment of enterprise-level AI intelligent robots, possessing extremely high practical value and promising prospects for promotion.
[0043] Compared with the prior art, the present invention has the following specific advantages:
[0044] (1) Completely resolve the issue of overlapping information among multiple users and prevent AI question-and-answer errors.
[0045] Abandoning the traditional global single-agent shared architecture, it adopts a one-person-one-agent isolation architecture, where each user has an independent agent instance, independent session context, and independent memory storage. Dialogue data, question-and-answer records, and personalized memories from different users are completely isolated and invisible to each other. This completely solves the core pain points of traditional architectures, such as multi-user context confusion, AI illusions, and cross-contamination of information, significantly improving the accuracy and stability of intelligent question answering and mitigating the risk of enterprise business information leakage.
[0046] (2) Industry-first skill-based user-level isolation enables differentiated customized services.
[0047] Breaking away from the industry convention of "one agent loading all plugins" in existing AI agent frameworks, this system pioneers a user-level skill isolation mechanism. Different agent instances can be independently configured with their own exclusive skill plugin sets. R&D agents can be configured with code analysis and technical Q&A skills, sales agents with customer management and CRM query skills, and management agents with data statistics and report analysis skills. This truly achieves personalized, job-specific intelligent services, adapting to the refined and scenario-based office needs of enterprises.
[0048] (3) Unify the interaction entry point and optimize the two-way experience for users and operations and maintenance.
[0049] The entire process utilizes a single WeChat Work robot as the sole interaction point, eliminating the need for users to remember or switch between multiple robots. Integration is effortless, and the user experience is consistent and smooth. Administrators only need to maintain one set of robot credentials, eliminating the need to configure multiple services for different departments and positions. This significantly simplifies the operation and maintenance process, reduces costs, and enables extremely simplified deployment and management.
[0050] (4) Highly flexible and scalable, with high availability and stable operation.
[0051] It supports on-demand creation and flexible scaling of Agent instances, allowing for smooth expansion from a single instance to a multi-instance cluster based on the scale of enterprise users, adapting to high-concurrency office scenarios. Multiple instances run independently and are mutually fault-tolerant; the failure or upgrade of a single Agent instance will not affect the global service. Simultaneously, a public Agent fallback mechanism is configured to ensure uninterrupted service in cases of unbound users or abnormal scenarios, significantly improving overall system availability.
[0052] (5) The architecture has a high degree of decoupling and is convenient for iteration and maintenance.
[0053] The three-tier architecture features clear responsibilities and complete decoupling, allowing the interaction layer, routing layer, and service layer to be independently iterated and upgraded. Agent skill updates, plugin expansions, and feature debugging only affect the corresponding independent instance and will not affect the global service. It can be quickly adapted to new office scenarios and new job requirements in the future, demonstrating strong architectural compatibility and iterability.
[0054] Other features and advantages of this application will be set forth in detail in the following description, or will become apparent through the implementation of the relevant technical solutions of this application. The objectives and other advantages of this application can be achieved through the technical features and means explicitly pointed out in the description, claims, and drawings, and will be obtained through the implementation of these technical contents. Attached Figure Description
[0055] To more clearly illustrate the technical solution of this application, the accompanying drawings involved in the description of this invention will be briefly introduced below. It should be noted that the drawings only show some embodiments of the invention. For those skilled in the art, other related drawings can be derived from these drawings without creative effort.
[0056] Figure 1 This diagram compares the traditional single-agent architecture with the architecture of this invention.
[0057] Figure 2 This is a schematic diagram of the overall layered architecture of the system of the present invention.
[0058] Figure 3 This is a flowchart of the message routing service process of the system of the present invention.
[0059] Figure 4This is a structural diagram of the WeChat intelligent robot system for enterprises based on dynamic routing of user identity, which is the composition of the present invention.
[0060] Figure 5 This is a schematic diagram illustrating the implementation process of the user identity-based dynamic routing method for a dedicated isolation service with one agent per user, as described in this invention. Detailed Implementation
[0061] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the described embodiments are only some embodiments of this application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the protection scope of this application.
[0062] In this document, the term "comprising" and any variations thereof (such as "including," "including," etc.) are open-ended expressions and should be understood as "including but not limited to," meaning that the listed content is not exhaustive and may include other content not explicitly mentioned. The term "based on" should be understood as "at least partially based on," meaning that the basis or condition referred to may not be the only factor and may involve other relevant factors. The term "one embodiment" should be understood as "at least one embodiment," meaning that the described embodiment is not the only possible implementation, and other similar embodiments may exist.
[0063] In this application, the terms "a" and "a plurality of" are used to modify related elements or features, and their expression is illustrative rather than restrictive. Unless otherwise expressly stated in the context, "a" should be understood as "at least one," and "a plurality of" should be understood as "at least two." Those skilled in the art should reasonably interpret these terms based on the semantic and logical relationships of the context to ensure that they cover the possibility of "one or more."
[0064] This invention provides the following technical solution:
[0065] 1. System Overall Architecture Design
[0066] This invention provides a user-identity-based dynamic routing enterprise WeChat intelligent robot system with one person, one agent. The overall layered architecture of this system is as follows: Figure 2As shown, the system adopts a three-layer decoupled architecture consisting of a unified WeChat interaction layer, a Hermes gateway routing layer, and a multi-Agent instance service layer. Real-time data interaction and command transmission are achieved entirely through the WebSocket long-connection protocol. This system breaks through the limitations of traditional single-Agent architectures, implementing five core innovative mechanisms: a unified robot entry mechanism, a precise user identity resolution mechanism, a user-Agent dynamic routing and distribution mechanism, a complete isolation mechanism for multiple Agent instances, and a user-level skill and memory differentiation configuration mechanism. While ensuring a consistent user experience, it completely achieves multi-user session isolation, information isolation, and skill isolation, solving the core problems of traditional robots such as contextual confusion, information overlap, and inability to provide personalized services.
[0067] 2. Core Technology Mechanism
[0068] (1) Unified entry point and global service mechanism
[0069] This system uses a single WeChat Work bot as the sole global interaction entry point. All employees within the enterprise do not need to switch between multiple bots; they can access intelligent services through a unified dialog box. The WeChat Work backend only needs to configure one set of bot credentials. The Gateway establishes a persistent message channel with the WeChat Work AI Bot gateway via a WebSocket long connection, and all user messages are pushed to the Hermes gateway in real time. This mechanism completely solves the problems of fragmented user experience and cumbersome operation and maintenance configuration in traditional multi-bot deployment models, enabling zero-threshold user access and lightweight operation and maintenance for administrators.
[0070] (2) User identity accurate parsing mechanism
[0071] After receiving message frames pushed by WeChat Work, the gateway automatically parses the unique user identifier (userid) embedded in the message body to accurately distinguish the sender of each message. Relying on WeChat Work's native identity system, user identity verification and extraction can be completed in real time and accurately without additional authorization or user login. This provides a unique identity basis for subsequent dynamic routing, user isolation, and personalized services, ensuring the accuracy and security of routing matching.
[0072] (3) User-Agent dynamic routing distribution mechanism
[0073] The system has a built-in standardized user-Agent routing mapping table, supporting custom configuration of the binding relationship between users and Agent instances. After the gateway resolves the user's identity, it automatically queries the routing table to complete intelligent distribution: for users who have bound a dedicated Agent, messages are accurately routed to the corresponding independent Agent instance; for users who have not bound an Agent, messages are routed to the public Agent instance by default to provide fallback service. It also supports flexible one-to-one and many-to-one binding, enabling both single-person dedicated Agent services and departmental-level batch dedicated services, adapting to the differentiated service needs of multi-level and multi-position enterprises.
[0074] (4) Complete isolation mechanism for multiple agent instances
[0075] The core innovation of this system lies in the deployment of multiple independent Agent instances, breaking the industry's inherent "single Agent global reuse" model. This system can create multiple independently running Agent instances, each with its own dedicated runtime environment, independent session management space, independent memory storage unit, and independent skill plugin set. Data between Agent instances is completely isolated, and their operation does not interfere with each other. The failure, upgrade, or debugging of a single Agent will not affect the normal use of other users, completely eliminating the problems of multi-user session overlap, context corruption, and information pollution, achieving secure isolation of user data at the architectural level. Simultaneously, the system checks the availability status of the target Agent before routing messages, ensuring that messages are forwarded only to normally online Agent instances, further enhancing system robustness.
[0076] (5) User message serial ordered processing mechanism
[0077] This system maintains an independent message processing queue for each user. Multiple messages from the same user are processed sequentially according to the order they are received, with the next message being processed only after the previous one is completed. This avoids issues such as out-of-order messages, request backlog, and incorrect responses for a single user. The message queues of different users are independent and do not block each other, allowing for parallel processing. This maximizes the system's concurrent processing capabilities while ensuring the continuity of individual user conversations.
[0078] (6) Deduplication and overflow prevention mechanism for replies
[0079] The gateway has a built-in reply deduplication queue to mitigate the sending frequency limitations of the WeChat Enterprise message push interface. The system manages deduplication based on the unique identifier (streamId) of each streaming reply; new replies with the same identifier automatically overwrite older ones, avoiding queue overflow issues triggered by high-frequency pushes. Simultaneously, a 300ms batch refresh mechanism is employed to merge multiple streaming edit events within a short period, ensuring both a smooth user experience and the stability and reliability of the push chain.
[0080] 3. System Operation Flow
[0081] Figure 3 The message routing process flowchart for this system includes the following steps:
[0082] The first step is system initialization. The administrator configures a unique robot and WebSocket connection credentials in the WeChat Work backend to complete the deployment of the Hermes gateway and the initialization of the routing table.
[0083] The second step is that all users of WeChat Work send conversation messages through a unified robot entry point, and the messages are uniformly pushed to the Hermes gateway.
[0084] The third step is for the gateway to parse the message frame, extract the user's unique userid identifier, and query the built-in route mapping table.
[0085] The fourth step is to match the target Agent instance according to the routing rules. Users who have been bound to the Agent are routed to their dedicated Agent, while users who have not been bound to the Agent are routed to the public Agent.
[0086] Fifth, the target agent invokes its own independent session history, personalized memory, and exclusive skill set to process user messages;
[0087] Step 6: After completing the response reasoning, the Agent sends the response data back to the gateway, which then forwards it to the WeChat Work client.
[0088] Step 7: Users receive personalized responses through a unified robot portal, with no awareness of the underlying routing and instance scheduling logic throughout the process.
[0089] To more clearly illustrate the technical solution of this application, the following will provide further explanation through specific scenario embodiments.
[0090] I. Environmental Preparation and System Deployment
[0091] To ensure stable system operation, standardized environment setup and system deployment should be completed in advance. The core deployment process is as follows:
[0092] 1. Configure WeChat Work Bot: Log in to the WeChat Work management backend, create an AI Bot mode smart bot, obtain a unique Bot ID and Secret credential, configure the WebSocket connection credential, and complete the message push permission activation.
[0093] 2. Gateway Service Deployment: Deploy the Hermes unified routing gateway, configure the core parameters for message reception, identity resolution, route matching, and message forwarding, and initialize the empty routing table and the default configuration of the public Agent.
[0094] 3. Agent Instance Creation: Through the gateway management interface or API interface, multiple independent Agent instances can be created according to the enterprise's job requirements. Different skill plugin sets such as R&D, sales, and general office can be configured for each instance. Each instance runs and is stored independently.
[0095] 4. User Route Binding: Administrators can configure the binding relationship between users and Agent instances in batches or individually through a visual interface, update the routing table, and complete personalized service adaptation configuration.
[0096] II. Core Functionality Code Implementation
[0097] 1. Core Logic of User Identity Resolution
[0098] The gateway receives WeChat message frames from Enterprise, accurately extracts the user's unique identifier, and provides a basis for route matching. The core code is as follows:
[0099] / / Extracting the user's unique identifier from WeChat Work message frames
[0100] function extractUserId(messageFrame) {
[0101] / / The message frame carries the enterprise WeChat user identity identifier
[0102] return messageFrame.body.from?.userid;
[0103] }
[0104] javascript
[0105] / / Configure a unique callback URL in WeChat Work for unified access to all user messages
[0106] / / Accurately extract the user's unique identifier from the message frame
[0107] function extractUserId(messageFrame) {
[0108] / / Parse the standard WeChat Work message structure to obtain the sender's userid
[0109] return messageFrame.body.from.userid;
[0110] }
[0111] 2. Core Logic of Dynamic Routing Based on User Identity
[0112] Intelligent distribution of dedicated agents and public agents based on routing tables enables differentiated route scheduling. The core code is as follows:
[0113] / / Routing table lookup: Find the corresponding Agent based on the user's identity
[0114] function routeMessage(userId, message) {
[0115] const route = getRouteByUserId(userId);
[0116] if (route) {
[0117] return forwardToAgent(route.agentId, message);
[0118] }
[0119] return forwardToPublicAgent(message);
[0120] }
[0121] javascript
[0122] / / Initialize the user-Agent route mapping table
[0123] const routeTable = new Map();
[0124] / / Dynamically distribute messages to the corresponding Agent instances based on user identity.
[0125] function routeMessage(userId, message) {
[0126] / / Query user-specific bound Agent
[0127] const agentId = routeTable.get(userId);
[0128] if (agentId) {
[0129] / / Routing to the user's dedicated agent to provide personalized isolation services
[0130] return forwardToAgent(agentId, message);
[0131] } else {
[0132] / / For users without binding, the default route is to the public agent as a fallback.
[0133] return forwardToPublicAgent(message);
[0134] }
[0135] }
[0136] 3. Independent Agent Instance Isolation Processing Logic
[0137] Each Agent instance has independent memory, session, and skills, achieving completely isolated message processing. The core code is as follows:
[0138] / / Each Agent instance has a completely independent runtime environment
[0139] class AgentInstance {
[0140] constructor(agentId) {
[0141] this.memory = new IndependentMemory(agentId); / / Independent memory
[0142] this.sessions = new SessionManager(agentId); / / Independent sessions
[0143] this.skills = new SkillManager(agentId); / / Independent skill set
[0144] }
[0145] }
[0146] javascript
[0147] / / Independent Agent instance class, achieving complete isolation across multiple dimensions
[0148] class AgentInstance {
[0149] constructor(agentId) {
[0150] this.agentId = agentId;
[0151] this.memory = new IndependentMemory(agentId); / / Independent memory storage
[0152] this.sessions = new SessionManager(agentId); / / Independent session management
[0153] this.skills = new SkillManager(agentId); / / Individual skill plugin set
[0154] }
[0155] / / Isolation message processing
[0156] async processMessage(userId, content) {
[0157] / / Load the current user's dedicated isolation session and memory
[0158] const session = await this.sessions.get(userId);
[0159] const context = await this.memory.getRelevant(userId, content);
[0160] / / Load the current Agent's exclusive skill set
[0161] const skills = this.skills.getEnabled();
[0162] / / Complete message reasoning and response in a completely isolated environment
[0163] return await this.llm.process({
[0164] content,
[0165] session
[0166] context,
[0167] skills
[0168] });
[0169] }
[0170] }
[0171] 4. User-independent message serial queue logic
[0172] A single-user independent queue ensures ordered message processing and avoids session corruption. The core code is as follows:
[0173] / / Maintain an independent serial processing queue for each user
[0174] const dispatchQueues = new Map();
[0175] function enqueueUserMessage(userId, message) {
[0176] const previous = dispatchQueues.get(userId) ?? Promise.resolve();
[0177] const current = previous.then(() => processMessage(userId,message));
[0178] dispatchQueues.set(userId, current);
[0179] }
[0180] javascript
[0181] / / Global User Message Queue Manager
[0182] const dispatchQueues = new Map();
[0183] / / Single-user message serial enqueue processing
[0184] async function enqueueUserMessage(userId, message) {
[0185] / / Get the user-specific queue; initialize it if it doesn't exist.
[0186] let queue = dispatchQueues.get(userId);
[0187] if (!queue) {
[0188] queue = Promise.resolve();
[0189] dispatchQueues.set(userId, queue);
[0190] }
[0191] / / Execute message processing tasks serially
[0192] queue = queue.then(async () => {
[0193] await routeMessage(userId, message);
[0194] });
[0195] dispatchQueues.set(userId, queue);
[0196] }
[0197] 5. User-Agent Binding Management Logic
[0198] To achieve flexible binding and automatic unbinding of users and agents, and ensure route uniqueness, the core code is as follows:
[0199] / / Bind a user to a specified Agent (to ensure route uniqueness)
[0200] function bindUserToAgent(userId, agentId) {
[0201] / / Remove the user's old bindings
[0202] routes = routes.filter(r => r.userId !== userId);
[0203] / / Create a new binding
[0204] routes.push({ userId, agentId});
[0205] agents.forEach(a => {
[0206] if (a.id === agentId) a.userIds.push(userId);
[0207] else a.userIds = a.userIds.filter(id => id !== userId);
[0208] });
[0209] }
[0210] javascript
[0211] / / Routing data structure definition
[0212] const routeData = {
[0213] routes: [
[0214] { userId: "zhangsan", agentId: "agent-dev"},
[0215] { userId: "lisi", agentId: "agent-sales"}
[0216] ],
[0217] agents: [
[0218] {
[0219] id: "agent-dev",
[0220] name: "R&D Department Agent",
[0221] userIds: ["zhangsan"],
[0222] isPublic: false,
[0223] skills: ["Code analysis", "Technical Q&A"]
[0224] },
[0225] {
[0226] id: "agent-sales",
[0227] name: "Sales Agent"
[0228] userIds: ["lisi"],
[0229] isPublic: false,
[0230] Skills: ["Customer Management", "CRM Query"]
[0231] },
[0232] {
[0233] id: "agent-public",
[0234] name: "Public Agent",
[0235] userIds: [],
[0236] isPublic: true,
[0237] skills: ["General FAQs", "Daily Office Work"]
[0238] } ]
[0240] };
[0241] / / User and Agent binding update function
[0242] function bindUserToAgent(userId, agentId) {
[0243] / / Remove old user binding relationships to ensure one-to-one uniqueness
[0244] routeData.routes = routeData.routes.filter(r => r.userId !==userId);
[0245] / / Add a binding relationship
[0246] routeData.routes.push({ userId, agentId});
[0247] / / Update the target agent user list
[0248] const agent = routeData.agents.find(a => a.id === agentId);
[0249] if (!agent.userIds.includes(userId)) {
[0250] agent.userIds.push(userId);
[0251] }
[0252] / / Remove the user from other agents to avoid conflicts.
[0253] routeData.agents.forEach(a => {
[0254] if (a.id !== agentId) {
[0255] a.userIds = a.userIds.filter(id => id !== userId);
[0256] }
[0257] });
[0258] }
[0259] III. Core Application Examples
[0260] Example 1: Agent creation and user binding process
[0261] Administrators can create agents and bind users through API or web management interface to achieve personalized service configuration: First, call the creation interface, enter the agent name and skill type to generate an independent agent instance; then configure the user binding relationship to associate users with corresponding positions with dedicated agents; after the binding takes effect, all messages of the user will be automatically routed to the dedicated instance, and unbound users will use the public agent by default, without the need for manual operation by the user.
[0262] Example 2: Single-user personalized dialogue process
[0263] Enterprise employees initiate conversations through a unified chatbot portal. The gateway automatically identifies the user and routes them to a dedicated Agent. The Agent utilizes the user's independent historical conversations, personalized memories, and exclusive skills to handle questions and answers, completely isolating the user from other users' data throughout the process. Multiple conversations can continue in context, enabling continuous, accurate, and personalized intelligent services without interference from other users' conversations.
[0264] Example 3: Multi-user Differentiated Isolation Service Process
[0265] Within the same enterprise, R&D users and sales users can access completely different intelligent services through the same chatbot entry point: R&D user messages are routed to the R&D Agent, invoking code analysis and technical Q&A skills; sales user messages are routed to the Sales Agent, invoking customer management and CRM query skills. The two instances run independently, with no data visible to each other, and their question-and-answer logic, skill capabilities, and conversation memory are completely differentiated, truly achieving a unified entry point and personalized, isolated services.
[0266] Example 4: Verification of the effectiveness of multi-user information isolation
[0267] Each user's dedicated agent can only read their own user's session and memory data, and cannot access information across users. When a user queries their personal conversation history or requests personalized information, the agent can accurately match the dedicated data without mixing up information from other users. This completely solves the problems of mixed multi-user sessions, information leakage, and incorrect question-and-answer responses in traditional single-agent architectures, ensuring enterprise office data security and service accuracy.
[0268] IV. Daily Operation and Maintenance Process
[0269] Administrators can achieve lightweight operation and maintenance throughout the entire process through the gateway's visual interface: real-time viewing of the running status, online status, and message processing volume of all Agent instances; support for creating, deleting, starting, and stopping Agent instances as needed, and flexible configuration of skill plugins; support for batch adjustment of user-Agent binding relationships to adapt to enterprise personnel changes and job adjustments; real-time monitoring of system operation logs, Q&A records, and anomaly information to quickly troubleshoot faults without complex configuration and manual operation and maintenance.
[0270] The flowcharts and block diagrams in the accompanying drawings illustrate possible implementations of systems, methods, and computer program products according to various embodiments of this application, including architecture, functionality, and operation. In these figures, each block may represent a module, program segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should be noted that each block in the block diagrams and / or flowcharts, and combinations thereof, can be implemented using either a dedicated hardware-based system or a combination of dedicated hardware and computer instructions to achieve the specified function or operation.
[0271] Embodiments of this application also disclose an electronic device, including: a processor, a communication interface, a memory for storing a processor-executable computer program, and a communication bus. The processor, communication interface, and memory communicate with each other via the communication bus. The processor executes the executable computer program to implement the steps of the aforementioned method for user-identity-based dynamic routing and dedicated isolation services for a single agent.
[0272] It is understood that, in addition to memory and a processor, this electronic device may also include input devices (such as a keyboard), output devices (such as a display), and other communication modules. These input devices, output devices, and other communication modules all communicate with the processor through I / O interfaces (i.e., input / output interfaces).
[0273] The operations described in this application can be implemented by writing computer program code using one or more programming languages or a combination thereof. The programming languages include, but are not limited to, the following types:
[0274] Object-oriented programming languages, such as Java, Smalltalk, C++, etc.
[0275] Conventional procedural programming languages, such as "C" or similar programming languages.
[0276] The execution methods of program code include, but are not limited to:
[0277] It runs entirely on the user's computer;
[0278] Part of it executes on the user's computer, and part of it executes on a remote computer;
[0279] Execute as a standalone software package;
[0280] It is executed entirely on a remote computer or server.
[0281] In scenarios involving remote computers, the remote computer can connect to the user's computer via any type of network, including but not limited to local area networks (LANs) or wide area networks (WANs). Furthermore, the remote computer can also connect to external computers through an internet service provider, for example, by utilizing the internet for connection.
[0282] Furthermore, this application also discloses a computer-readable storage medium, which, when the instructions in the computer-readable storage medium are executed by the processor of an electronic device, enables the electronic device to perform the various steps of the user identity-based dynamic routing method for exclusive isolation services for one person, one agent disclosed in this application.
[0283] In the context of this application, a computer-readable storage medium refers to a tangible medium capable of storing computer program code and related data. Specific examples include, but are not limited to, the following:
[0284] (1) Portable computer disk: such as floppy disks and other removable magnetic storage media.
[0285] (2) Hard disk: including mechanical hard disks and solid-state hard disks and other fixed storage devices.
[0286] (3) Random Access Memory (RAM): A volatile storage medium used for temporary storage of data and program code.
[0287] (4) Read-only memory (ROM): a non-volatile storage medium used to store fixed programs and data.
[0288] (5) Erasable programmable read-only memory (EPROM) or flash memory: non-volatile storage media that supports multiple erasures and reprogrammings.
[0289] (6) Fiber optic storage devices: storage media based on fiber optic technology.
[0290] (7) Portable compact disc read-only memory (CD-ROM): a read-only medium that stores data in the form of an optical disc.
[0291] (8) Optical storage devices: such as DVDs, Blu-ray discs and other storage media based on optical principles.
[0292] (9) Magnetic storage devices: such as magnetic tapes, disks and other storage media based on magnetic principles.
[0293] (10) Any suitable combination of the above: for example, combining multiple storage media to meet different storage needs.
[0294] These computer-readable storage media can be used to store the program code and related data described in this application to support program execution and persistent data storage.
[0295] Specifically, according to embodiments of this application, the processes described in the flowcharts can be implemented as computer software programs. For example, embodiments of this application relate to a computer program product comprising a computer program carried on a non-transitory computer-readable medium. This computer program contains program code for executing the user identity-based dynamic routing method for a dedicated isolation service for each user and agent disclosed in this application. When this computer program is executed by a processing system, it can achieve the functions defined in the embodiments of this application.
[0296] While the foregoing discussion contains several specific implementation details, these details should not be construed as limiting the scope of this application. The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this application is not limited to technical solutions formed by specific combinations of the above-described technical features. Furthermore, this application should also cover other technical solutions formed by any combination of the above-described technical features or their equivalents without departing from the foregoing disclosed concept.
[0297] Those skilled in the art should also understand that modifications can be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features, without departing from the spirit and scope of the technical solutions of the embodiments of this application. These modifications or substitutions will not cause the essence of the corresponding technical solutions to deviate from the core spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A user-identity-based dynamic routing enterprise WeChat intelligent robot system, characterized in that, include: The Enterprise WeChat unified interaction layer is configured to use a single Enterprise WeChat robot as the only global interaction entry point, receive messages sent by all users within the enterprise, and push the messages to the Hermes gateway routing layer via a WebSocket long connection. The Hermes gateway routing layer is configured to parse the received message frame, extract the unique user identifier carried in it, query the preset user-Agent routing mapping table, and distribute the current message to the corresponding Agent instance according to the query result; The multi-Agent instance service layer is configured with multiple independently running Agent instances and at least one public Agent instance. Each Agent instance is deployed independently in its own runtime environment and has an independent session management space, an independent memory storage unit, and an independent skill plugin set. It is used to process user messages routed to this instance in isolation and generate response data. Session data, memory data, and skill configurations between different Agent instances are not visible to each other. The Hermes gateway routing layer is also configured to send the response data back to the WeChat unified interaction layer, and the unified interaction layer will push the response data to the corresponding user client.
2. The enterprise WeChat intelligent robot system according to claim 1, characterized in that, The Hermes gateway routing layer includes: The identity resolution module is used to parse and extract the userid field of the sending user from the standard WeChat Enterprise message frame, as a unique identifier for the user; The routing matching module is used to query a preset user-Agent routing mapping table based on the user's unique identifier to determine the target Agent instance; The message forwarding module is used to forward user messages to the target Agent instance, and when the target Agent instance is unavailable, to route user messages to a preset public Agent instance.
3. The enterprise WeChat intelligent robot system according to claim 1, characterized in that, The system also includes a message queue management unit, configured to maintain an independent message processing queue for each user, with multiple messages from the same user being processed serially in the order of receipt, and message queues from different users being independent and executed in parallel.
4. The enterprise WeChat intelligent robot system according to claim 1, characterized in that, The Hermes gateway routing layer also includes a reply deduplication unit, which is configured to manage the deduplication of reply messages waiting to be pushed based on the unique identifier of the streaming reply. New replies with the same identifier overwrite old replies, and reply messages are pushed to the WeChat unified interaction layer in a batch refresh manner. And an availability check unit, configured to detect the running status of the target Agent instance before distributing user messages to the target Agent instance, and to perform message forwarding only when the target Agent instance is online and available.
5. The enterprise WeChat intelligent robot system according to claim 1, characterized in that, The user-Agent routing mapping table supports one-to-one binding and many-to-one binding. One-to-one binding means that one user is uniquely bound to one dedicated Agent instance, while many-to-one binding means that multiple users are jointly bound to the same dedicated Agent instance.
6. The enterprise WeChat intelligent robot system according to claim 1, characterized in that, The public Agent instance is configured to receive user messages distributed by the Hermes gateway routing layer that are not bound to a dedicated Agent instance, and to provide a generalized fallback question and answer service.
7. A method for user-identity-based dynamic routing and dedicated isolation service for one person, one agent, implemented based on the system described in any one of claims 1 to 6, characterized in that... Includes the following steps: S1. System Initialization: Configure a unique robot and WebSocket connection credential in the WeChat management backend, deploy the Hermes gateway routing layer, initialize the user-Agent routing mapping table, and create multiple independently running Agent instances according to the enterprise's job requirements, and configure differentiated skill plugin sets for each instance. S2. Unified Message Reception: The Enterprise WeChat unified interaction layer receives all users' conversation messages through the unique robot and pushes all messages to the Hermes gateway routing layer through a WebSocket long connection. S3. User Identity Resolution: The Hermes gateway routing layer parses the received message frame and extracts the unique identity identifier of the message sender. S4. Dynamic route matching: The Hermes gateway routing layer uses the unique identifier as an index to query the user-Agent route mapping table to determine whether the current user has been bound to a dedicated Agent instance. S5. Message Distribution Processing: If the current user has bound a dedicated Agent instance, the message will be routed to the dedicated Agent instance bound to the user; if not, the message will be routed to the preset public Agent instance; the target Agent instance calls its own independent session history, memory data and skill plugin set to perform reasoning processing on the user message and generate response data. S6. Response Feedback Push: The Hermes gateway routing layer receives the response data returned by the target Agent instance, sends it back to the WeChat unified interaction layer, and the unified interaction layer pushes the response data to the corresponding user's WeChat client.
8. The method according to claim 7, characterized in that, In step S5, before the target Agent instance processes the user message, it also includes: adding the current user message to a dedicated message processing queue maintained independently for that user, and processing each message in the queue serially according to the message receiving order; When the target Agent instance processes user messages, different Agent instances process their respective received user messages in parallel, and messages from different users under the same Agent instance do not block each other.
9. The method according to claim 7, characterized in that, In step S6, before the Hermes gateway routing layer sends back the response data, the following steps are also included: deduplicating multiple replies to be pushed based on the unique identifier of the streaming reply, with new replies with the same identifier overwriting old replies, and pushing them to the WeChat unified interaction layer in a batch refresh manner.
10. The method according to claim 7, characterized in that, The method also includes a route binding management step: the administrator configures or changes the binding relationship between users and Agent instances through a visual interface or API interface, and synchronizes the updated binding relationship to the user-Agent route mapping table, ensuring that the same user is bound to only one Agent instance when the binding is changed.