File tree Expand file tree Collapse file tree
packages/models/src/helpers/omnichannel Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,15 @@ import { UserStatus } from '@rocket.chat/core-typings';
22import type { IUser } from '@rocket.chat/core-typings' ;
33import type { Filter } from 'mongodb' ;
44
5+ /**
6+ * Builds the query to find online and available agents for livechat auto-assignment.
7+ * * According to product rules, the primary conditions for auto-assignment are:
8+ * - User must have the 'livechat-agent' role.
9+ * - Livechat service status (`statusLivechat`) must be 'available'.
10+ * - User's global status must NOT be 'offline' (Bots are exempt from this rule).
11+ * - If the "Accept new omnichannel requests when the agent is idle" (aka `Livechat_enabled_when_agent_idle`) setting is OFF,
12+ * then the statusConnection must NOT be 'away'.
13+ */
514export const queryStatusAgentOnline = ( extraFilters = { } , isLivechatEnabledWhenAgentIdle ?: boolean ) : Filter < IUser > => ( {
615 statusLivechat : 'available' ,
716 roles : 'livechat-agent' ,
You can’t perform that action at this time.
0 commit comments