RocketChat/Rocket.Chat · error · Error

Invalid token for livechat message

Error message

Invalid token for livechat message

What it means

Error "Invalid token for livechat message" thrown in RocketChat/Rocket.Chat.

Solutions

  1. Include the visitor's livechat token in the message object (message.token) when creating a livechat message.
  2. Obtain the token from the visitor record used to open the livechat session and pass it through unchanged.

Example fix

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'); }

When it happens

Trigger: Thrown at apps/meteor/app/apps/server/bridges/livechat.ts:57 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of RocketChat/Rocket.Chat@2a7de45707 (2026-08-18). Data as JSON: /api/errors/3ae0f8ff5e3234f7. Report an issue: GitHub.

Appendix: source

Thrown at apps/meteor/app/apps/server/bridges/livechat.ts:57

	constructor(private readonly orch: IAppServerOrchestrator) {
		super();
	}

	protected isOnline(departmentId?: string): boolean {
		// This function will be converted to sync inside the apps-engine code
		// TODO: Track Deprecation
		return deasyncPromise(online(departmentId));
	}

	protected async isOnlineAsync(departmentId?: string): Promise<boolean> {
		return online(departmentId);
	}

	protected async createMessage(message: IAppsLivechatMessage, appId: string): Promise<string> {
		this.orch.debugLog(`The App ${appId} is creating a new message.`);

		if (!message.token) {
			throw new Error('Invalid token for livechat message');
		}

		// #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed.
		const guest = this.orch.getConverters().get('visitors').convertAppVisitor(message.visitor);
		const appMessage = await this.orch.getConverters().get('messages').convertAppMessage(message);
		const livechatMessage = appMessage as ILivechatMessage | undefined;

		const msg = await sendMessage({
			guest: guest as ILivechatVisitor,
			message: livechatMessage as ILivechatMessage,
			agent: undefined,
			roomInfo: {
				source: {
					type: OmnichannelSourceType.APP,
					id: appId,
					alias: this.orch.getManager()?.getOneById(appId)?.getNameSlug(),
				},
			},

View on GitHub (pinned to 2a7de45707)