{"record":{"id":"38fb0b92b5a39835","repo":"RocketChat/Rocket.Chat","slug":"error-user-is-offline","errorCode":"error-user-is-offline","errorMessage":"error-user-is-offline","messagePattern":"error-user-is-offline","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/omnichannel/Helper.ts","lineNumber":510,"sourceCode":"\t\tuserId: transferData.userId,\n\t});\n\n\tconst { userId: agentId, clientAction } = transferData;\n\tif (!agentId) {\n\t\tthrow new Error('error-invalid-agent');\n\t}\n\tconst user = await Users.findOneOnlineAgentById(\n\t\tagentId,\n\t\tsettings.get<boolean>('Livechat_enabled_when_agent_idle'),\n\t\tsettings.get<boolean>('Livechat_accept_chats_with_no_agents'),\n\t\t{},\n\t);\n\tif (!user) {\n\t\tlogger.debug({\n\t\t\tmsg: 'Agent is offline. Cannot forward',\n\t\t\tagentId,\n\t\t});\n\t\tthrow new Error('error-user-is-offline');\n\t}\n\n\tconst { _id: rid, servedBy: oldServedBy } = room;\n\tconst inquiry = await LivechatInquiry.findOneByRoomId(rid, {});\n\tif (!inquiry) {\n\t\tlogger.debug({\n\t\t\tmsg: 'No inquiries found for room. Cannot forward',\n\t\t\troomId: room._id,\n\t\t});\n\t\tthrow new Error('error-invalid-inquiry');\n\t}\n\n\tif (oldServedBy && agentId === oldServedBy._id) {\n\t\tthrow new Error('error-selected-agent-room-agent-are-same');\n\t}\n\n\tconst { username } = user;\n\tconst agent = { agentId, username };","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/omnichannel/Helper.ts#L492-L528","documentation":"forwardRoomToAgent resolves the target with Users.findOneOnlineAgentById(agentId, Livechat_enabled_when_agent_idle, Livechat_accept_chats_with_no_agents); a null result throws error-user-is-offline. Whether away/busy/idle agents count as online depends on those two settings, so the same agent can be a valid forward target on one workspace and not on another.","triggerScenarios":"Forwarding a livechat room to an agent whose status is away/busy while Livechat_enabled_when_agent_idle is false; agent logged out mid-shift; agent turned off their livechat availability.","commonSituations":"Agents forgetting to return status to online; retrying a forward after the target agent went idle; workspace tightened the idle-agent settings.","solutions":["Pick a different online agent, or forward to the department queue instead","Enable Livechat_enabled_when_agent_idle if business rules allow idle agents to receive forwards","Check the target agent's livechat availability toggle and connection before retrying"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const agent = await Users.findOneOnlineAgentById(\n  agentId,\n  settings.get('Livechat_enabled_when_agent_idle'),\n  settings.get('Livechat_accept_chats_with_no_agents'),\n  { projection: { _id: 1 } },\n);\nif (!agent) {\n  // pick another agent or forward to the department queue instead\n}","typeGuard":null,"tryCatchPattern":"try {\n  await forwardRoomToAgent(room, transferData, guest);\n} catch (err) {\n  if (err instanceof Error && err.message === 'error-user-is-offline') {\n    // offer department forward or another online agent\n  } else throw err;\n}","preventionTips":["Show live agent availability in the transfer dialog before submit","Tune Livechat_enabled_when_agent_idle to match your routing policy","Prefer department forwards when agent availability is uncertain"],"tags":["omnichannel","livechat","agent-status","transfer","rocket-chat"],"backgroundTag":"agent-offline","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}