All jobs

How Does Café Software Turn Each Shop's Weekly Stock Count in Google Sheets Into Draft Supplier Orders?

Ordering software for independent cafés makes one agent per café that reads its stock-count sheet in Google Drive each week and drafts an order per supplier.

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

What the agent does

This is for a software company that sells ordering and supplier management to independent coffee shops. Most of its customers already count stock every Sunday night in a Google Sheet they have kept for years: beans, milk, oat milk, cups and lids, pastries from the bakery, with a par level beside each line. Monday morning the owner turns that sheet into four or five orders, one per supplier, rounding to case sizes and forgetting something about once a month. The software's new feature reads the café's own sheet and has the orders drafted by the time the owner opens the app.

The company saves the agent once as a template with POST /o/{org}/agents, "connections": ["google-drive"] (it connects a Google account of its own first) and instructions that keep it to reading. When a café owner turns the feature on, the backend makes their agent with {"template": "<template id>", "name": "orders-<cafe id>"}, calls POST /o/{org}/agents/{agent}/connections {"type": "app", "name": "google-drive"}, and opens the authorize_url in a popup, where the owner signs in to Google. Rush's Google Drive product asks Google for drive.readonly, drive.file and spreadsheets; the agent reads with the first and the last, and the instructions forbid creating, editing or sharing any file.

On a run the agent finds the sheet: by the spreadsheet id the app saved when the owner picked it, or, the first time, with Drive's files.list and a q for a spreadsheet named Stock count. It reads the count tab and the suppliers tab with the Sheets API's spreadsheets.values.get, using the A1 ranges the app sends, so a café that added a column last month is read by its headers and not by position. For each line it takes par minus on hand, rounds up to the supplier's case size from the suppliers tab, and skips anything at or above par.

Lines with a blank count are not ordered. They go in a Not counted list, because a blank usually means nobody counted that shelf, not that it is empty, and ordering a full case of oat milk on a guess is how a café ends up throwing it away. Lines whose supplier is missing from the suppliers tab go in their own list. The drafts stay drafts: the app shows them, the owner edits quantities, and the app sends nothing to any supplier until the owner presses Send.

Start it with one API call

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

{
  "agent": "<agent id>",
  "input": "Draft this week's supplier orders from my stock count. Spreadsheet id 1Fq8cExampleSheetId. Read Count!A1:F300 and Suppliers!A1:D50 with spreadsheets.values.get. Count columns by header: Item, Supplier, Unit, Par, On hand, Count date. Suppliers columns: Supplier, Email, Case size unit, Order day. For each item with On hand below Par, order Par minus On hand rounded up to the item's case size. Skip items at or above Par. Items with a blank On hand go to not_counted, not to an order; items whose Supplier is not in Suppliers go to unknown_supplier. Use only rows whose Count date is 2026-11-15 or 2026-11-16, and list older rows in stale. Return only JSON {orders: [{supplier, email, lines: [{item, unit, on_hand, par, order_qty}]}], not_counted: [item], unknown_supplier: [item], stale: [{item, count_date}]}. If a header named here is missing, stop and name it instead of guessing. Read only: do not edit, create or share any file."
}
  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

The session's answer is the JSON, which the app's webhook handler turns into one draft order per supplier on the café's Orders screen, each line showing the count and the par it came from. The lists of items not counted, items with no known supplier and rows with an old count date sit above the drafts, because those are what the owner has to answer before anything is sent.

What the owner checks before pressing Send: the not-counted items (walk to the shelf, or type a number), any quantity that looks wrong for the week ahead, such as a holiday or a catering order the sheet does not know about, and that a supplier's case size has not changed. The app sends each order by the supplier's email or portal only after that, and keeps the draft and the sent version side by side.

Run it on every Monday morning, per café

The app's scheduler sends one POST /o/{org}/sessions per café with the feature on at 06:00 on Monday in the café's time zone, with its agent id as agent, the sheet id and ranges in input, and a request_id that is a UUID v5 of the café id and the week, so a retried job starts no second run. Every café's run starts at once and those past the key's max_concurrent wait as queued.

A café that counts twice a week, or finishes the count late, can press Draft now in the app, which sends the same request with that day's dates.

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

Why run it on Rush?

Each café's Google sign-in is the owner's, held in Rush's connection under their own agent. The company registers no Google app and stores no Google token, and one café's agent can never open another café's Drive. A session's accounts names the Google account it read, which the company can show an owner who asks what read their files.

Each Monday is one session per café on its own computer, with a record of every Drive and Sheets call and what its model calls cost. The company totals those per café with GET /o/{org}/sessions?agent=<agent id> and sees what the feature costs beside the subscription it sells, café by café.

Frequently asked questions

Why does the sign-in ask for more than reading?

Rush's Google Drive product asks for drive.readonly, drive.file and spreadsheets together, so one connection can serve jobs that create a sheet. Google's reference accepts drive.readonly for reading a range, and this template's instructions forbid editing any file; the transcript records each call.

What if the owner renames a column?

The agent reads columns by their header row, so a moved column still works. A renamed header the prompt does not know stops the run with a note naming the missing column, and the app asks the owner to map it once.

Does it place the orders?

No. It drafts them, and the café owner sends each one from the app after checking it. An order sent on a miscount costs the café money and waste, so the person who counted the shelf stays the person who sends.

Can it learn the right par levels?

Not in this job. It uses the par levels the owner keeps in the sheet. A café that wants suggestions could have a separate monthly run compare past counts with past orders, and the owner would decide whether to change the sheet.

More Google Drive jobs

More jobs like this: Run an agent per customer task

Keep reading