Skip to content

Orland00/marketing-agent

Repository files navigation

Marketing Agent

AI-powered, multi-tenant social media automation on a single Cloudflare Worker. Generate on-brand posts with Claude, review and approve them from Telegram, and publish on a schedule to Meta (Facebook / Instagram) and X.

Cloudflare Workers Anthropic Supabase TypeScript

Public, sanitized snapshot. All real brand data, credentials, and account IDs have been removed; tenants are reduced to generic demo brands (demo, acme, globex). Not configured to connect to any live account.

How it works

        Claude (content)            Telegram (human approval)
              │                              │
              ▼                              ▼
   ┌──────────────────────────────────────────────────┐
   │            Cloudflare Worker (Hono)                │
   │  generate → queue → approve → schedule → publish   │
   └──────────────────────────────────────────────────┘
              │                              │
              ▼                              ▼
        Supabase (state)         Meta Graph API / X API
  1. Generate. Per-tenant brand voice, audience, and hashtags drive a Claude prompt that drafts platform-specific copy (src/lib/ai.ts).
  2. Approve. Drafts land in a queue; an operator approves, edits, or rejects them from a Telegram chat (src/telegram/handler.ts, src/routes/accept-ui.ts).
  3. Schedule & publish. A cron-driven publish queue posts approved content via platform adapters (src/adapters/meta.ts, src/adapters/twitter.ts).
  4. Measure. Engagement stats are pulled back daily for reporting (src/routes/analytics.ts, src/routes/stats-ui.ts).

Highlights

  • Multi-tenant by slug. One Worker serves many brands via /:slug routes; brand config lives in src/lib/product.ts.
  • AI operations layer with prompt registry, public eval shells, and a human-in-the-loop approval model (docs/ai/).
  • Database-backed workflow for tenants, prompts, drafts, queues, approvals, schedules, publish results, and analytics snapshots.
  • External API adapters for model providers, Telegram, Meta Graph, X, object storage, and Supabase.
  • Queue-first production shape: generation, review, publishing, retry, and reporting are separated into explicit states.
  • Adapter pattern isolates each social platform behind a common interface.
  • Human-in-the-loop publishing — nothing goes out without approval.
  • Cron dispatcher for the publish queue and daily analytics pulls.
  • R2-backed image handling for generated post media.

Layout

src/
  adapters/   per-platform publishers (meta, twitter) + registry
  lib/        ai, publisher, supabase, telegram, validation, date-parser
  routes/     posts, campaigns, pending, accept/stats UIs, analytics, images
  telegram/   bot command + approval handler
tests/        vitest unit tests
docs/        public architecture + AI operations shell

See docs/architecture.md for the sanitized database, API, queue, and provider integration map.

Running locally

npm install
cp .dev.vars.example .dev.vars   # fill in your own keys
npm run dev
npm test

Secrets are set with wrangler secret put in production and never committed. See .dev.vars.example for the full list.

License

Source-available for portfolio / review purposes. Not licensed for redistribution or commercial reuse.

About

AI-powered multi-tenant social media automation on Cloudflare Workers — Claude content + Telegram approvals + Meta/X publishing. (Sanitized public snapshot)

Resources

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages