← library
prompt🪄 Automation & scriptingv2 · updated 2026-06-12

Scheduled automation & webhooks

Cron + queue + webhook glue that's idempotent and observable.

Run it as a prompt

Paste this into any AI agent, or fetch it: curl -s https://uplift.page/api/v1/prompts/automation-jobs/raw

prompt.md
# Scheduled automation & webhooks

Automate recurring work (syncs, reports, notifications) so it retries itself, never double-fires, and tells you when it's stuck.

## Recommended stack

- **Supabase Cron + Queues (pgmq) or Inngest** - scheduling. Cron in the database (or durable functions) beats a forgotten VM crontab.
- **TypeScript** - jobs. Shared types between producer and consumer stop payload drift.
- **A dead-letter table + Slack/email alert** - failure path. Jobs that fail silently are jobs that don't exist.

## Build steps

1. Make every job a pure function of (config, window): re-running yesterday's job must be safe.
2. Key side effects on an idempotency id (event id, date+entity) checked before acting.
3. Verify webhook signatures; queue the payload and return 200 fast - process async.
4. Record every run (started, finished, count, error) in a runs table; alert on missed schedules.
5. Backoff with jitter on retries; park poison messages in the dead-letter table after N attempts.

## Watch out for

- Doing work inside the webhook request handler - timeouts become data loss.
- Retries without idempotency keys (double emails, double charges).
- Alerting only on failure, not on absence-of-success.

## Definition of done

- Killing a job mid-run and re-running produces correct results
- A failed webhook replays from the dead-letter table with one command
- Missed schedule pages someone within 15 minutes

The full prompt

Automate recurring work (syncs, reports, notifications) so it retries itself, never double-fires, and tells you when it's stuck.

Recommended stack

  • Supabase Cron + Queues (pgmq) or Inngest - scheduling. Cron in the database (or durable functions) beats a forgotten VM crontab.
  • TypeScript - jobs. Shared types between producer and consumer stop payload drift.
  • A dead-letter table + Slack/email alert - failure path. Jobs that fail silently are jobs that don't exist.

Build steps

  1. Make every job a pure function of (config, window): re-running yesterday's job must be safe.
  2. Key side effects on an idempotency id (event id, date+entity) checked before acting.
  3. Verify webhook signatures; queue the payload and return 200 fast - process async.
  4. Record every run (started, finished, count, error) in a runs table; alert on missed schedules.
  5. Backoff with jitter on retries; park poison messages in the dead-letter table after N attempts.

Watch out for

  • Doing work inside the webhook request handler - timeouts become data loss.
  • Retries without idempotency keys (double emails, double charges).
  • Alerting only on failure, not on absence-of-success.

Definition of done

  • Killing a job mid-run and re-running produces correct results
  • A failed webhook replays from the dead-letter table with one command
  • Missed schedule pages someone within 15 minutes

Served from the uplift.page library and refreshed within 5 minutes of every update.