Rules — automate your ad management

Last updated: May 19, 2026

Rules — automate your ad management

Rules Engine = if-then automation for your ads. Wevion evaluates every active rule every 15 minutes (cron with 2-minute offset) and acts on matching campaigns / ad sets / ads via SQS workers. Companion to Ads Manager (PRD-16): Ads Manager monitors, Rules Engine acts. Use cases: pause losers automatically, scale winners, protect daily spend, get alerted on anomalies.

Who is this for

Mediabuyers who want to stop doing repetitive manual actions ("pause every campaign with CPA > X for 3 days") and instead let the platform handle the routine + focus on strategy. Especially valuable when managing 10+ active campaigns where manual scanning every morning becomes a bottleneck.

What a rule is

A rule has 5 parts:

  1. Scope — which ad accounts + which entity level (campaign / adset / ad) + entity filter (name contains, status)

  2. Conditions — one or more {metric, operator, value, time_range} combined with AND / OR logic

  3. Actions — what to do when conditions match (pause, activate, increase / decrease budget %, relaunch, notify only)

  4. Scheduleinterval (every N min) or daily_at_time (extensions)

  5. Protections — cooldown, max executions per day, budget change caps

Status is one of paused / active / error. New rules start paused — toggle to active when ready.

How evaluation works

Wevion runs a cron job in apps/backend/src/server.ts every 15 minutes (with a 2-minute offset). Each tick:

  1. Cron selects rules where status = active AND last_evaluated_at < 15 min ago

  2. Updates last_evaluated_at first (prevents duplicate enqueue if a tick overlaps)

  3. Enqueues message to SYNC SQS queue (50 max in-flight, 15-min visibility timeout, 20 max attempts)

  4. evaluate-rules.worker.ts fetches latest metrics + checks conditions

  5. For matching entities: enqueues to execute-rule-action.worker.ts

  6. Worker performs the action on the platform (Meta / Google / TikTok / etc.)

  7. Records execution in automation_rule_execution table + audit log

Reality check: "every 15 min" is the minimum cadence. Sub-15-min evaluation is not supported by design — protects against runaway loops + respects platform rate limits.

Use cases

Pause losers

IF cpa > 30 AND spend > 50 FOR last_7d
THEN pause adset
COOLDOWN 360 min

Kills underperforming ad sets without you logging in every morning.

Scale winners

IF roas > 3 AND spend > 100 FOR last_3d
THEN increase_budget_pct 20
COOLDOWN 720 min, MAX 3/day

Scales winners by 20% up to 3 times per day, then waits the cooldown.

Protect daily spend

IF budget_spent_pct > 80 FOR today
THEN notify_only

Alerts you when 80% of daily budget consumed — manual decision on extra budget.

Frequency cap

IF frequency > 5 FOR last_7d
THEN pause adset

Prevents creative fatigue auto-burning audiences.

Where it lives in the app

Route /rules. Sidebar entry Rules. Pages:

  • List (/rules) — all rules with status + last execution + next fire time

  • Builder (/rules/new, /rules/:id/edit) — create / edit

  • Detail (/rules/:id) — execution history + metrics snapshots

  • Templates (/rules/templates) — pre-built rules to fork

Cross-platform rules

Cross-platform rules (rules that span Meta + Google + TikTok + LinkedIn + Taboola in one rule) sit behind the ENABLE_CROSS_PLATFORM_RULES feature flag. 7 metrics supported (spend, spend_pct, impressions, clicks, ctr, cpc, cpm, purchases, purchase_value, roas, cpa) with 5 operators. See rul-117 extensions.

What you'll see

In /rules:

  • Table: rule name, status badge, entity level, schedule, last fired, execution count

  • Per-row actions: Edit, Pause / Resume, Duplicate, Delete, View executions

  • Top toolbar: New rule, From template, Bulk actions

In execution history:

  • Timeline of fires with entity counts (evaluated / matched / acted / skipped / errored)

  • Per-entity result with before / after values + metric snapshot

Key concepts to learn next

Best practices

Start narrow

First rule: target ONE ad account, ONE entity level, ONE condition. Watch execution history for a week. Then expand scope.

Preview before activating

Every new rule: use preview / dry-run to see what would have matched. Avoids surprises on first fire.

Use notify_only when learning

For rules you're unsure about (new metric, new threshold): start with notify_only action. Validate matches are correct over 1-2 weeks. Then switch to actual action (pause / scale).

Conservative cooldowns

For destructive actions (pause, decrease_budget_pct): cooldown ≥ 360 min default. Prevents thrashing on noisy metrics.

Related