Automations & Approvals
Run event-driven workflows and gate sensitive actions with approvals. This guide follows version 3.1.7 (03acdf712c).
For the worker process, see Background Services.
Automations
- Core definitions:
backend/core-api/src/modules/automations/(graphql/schema/,db/models/{Automations,Executions,...}.ts,trpc/automations.ts). - Shared contracts:
backend/erxes-api-shared/src/core-modules/automations/. - Execution engine:
backend/services/automations/src/with BullMQ workers fortrigger,action, andaiAgentqueues.
An automation combines triggers, actions, and target selection. Executions records each run. Plugins contribute triggers and actions through meta/automations.ts (for example Sales and Operation register their own handlers). The automations service must be running (ENABLED_SERVICES=automations) for execution; the API alone only stores definitions.
Approvals
- Core module:
backend/core-api/src/modules/approval/(graphql/schema/,db/definitions/{approvalRequests,approvalLocks}.ts,trpc/approval.ts). - Shared guards:
backend/erxes-api-shared/src/core-modules/approval/(checkApprovalLock, zod schemas, constants).
A request tracks contentType, contentId, lockId, requesterId, status (pending|approved|rejected), requiredApproverIds, and per-user decisions[]. Locks prevent the underlying action until the decision completes. Check checkApprovalLock before implementing a new approvable operation.
Verify
- Enable and start the automations service, create a trigger-action flow, and confirm an
Executionappears. - Create an approval request, approve and reject with different users, and confirm the lock behavior.
- Stop the automations service and confirm scheduled triggers queue rather than execute.