RocketChat/Rocket.Chat · error · Error

Invalid trigger

Error message

Invalid trigger

What it means

The public, unauthenticated route livechat/triggers/:_id/external-service/call loads the trigger by URL id with LivechatTrigger.findOneById; a miss throws 'Invalid trigger'. authRequired is false (widget traffic), so any visitor hitting a stale trigger id produces this error.

Source

Thrown at apps/meteor/ee/server/api/v1/omnichannel/triggers.ts:82

	'livechat/triggers/:_id/external-service/call',
	{
		authRequired: false,
		rateLimiterOptions: {
			numRequestsAllowed: 10,
			intervalTimeInMS: 60000,
		},
		validateParams: isLivechatTriggerWebhookCallParams,
		license: ['livechat-enterprise'],
	},
	{
		async post() {
			const { _id: triggerId } = this.urlParams;
			const { token: visitorToken, extraData } = this.bodyParams;

			const trigger = await LivechatTrigger.findOneById(triggerId);

			if (!trigger) {
				throw new Error('Invalid trigger');
			}

			if (!trigger?.actions.length || !isExternalServiceTrigger(trigger)) {
				throw new Error('Trigger is not configured to use an external service');
			}

			const { params: { serviceTimeout = 5000, serviceUrl, serviceFallbackMessage = 'trigger-default-fallback-message' } = {} } =
				trigger.actions[0];

			if (!serviceUrl) {
				throw new Error('Invalid service URL');
			}

			const token = settings.get<string>('Livechat_secret_token');

			if (!token) {
				throw new Error('Livechat secret token is not configured');
			}

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Resolve the current trigger _id via GET /api/v1/livechat/triggers (as a manager) and update your integration.
  2. After trigger changes, invalidate widget/client caches or serve the id dynamically instead of bundling it.
  3. If the trigger was deleted intentionally, remove the call from your widget/integration.

Example fix

// before
await api.post(`/v1/livechat/triggers/${HARDCODED_ID}/external-service/call`, { token, extraData });

// after
const { triggers } = await api.get('/v1/livechat/triggers', { params: { count: 0 } });
const t = triggers.find((x) => x.name === 'My trigger');
if (t) await api.post(`/v1/livechat/triggers/${t._id}/external-service/call`, { token, extraData });
Defensive patterns

Strategy: validation

Validate before calling

const { triggers } = await api.get('/v1/livechat/triggers', { params: { count: 0 } });
const trigger = triggers.find((t) => t._id === triggerId);
if (!trigger) throw new Error(`Trigger ${triggerId} no longer exists`);
await api.post(`/v1/livechat/triggers/${trigger._id}/external-service/call`, body);

Try / catch

try {
  await api.post(`/v1/livechat/triggers/${triggerId}/external-service/call`, body);
} catch (e) {
  if (e?.response?.data?.error === 'Invalid trigger') {
    // resolve the current trigger id and update your integration
  } else throw e;
}

Prevention

When it happens

Trigger: POST /api/v1/livechat/triggers/<stale-or-deleted-id>/external-service/call, e.g. a livechat widget or integration still referencing a trigger id after the trigger was deleted or recreated.

Common situations: Visitor browsers caching old trigger ids after admins rebuilt triggers; deployments that recreate triggers with new ids; integrations that hard-code a trigger id instead of resolving it by name.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/33de282e41700807. Report an issue: GitHub.