{"record":{"id":"33de282e41700807","repo":"RocketChat/Rocket.Chat","slug":"invalid-trigger","errorCode":null,"errorMessage":"Invalid trigger","messagePattern":"Invalid trigger","errorType":"exception","errorClass":"Error","httpStatus":400,"severity":"error","filePath":"apps/meteor/ee/server/api/v1/omnichannel/triggers.ts","lineNumber":82,"sourceCode":"\t'livechat/triggers/:_id/external-service/call',\n\t{\n\t\tauthRequired: false,\n\t\trateLimiterOptions: {\n\t\t\tnumRequestsAllowed: 10,\n\t\t\tintervalTimeInMS: 60000,\n\t\t},\n\t\tvalidateParams: isLivechatTriggerWebhookCallParams,\n\t\tlicense: ['livechat-enterprise'],\n\t},\n\t{\n\t\tasync post() {\n\t\t\tconst { _id: triggerId } = this.urlParams;\n\t\t\tconst { token: visitorToken, extraData } = this.bodyParams;\n\n\t\t\tconst trigger = await LivechatTrigger.findOneById(triggerId);\n\n\t\t\tif (!trigger) {\n\t\t\t\tthrow new Error('Invalid trigger');\n\t\t\t}\n\n\t\t\tif (!trigger?.actions.length || !isExternalServiceTrigger(trigger)) {\n\t\t\t\tthrow new Error('Trigger is not configured to use an external service');\n\t\t\t}\n\n\t\t\tconst { params: { serviceTimeout = 5000, serviceUrl, serviceFallbackMessage = 'trigger-default-fallback-message' } = {} } =\n\t\t\t\ttrigger.actions[0];\n\n\t\t\tif (!serviceUrl) {\n\t\t\t\tthrow new Error('Invalid service URL');\n\t\t\t}\n\n\t\t\tconst token = settings.get<string>('Livechat_secret_token');\n\n\t\t\tif (!token) {\n\t\t\t\tthrow new Error('Livechat secret token is not configured');\n\t\t\t}","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/api/v1/omnichannel/triggers.ts#L64-L100","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Resolve the current trigger _id via GET /api/v1/livechat/triggers (as a manager) and update your integration.","After trigger changes, invalidate widget/client caches or serve the id dynamically instead of bundling it.","If the trigger was deleted intentionally, remove the call from your widget/integration."],"exampleFix":"// before\nawait api.post(`/v1/livechat/triggers/${HARDCODED_ID}/external-service/call`, { token, extraData });\n\n// after\nconst { triggers } = await api.get('/v1/livechat/triggers', { params: { count: 0 } });\nconst t = triggers.find((x) => x.name === 'My trigger');\nif (t) await api.post(`/v1/livechat/triggers/${t._id}/external-service/call`, { token, extraData });","handlingStrategy":"validation","validationCode":"const { triggers } = await api.get('/v1/livechat/triggers', { params: { count: 0 } });\nconst trigger = triggers.find((t) => t._id === triggerId);\nif (!trigger) throw new Error(`Trigger ${triggerId} no longer exists`);\nawait api.post(`/v1/livechat/triggers/${trigger._id}/external-service/call`, body);","typeGuard":null,"tryCatchPattern":"try {\n  await api.post(`/v1/livechat/triggers/${triggerId}/external-service/call`, body);\n} catch (e) {\n  if (e?.response?.data?.error === 'Invalid trigger') {\n    // resolve the current trigger id and update your integration\n  } else throw e;\n}","preventionTips":["Never hard-code trigger ids in widgets; resolve them dynamically.","After deleting/recreating triggers, invalidate client-side caches of trigger ids.","Remember this call route is public: stale ids surface to visitors, not admins."],"tags":["omnichannel","livechat-triggers","external-service","not-found","public-api"],"backgroundTag":"resource-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}