{"record":{"id":"908474aed86c5a63","repo":"RocketChat/Rocket.Chat","slug":"error-agent-status-service-offline","errorCode":"error-agent-status-service-offline","errorMessage":"error-agent-status-service-offline","messagePattern":"error-agent-status-service-offline","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/omnichannel/takeInquiry.ts","lineNumber":36,"sourceCode":"\t\tthrow new Meteor.Error('error-not-found', 'Inquiry not found', {\n\t\t\tmethod: 'livechat:takeInquiry',\n\t\t});\n\t}\n\n\tif (inquiry.status === 'taken') {\n\t\tthrow new Meteor.Error('error-inquiry-taken', 'Inquiry already taken', {\n\t\t\tmethod: 'livechat:takeInquiry',\n\t\t});\n\t}\n\n\tconst user = await Users.findOneOnlineAgentById(\n\t\tuserId,\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\tthrow new Meteor.Error('error-agent-status-service-offline', 'Agent status is offline or Omnichannel service is not active', {\n\t\t\tmethod: 'livechat:takeInquiry',\n\t\t\t...(process.env.TEST_MODE && {\n\t\t\t\tLivechat_enabled_when_agent_idle: settings.get<boolean>('Livechat_enabled_when_agent_idle'),\n\t\t\t\tLivechat_accept_chats_with_no_agents: settings.get<boolean>('Livechat_accept_chats_with_no_agents'),\n\t\t\t\tuser: await Users.findOneById(userId),\n\t\t\t}),\n\t\t});\n\t}\n\n\tconst room = await LivechatRooms.findOneById(inquiry.rid);\n\tif (!room || !(await Omnichannel.isWithinMACLimit(room))) {\n\t\tthrow new Meteor.Error('error-mac-limit-reached');\n\t}\n\n\tconst contactId = room.contactId ?? (await migrateVisitorIfMissingContact(room.v._id, room.source));\n\tif (contactId) {\n\t\tconst isAgentAvailableToTakeContactInquiryResult = await isAgentAvailableToTakeContactInquiry(inquiry.v._id, room.source, contactId);\n\t\tif (!isAgentAvailableToTakeContactInquiryResult.value) {","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/omnichannel/takeInquiry.ts#L18-L54","documentation":"Before letting a user take an inquiry, takeInquiry re-validates the taker via Users.findOneOnlineAgentById considering Livechat_enabled_when_agent_idle and Livechat_accept_chats_with_no_agents; a null result throws Meteor.Error('error-agent-status-service-offline', 'Agent status is offline or Omnichannel service is not active'). In TEST_MODE the error payload includes the relevant settings and the raw user doc for debugging.","triggerScenarios":"Calling livechat:takeInquiry while the taking user is not seen as an online agent: user status offline/busy/away, agent idle with Livechat_enabled_when_agent_idle=false, the user not being an omnichannel agent at all, or their livechat status derived as offline.","commonSituations":"Agent's socket dropped so LivechatAgentActivityMonitor flipped them to away/idle, agent set themselves away then tried to grab a chat from a stale UI, API/scripted calls without an active connection, or default auto-away settings marking the agent idle.","solutions":["Have the agent set their status back to online (avatar menu > online) and retry","Check Livechat_enabled_when_agent_idle — enable it if idle agents must still take inquiries","Verify the user appears in Omnichannel > Agents with an online status","Inspect LivechatAgentActivityMonitor behavior/auto-away settings if statuses flip unexpectedly; keep a live websocket connection so presence stays online"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { Users } from '@rocket.chat/models';\nimport { settings } from '../../settings';\n\nconst onlineAgent = await Users.findOneOnlineAgentById(\n  userId,\n  settings.get<boolean>('Livechat_enabled_when_agent_idle'),\n  settings.get<boolean>('Livechat_accept_chats_with_no_agents'),\n);\nif (!onlineAgent) {\n  throw new Meteor.Error('error-agent-status-service-offline', 'Set status online before taking inquiries');\n}\nawait Meteor.callAsync('livechat:takeInquiry', inquiryId);","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('livechat:takeInquiry', inquiryId);\n} catch (err) {\n  if (err instanceof Meteor.Error && err.error === 'error-agent-status-service-offline') {\n    // prompt the agent to go online / reconnect, then retry after status change\n  } else {\n    throw err;\n  }\n}","preventionTips":["Keep an active websocket connection so agent presence stays 'online' while working the queue","Review Livechat_enabled_when_agent_idle against your team's idle habits","Watch LivechatAgentActivityMonitor auto-away settings so status doesn't silently flip"],"tags":["omnichannel","agent-status","presence","inquiry","take-inquiry"],"backgroundTag":"agent-offline","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}