All jobs

Which of Our Customers' Accounts Stopped Using the Product This Week? A Customer-Success App's Weekly Check of Each Customer's PostHog

A customer-success software company makes one agent per customer, signed into that customer's PostHog, that lists accounts whose weekly active users fell sharply.

Run this on RushOpens the console with this prompt ready to send. Connect PostHog there first.

What the agent does

This is for a company that sells customer-success software to small business-software companies: an app where an account manager sees each of their customers' accounts, renewal dates and notes. Its own customers already send product events to PostHog, and what their account managers most want to know each Monday is which accounts went quiet: the logistics firm whose forty users dropped to six, the clinic group that stopped opening reports. The app adds a Monday list of those accounts for each customer, read from that customer's own PostHog. Each customer signs in to PostHog themselves; the app never holds a PostHog key.

The company connects a PostHog project of its own, then saves the agent once as a template with POST /o/{org}/agents, naming posthog in connections and instructions that allow reading only. When a customer turns the list on, the app's backend calls POST /o/{org}/agents {"template": "<template id>", "name": "usage-drop-<customer id>"}, stores the agent id against the customer, and calls POST /o/{org}/agents/{agent}/connections {"type": "mcp", "name": "posthog"}. It opens the authorize_url in a popup while the customer's admin is signed in to the app. PostHog's docs say the consent screen lets that person choose which projects the connection reaches, and calls to any other project are refused with a 403. The company registers no OAuth app of its own.

On a run the agent calls projects-get and switch-project to work in the project the customer chose in the app's setup, then read-data-schema to find the events and the property that identifies an account, which the customer also named in setup (a company group, or an organization_id property on each person). With execute-sql it counts distinct active users per account for each of the last five weeks, where active means any event other than the page views and identify calls the prompt excludes. An account is flagged when last week's active users fell by at least 40 percent from its average over the four weeks before, and that average was at least 5 users, so a two-person trial going quiet is not news.

For each flagged account the agent runs one more query for the features that account used most in the earlier weeks and how often each was used last week, so the list can say "stopped exporting payroll reports" instead of only giving a number. It never creates an insight, a cohort, a dashboard or a feature flag, and changes no person or property.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "<agent id>",
  "input": "Weekly usage-drop check. Last week: 2026-11-16 to 2026-11-22. Baseline: the four weeks 2026-10-19 to 2026-11-15. PostHog project: 'Production'. Account key: the group type 'company' (use read-data-schema to see how events carry it). Read only: create, edit or delete nothing in PostHog. 1) projects-get, then switch-project to 'Production'. 2) read-data-schema to confirm the account key and event names. 3) execute-sql: distinct users per account per week for the five weeks, counting all events except $pageview, $pageleave, $identify and $autocapture. 4) Flag accounts where last week's users <= 0.6 x the baseline weekly average and the baseline average >= 5. 5) For each flagged account, execute-sql for its top 5 events by count in the baseline and their counts last week. Return JSON only: {week, project, flagged: [{account_key, account_name, baseline_avg_users, last_week_users, change_pct, top_events: [{event, baseline_weekly_avg, last_week}], summary}], accounts_checked}. summary is one plain sentence, such as 'stopped exporting reports'. No user names or emails in the output."
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is the JSON in the session's result, which the run.completed webhook carries to the app's server: each flagged account with its active users before and after, the change, the features it stopped using and a one-line summary, plus how many accounts were checked. The app turns it into the Monday list on each account manager's home screen, next to the renewal date it already knows.

What the account manager checks before calling the customer: whether the drop has an ordinary reason the app cannot see, such as a holiday week in that customer's country or a team that moved to a new workspace, and whether the account's renewal is close enough to matter. The output carries no person's name or email, by the prompt's rule. The agent only reads and reports; reaching out stays with the account manager.

Run it on every Monday morning

The app's scheduler sends POST /o/{org}/sessions with {"agent": "<agent id>", "input": "…"} for each customer with the list turned on, every Monday at 5:00 in the customer's time zone, filling in last week's dates, the project and the account key from the app's own setup screen. It sends a fresh request_id, a UUID, per customer and week so a retried call does not start a second run, and matches the result to the customer by the agent id it stored.

An account manager preparing for a renewal call can press "Check this account" in the app, which starts the same agent with one account key and the last twelve weeks instead of five.

The use case this job follows, with its automation and trigger: Run an agent per customer task.

Why run it on Rush?

Each customer's PostHog sign-in is held in Rush's connection under that customer's own agent, so one customer's run never sees another's project or the company's own, and deleting a customer's agent when they leave disconnects that sign-in. The company stores agent ids, not PostHog keys.

Each run has its own computer and a record of every query it ran, so when a customer asks why an account was flagged, support opens that Monday's session and reads the SQL and its result. PostHog's docs note that its own usage billing still applies to the data queries read, so the prompt reads five weeks and no more; to bill customers for the list, the company totals each agent's total_cost_usd from GET /o/{org}/sessions?agent=<agent id>.

Frequently asked questions

What if a customer does not track accounts as a group?

The setup screen asks which property identifies an account, and a person property such as an organization id works too. If events carry neither, the agent reports that it found no account key, and the app asks the customer to add one.

Why ignore page views and autocapture?

Those events fire when someone opens a tab and leaves it, so they make a quiet account look active. Counting the events a customer's product sends on purpose shows real use.

Can the agent build a cohort of the quiet accounts in PostHog?

The template's instructions forbid writing to the customer's project. A cohort in their PostHog is the customer's to create, and the list in the app is enough for the account manager.

More PostHog jobs

More jobs like this: Run an agent per customer task

Keep reading