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 for trigger, action, and aiAgent queues.

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

  1. Enable and start the automations service, create a trigger-action flow, and confirm an Execution appears.
  2. Create an approval request, approve and reject with different users, and confirm the lock behavior.
  3. Stop the automations service and confirm scheduled triggers queue rather than execute.

Source references

Was this helpful?