{"record":{"id":"e3a807c741b0468c","repo":"RocketChat/Rocket.Chat","slug":"provided-agent-is-not-online","errorCode":null,"errorMessage":"Provided agent is not online","messagePattern":"Provided agent is not online","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/hooks/omnichannel/checkAgentBeforeTakeInquiry.ts","lineNumber":37,"sourceCode":"\t\tdepartment: string;\n\t};\n\toptions: {\n\t\tforwardingToDepartment?: {\n\t\t\toldDepartmentId: string;\n\t\t\ttransferData: any;\n\t\t};\n\t\tclientAction?: boolean;\n\t};\n}) => {\n\tif (!inquiry?._id || !agent?.agentId) {\n\t\tcbLogger.debug('No inquiry or agent provided');\n\t\tthrow new Error('No inquiry or agent provided');\n\t}\n\tconst { agentId } = agent;\n\n\tif (!(await checkOnlineAgents(undefined, agent))) {\n\t\tcbLogger.debug('Provided agent is not online');\n\t\tthrow new Error('Provided agent is not online');\n\t}\n\n\tif (!settings.get('Livechat_waiting_queue')) {\n\t\tcbLogger.info({ msg: 'Chat can be taken by Agent: waiting queue is disabled', agentId });\n\t\treturn agent;\n\t}\n\n\tif (await allowAgentSkipQueue(agent)) {\n\t\tcbLogger.info({ msg: 'Chat can be taken by Agent: agent can skip queue', agentId });\n\t\treturn agent;\n\t}\n\n\tconst { department: departmentId } = inquiry;\n\tconst user = await Users.getAgentAndAmountOngoingChats(agentId, departmentId);\n\tif (!user) {\n\t\tcbLogger.debug({ msg: 'No valid agent found', agentId });\n\t\tthrow new Error('No valid agent found');\n\t}","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/hooks/omnichannel/checkAgentBeforeTakeInquiry.ts#L19-L55","documentation":"Thrown by the `livechat.checkAgentBeforeTakeInquiry` callback when `checkOnlineAgents(undefined, agent)` returns false, meaning the provided agent is not currently considered online/available. It is a plain `Error`; logged at debug level first. It prevents taking an inquiry by an agent who cannot accept it.","triggerScenarios":"Invoking the take-inquiry callback for an agent whose livechat status is offline/away, so `checkOnlineAgents` returns false.","commonSituations":"Agent set themselves away/offline then attempted to take an inquiry; agent's livechat availability not yet synced; agent removed from service while action in flight.","solutions":["Have the agent set their livechat status to available/online before taking the inquiry.","Verify `checkOnlineAgents` reflects current status (no stale cache).","Reassign the inquiry to an online agent."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { checkOnlineAgents } from '../../../../server/lib/livechat';\n\nasync function agentIsOnline(agent: ILivechatAgent): Promise<boolean> {\n\treturn checkOnlineAgents(undefined, agent);\n}","typeGuard":"function isAgentNotOnlineError(e: unknown): boolean {\n\treturn e instanceof Error && e.message === 'Provided agent is not online';\n}","tryCatchPattern":"try {\n\tawait callbacks.run('livechat.checkAgentBeforeTakeInquiry', inquiry, agent);\n} catch (e) {\n\tif (e instanceof Error && e.message === 'Provided agent is not online') {\n\t\t// agent must set status to available first\n\t}\n\tthrow e;\n}","preventionTips":["Ensure the agent's livechat status is online/available before taking inquiries.","Refresh agent status to avoid stale availability data.","Reassign to an online agent when the target is away."],"tags":["omnichannel","livechat","agents","validation","ee"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}