Build your own Stripe revenue trend ledger with weekly email reports

By General Input

Capture yesterday's Stripe numbers into your own database every morning, then get a written week-over-week trend email each Monday.

Integrations

  • Stripe
  • General Input Database
  • Gmail

Type

Agentic Task

Categories

  • Finance
  • Operations

I want an agent workflow that grows my own revenue trend ledger out of Stripe and emails me a weekly written report off it. The trigger is a cron schedule that runs every day at 8am America/New_York.

On every run (daily job), the agent should:

1) Compute the prior calendar day in America/New_York (yesterday's 00:00 to 23:59:59 in NY time, converted to UTC unix timestamps for the Stripe filters).

2) Use the Stripe List Balance Transactions operation, filtered by created.gte / created.lte to that day, to compute yesterday's gross volume, net volume (after Stripe fees), and refund total. Paginate fully with starting_after until has_more is false so the totals are correct. Amounts are in the smallest currency unit; convert to dollars when displaying.

3) Use the Stripe List Charges operation, filtered to yesterday, to compute the new-customer charge count (count of successful charges whose customer_id was first seen yesterday). Also use Stripe List Disputes filtered to yesterday for the dispute count.

4) Upsert ONE row keyed by date into a table called daily_revenue_snapshots in my General Input Database. Columns: snapshot_date (TEXT PRIMARY KEY, ISO yyyy-mm-dd), gross_volume_cents INTEGER, net_volume_cents INTEGER, refund_total_cents INTEGER, dispute_count INTEGER, new_customer_charge_count INTEGER, currency TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP. Use INSERT ... ON CONFLICT(snapshot_date) DO UPDATE SET ... so re-runs and backfills are idempotent. Create the table on the first run if it does not exist.

Then, ONLY if the run date in America/New_York is a Monday, additionally do the weekly trend report. For the weekly report do NOT call Stripe again. Read it entirely from the daily_revenue_snapshots table:

a) Select the last 28 snapshot_date rows from daily_revenue_snapshots ordered by date descending.

b) Bucket them into last-7-days vs prior-7-days vs the 14 days before that. Compute: week-over-week delta on gross volume, net volume, refunds, and disputes (both absolute and percent); the prior week's average daily gross; and the single largest mover day in the last 7 days (the day whose gross volume deviated the most from the trailing 28-day average, with the direction).

c) Send me a written trend email via the Gmail Send a Message operation, to my own address. Subject line like "Weekly revenue trend, week of <Mon date>". Body should have a short narrative paragraph at the top in plain language explaining what changed and why it might matter, followed by clean bullet highlights for each metric and the largest-mover callout. Format the body as HTML so the bullets render nicely. Construct the RFC 2822 message and base64url-encode it for the raw field, per Gmail's send semantics.

On non-Monday days the workflow just writes the snapshot and exits silently with no email.

Important behavior notes: the General Input Database is the multi-week persistent store. Stripe is only ever called for one day at a time (yesterday). The weekly report is always served from the database, never by re-paginating Stripe. If yesterday's snapshot row already exists (e.g. manual backfill), overwrite it with the freshest numbers rather than skipping. If the database table is empty on a Monday, send a short "not enough history yet" email instead of failing.

Related prompts

Explore more prompts
Win back LiveChat visitors whose chats went unansweredLet support send one-off Loops emails without an engineerA brand asset library your marketing team actually searchesLiveKit live operations console for room moderationCustomer lifecycle inspector for Loops, Stripe and PostHogChat quality review board for LiveChat support leadsCompetitor LinkedIn ad watchlist with a permanent archiveLiveChat coverage board for planning next week's shiftsPhone routing control panel for LiveKit voice agentsA searchable RFP answer library your bid team drafts from