{"record":{"id":"3ae0f8ff5e3234f7","repo":"RocketChat/Rocket.Chat","slug":"invalid-token-for-livechat-message","errorCode":null,"errorMessage":"Invalid token for livechat message","messagePattern":"Invalid token for livechat message","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/livechat.ts","lineNumber":57,"sourceCode":"\tconstructor(private readonly orch: IAppServerOrchestrator) {\n\t\tsuper();\n\t}\n\n\tprotected isOnline(departmentId?: string): boolean {\n\t\t// This function will be converted to sync inside the apps-engine code\n\t\t// TODO: Track Deprecation\n\t\treturn deasyncPromise(online(departmentId));\n\t}\n\n\tprotected async isOnlineAsync(departmentId?: string): Promise<boolean> {\n\t\treturn online(departmentId);\n\t}\n\n\tprotected async createMessage(message: IAppsLivechatMessage, appId: string): Promise<string> {\n\t\tthis.orch.debugLog(`The App ${appId} is creating a new message.`);\n\n\t\tif (!message.token) {\n\t\t\tthrow new Error('Invalid token for livechat message');\n\t\t}\n\n\t\t// #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed.\n\t\tconst guest = this.orch.getConverters().get('visitors').convertAppVisitor(message.visitor);\n\t\tconst appMessage = await this.orch.getConverters().get('messages').convertAppMessage(message);\n\t\tconst livechatMessage = appMessage as ILivechatMessage | undefined;\n\n\t\tconst msg = await sendMessage({\n\t\t\tguest: guest as ILivechatVisitor,\n\t\t\tmessage: livechatMessage as ILivechatMessage,\n\t\t\tagent: undefined,\n\t\t\troomInfo: {\n\t\t\t\tsource: {\n\t\t\t\t\ttype: OmnichannelSourceType.APP,\n\t\t\t\t\tid: appId,\n\t\t\t\t\talias: this.orch.getManager()?.getOneById(appId)?.getNameSlug(),\n\t\t\t\t},\n\t\t\t},","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/2a7de457074cbb4d4373fbd9a4e5bea292c9c764/apps/meteor/app/apps/server/bridges/livechat.ts#L39-L75","documentation":"Error \"Invalid token for livechat message\" thrown in RocketChat/Rocket.Chat.","triggerScenarios":"Thrown at apps/meteor/app/apps/server/bridges/livechat.ts:57 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include the visitor's livechat token in the message object (message.token) when creating a livechat message.","Obtain the token from the visitor record used to open the livechat session and pass it through unchanged."],"exampleFix":"Validate the livechat token against the room/visitor before accepting the message: if (!token || room.v.token !== token) { throw new Error('Invalid token for livechat message'); }","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2a7de457074cbb4d4373fbd9a4e5bea292c9c764","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}