Skip to content

Documentation

Automations & Agentic Workflows — Event-Driven CMS Triggers & Webhooks

Build event-driven automations in SveltyCMS: webhook actions, conditional triggers, scheduled cron jobs, and agentic AI background tasks.

11/1/2026
7 min read Edit on GitHub

SveltyCMS includes a visual Automation Builder for creating event-driven workflows — no custom code required. Automations extend the existing Webhook System by adding multiple operation types, conditional logic, and a step-by-step editor GUI.

Tip

Enterprise Use Cases: Send email notifications on publish, call external APIs on content changes, auto-set fields for editorial workflows, log audit events, and chain conditions together.


Key Concepts

Triggers

Every automation starts with a trigger — the event or condition that starts the flow.

Trigger Type Description Example
Event Hook Fires when a CMS event occurs entry:publish, media:upload
Schedule Fires at specific times (cron) 0 9 * * 1-5 (weekdays at 9 AM)
Manual Fires only via the UI or API One-off data migrations

Available Events

Event Category Description
entry:create Content New entry created
entry:update Content Existing entry modified
entry:delete Content Entry deleted
entry:publish Content Entry published
entry:unpublish Content Entry unpublished
media:upload Media File uploaded
media:delete Media File removed

Operations

Operations are the actions that execute when a trigger fires. They run sequentially as a chain.

Operation Icon Description
Send Webhook mdi:webhook Durable queued delivery with HMAC-SHA256 signing
Send Email mdi:email-outline HTML email with token-based dynamic content
Log Message mdi:text-box-outline Write to the server log at info/warn/error level
Set Field mdi:form-textbox Modify an entry field value (e.g., set reviewed = true)
Condition mdi:filter-outline Gate downstream operations (equals, contains, exists)
Agentic Task mdi:robot Trigger a background task on mcp.sveltycms.com

Token System

All text fields in operations support token placeholders for dynamic values:

{{ entry.title }}         → Entry title
{{ entry.status }}        → Entry status
{{ entry.author }}        → Author name
{{ entry.<field_name> }}  → Any entry field

{{ trigger.event }}       → Event name (e.g. "entry:publish")
{{ trigger.collection }}  → Collection name
{{ trigger.timestamp }}   → ISO timestamp

{{ user.email }}          → Current user email
{{ user.username }}       → Current username
{{ system.now }}          → Current date/time

Using the Automation Builder

Step 1: Trigger Configuration

Navigate to Config → Automations and click New Automation.

Note

New automations open with a How automations work panel and per-step guidance. Next stays disabled until the step is valid — a name plus at least one event (or a cron expression) on step 1, and at least one operation on step 2 — and the missing requirement is spelled out below the editor.

  • Enter a descriptive name (e.g., “Notify editors on publish”)
  • Select the trigger type (Event Hook, Schedule, or Manual)
  • For event triggers, check the specific events you want to react to
  • Toggle Active to control whether the automation fires

Step 2: Operation Chain

Build your operation chain by clicking operation cards:

  1. Send Email — Set recipient, subject, and HTML body with tokens
  2. Send Webhook — Configure URL, method, body template, and signing secret
  3. Condition — Gate the chain (e.g., only proceed if status === 'publish')
  4. Set Field — Modify entry data (e.g., reviewed_by = {{ user.username }})
  5. Log Message — Record events at your chosen severity level

Operations execute in order. Reorder them using the up/down arrows, or remove them with the ✕ button.

Step 3: Preview & Test

Review your complete flow summary and run a test execution with a mock payload. The test result shows per-operation status, duration, and any errors.

Warning

A test executes the configured operations for real — webhooks are sent and emails are queued. Point test flows at a safe endpoint or temporarily disable the flow. New automations must be created before they can be tested.


API Reference

All endpoints require admin authentication.

List All Automations

GET /api/automations

Response:

{
  "success": true,
  "data": [{ "id": "...", "name": "...", "active": true, ... }]
}

