Automations Engine
Automations in BeechCMS allow you to trigger automated workflows—such as sending transactional emails, dispatching webhooks, updating fields, or generating new records—based on content lifecycle events (create, update, delete) or recurring schedules (cron).
Automations are scoped per Seed and configured visually in the dashboard: open any content collection from the sidebar (e.g. Articoli, Customers) and click the Automations button in the top toolbar to open the lateral automations panel.
Architecture & Triggers
An automation rule consists of three building blocks:
- Trigger: The event that initiates the workflow.
- Lifecycle Events:
create,update, ordeleteon any specified Seed. - Schedule (
cron): Recurring time intervals (e.g. daily summaries, weekly cleanups), written as a standard five-field cron expression evaluated in UTC. An expression that cannot fire is rejected when the automation is saved.
- Lifecycle Events:
- Conditions: Optional logical rules (e.g.
status == 'published',priority == 'high') that must evaluate to true for execution to proceed. - Actions: A sequential pipeline of operations executed in exact order.
Supported Actions
BeechCMS provides five core action types:
| Action | Function | Example Use Case |
|---|---|---|
send_mail | Sends transactional HTML emails via Resend | Send confirmation emails on new contact form submissions |
webhook | Dispatches secure HTTP requests to external APIs | Notify Slack, Discord, Zapier, or n8n of new publications |
edit_field | Updates field values on an existing Fruit | Auto-assign tickets or increment view counters |
create_entry | Spawns a new Fruit in any Seed | Generate an audit record or welcome ticket |
set_variable | Preloads data from other Seeds for use in later actions | Fetch author details or calculate category aggregates |
Variables & Templating
Actions execute sequentially. You can interpolate data from the triggering item (this) or from declared variables using the double-brace syntax \{\{this.field\}\}.
Single Record Mode
Declare a variable with a fixed_id (either a literal ID or an interpolated value like \{\{this.author_id\}\}):
\{\{author\}\}: The entire object (ornullif not found).\{\{author.name\}\}: The author's name.\{\{author.email\}\}: The author's email address.
Collection Mode & Aggregates
When fixed_id is omitted, set_variable loads up to 10,000 records from a target Seed (a larger Seed is read partially and a warning is logged), allowing powerful aggregates and navigation:
\{\{posts.count\}\}: Total count of matching items.\{\{orders.sum.total\}\}: Sum of a numeric Branch (total).\{\{orders.avg.total\}\}: Average over the records that hold a number; empty values are ignored.\{\{posts.min.publishedAt\}\}: Minimum date/value.\{\{posts.max.publishedAt\}\}: Maximum date/value.\{\{tags.pluck.name\}\}: Comma-separated list of up to 100 values.\{\{posts.firstone.title\}\}: The title of the first item in the collection.\{\{posts.lastone.id\}\}: The ID of the last item in the collection.
Inline Filtering & Selectors
You can apply inline filters directly inside template tags:
- Inline Filter:
\{\{posts.(status=published).count\}\}(counts only published items). - Date Comparison:
\{\{posts.(publishedAt>1740000000).count\}\}. - Array Selector:
\{\{posts.array[art-001,art-002].count\}\}.
Webhook Integration
Webhooks allow seamless integration with external automation platforms (n8n, Make, Zapier, or custom backends).
Payload Example
{
"event": "content.published",
"trigger": {
"title": "\{\{this:title\}\}",
"slug": "\{\{this:slug\}\}",
"status": "\{\{this:status\}\}",
"publishedAt": "\{\{this:publishedAt\}\}"
},
"collection": {
"total_articles": "\{\{articles.count\}\}",
"published_count": "\{\{articles.(status=published).count\}\}",
"all_titles": "\{\{articles.pluck.title\}\}"
},
"latest": {
"id": "\{\{articles.firstone.id\}\}",
"title": "\{\{articles.firstone.title\}\}"
}
}Security & SSRF Protection
BeechCMS enforces strict security rules on all outbound webhooks:
- HTTPS Required: Insecure
http://webhook endpoints are rejected. - SSRF Defense: Private and loopback addresses (
localhost,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16,100.64.0.0/10, and the IPv6 loopback, unique-localfc00::/7and link-localfe80::/10ranges) are blocked to prevent attacks against cloud infrastructure. IPv6 forms that wrap an IPv4 address (IPv4-mapped::ffff:, NAT6464:ff9b::, 6to42002::) are checked against the IPv4 address they carry. - Checked again at delivery: The URL is validated when the automation is saved and again right before each request is sent (the delivery check is skipped only when
ENV=development, so local webhook sinks keep working). Redirect responses are not followed and count as a failed delivery. - Hostnames are not resolved: The check applies to the address written in the URL. A public hostname whose DNS record points at an internal address is not detected by BeechCMS itself.
HMAC Signature Verification
Every outgoing webhook includes the header X-BeechCMS-Signature: sha256=<hex> when WEBHOOK_SECRET is configured in your Worker.
Set the secret in production:
npx wrangler secret put WEBHOOK_SECRET --env productionVerification Example (Node.js)
import { createHmac } from 'node:crypto'
export function verifyWebhookSignature(body: string, signature: string, secret: string): boolean {
const expected = 'sha256=' + createHmac('sha256', secret).update(body).digest('hex')
return expected === signature
}
// In your API route handler:
const rawBody = await request.text()
const signature = request.headers.get('X-BeechCMS-Signature') ?? ''
if (!verifyWebhookSignature(rawBody, signature, process.env.WEBHOOK_SECRET!)) {
return new Response('Invalid signature', { status: 403 })
}Email Delivery
When using the send_mail action, BeechCMS uses Resend by default to dispatch transactional emails with zero latency.
- Ensure
RESEND_API_KEYis configured in your environment. - In the automation builder, configure To, Subject, and Body using dynamic template placeholders (e.g.
Hello \{\{this.name\}\}, thank you for your inquiry!). - Emails are dispatched asynchronously with automatic retries.
Custom Email Providers
While Resend is configured as the default delivery engine, BeechCMS uses a modular EmailProvider architecture. You can easily connect SMTP (such as Mailpit in local development), SendGrid, Postmark, Mailgun, or any custom provider. Learn how in the Email Module Guide.