Create Automation

POST /api/automations
Content-Type: application/json

{
  "name": "Email on Publish",
  "active": true,
  "trigger": {
    "type": "event",
    "events": ["entry:publish"]
  },
  "operations": [
    {
      "type": "email",
      "config": {
        "to": "editors@example.com",
        "subject": "Published: {{ entry.title }}",
        "body": "<p>{{ entry.title }} was published by {{ user.username }}.</p>"
      }
    }
  ]
}

Update Automation

PATCH /api/automations/:id
Content-Type: application/json

{ "active": false }

Delete Automation

DELETE /api/automations/:id

Test Automation

POST /api/automations/:id/test

Response:

{
  "success": true,
  "data": {
    "status": "success",
    "duration": 42,
    "operationResults": [{ "type": "email", "status": "success", "duration": 35 }]
  }
}

Architecture

The Automation System uses a decoupled, event-driven architecture to ensure minimal impact on core CMS performance.

Logic Flow

graph TD
    A["CMS Event (CRUD)"] --> B["EventBus (Singleton)"]
    B -->|Emit| C["AutomationService"]
    C --> D{"Evaluate Active Flows"}
    D -->|Match| E["Execution Engine"]
    E --> F["Operation Chain"]

    subgraph Operations
        F1["Set Field"]
        F2["Condition Checker"]
        F3["Email Dispatcher"]
        F4["Webhook Client"]
        F5["Logger"]
    end

    F --> F1 & F2 & F3 & F4 & F5

Webhook deliveries are durable jobs

A webhook operation does not call fetch inline. It enqueues a webhook-delivery job (the same job type as /config/webhooks) with the rendered body, method, custom headers and HMAC secret, so:

  • retry, backoff and the dead-letter path are shared with admin-configured webhooks;
  • every attempt appears in Config → Webhooks → Delivery logs as Automation: <flow name>;
  • the operation reports success once the job is enqueued. A failed HTTP attempt is visible in the logs (and retryable) instead of aborting the remaining operations.

Why two event buses

src/services/background/automation/event-bus.ts is deliberately separate from @utils/event-bus:

  • @utils/event-bus is the SSE/multi-instance backplane. Every emission also reaches its * wildcard, which /api/content/events forwards to browser clients.
  • The automation bus carries typed AutomationEvent payloads — which can include entry data — to flow executors only. Routing them through the shared bus would expose them to every SSE subscriber and change the wildcard payload contract.
  • Both are process singletons and server-only. Merge them only together with a dedicated non-SSE channel.

Sequence of Execution

sequenceDiagram
    participant DB as User/Database
    participant EB as EventBus
    participant AS as AutomationService
    participant OP as Operation Chain

    DB->>EB: emit('entry:publish', data)
    EB->>AS: trigger(event, data)
    AS->>AS: find matching flows
    AS->>OP: executeChain(flow.operations)
    loop For each operation
        OP->>OP: resolveTokens(config)
        OP->>OP: execute()
        Note over OP: Log success/failure
    end
    AS-->>DB: Execution complete (async)

Key Files

File Purpose
src/services/background/automation/types.ts Type definitions, event/operation metadata
src/services/background/automation/event-bus.ts Typed automation bus (deliberately not the SSE bus)
src/services/background/webhook-service.ts Webhook CRUD, queue dispatch and delivery logs
src/services/background/jobs/webhook-jobs.ts HMAC signing, egress-guarded delivery, retry classification
src/services/background/automation/automation-service.ts CRUD + execution engine
src/routes/api/[...path]/handlers/system.ts REST API endpoints (handleAutomationRoutes)
src/routes/(app)/config/automations/ GUI pages (list + editor)

Maintenance

Background repair — the watchdog and cache compaction — and the trash lifecycle are documented in Autonomous maintenance.

Related

automationsworkflowseventsenterprisemaintenancewatchdogself-healingwebhooksagentic-taskscron-jobsevent-driven-cms
Was this page helpful?