All jobs

Find Personal-Training Clients With No Next Session Booked in Each Trainer's Google Calendar

Software for personal trainers makes one agent per trainer that reads their Google Calendar each week and lists regular clients with no session booked ahead.

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

What the agent does

This is for a company that sells client-management software to independent personal trainers and small training studios. Most trainers book sessions straight into their own Google Calendar, one event per session with the client invited or named in the title, and the client who quietly stops booking is the one who never comes back. The company saves one agent as a template whose connections name google-calendar, and makes one agent from it for each trainer who turns on the weekly check, keeping the agent id against the trainer's account.

Each trainer connects their calendar once. The software's backend calls POST /o/{org}/agents/{agent}/connections {"type": "app", "name": "google-calendar"} and opens the authorize_url in a popup; the trainer signs in on Google's page, which names Rush as the app asking, and Rush asks only for the Calendar product's permissions, calendar.readonly and calendar.events. The software company registers no Google app, and the token is used from outside the agent's computer.

On a run, the agent calls the Google Calendar API's events.list on the trainer's primary calendar twice: once for the last six weeks and once for the next two, each with timeMin, timeMax, singleEvents=true so repeating sessions come back as single dates, and orderBy=startTime. It skips events whose status is cancelled. It decides who each session was with from the attendees email addresses, and from the event summary when the trainer writes "PT – Jordan K." instead of inviting anyone, matching names against the client list the software sends in the input.

A client counts as regular when they had at least the number of sessions in the input during the six weeks. For each regular client with nothing booked in the next two weeks, the agent returns their name, the date of their last session, how many sessions they had in the period, the weekday and time they usually came, and a two-sentence message the trainer could send, offering that usual slot when it is free in the next two weeks. It creates no event and invites no one.

Start it with one API call

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

{
  "agent": "<agent id>",
  "input": "Read the primary Google Calendar. Past window: 2026-10-03 to 2026-11-14. Next window: 2026-11-14 to 2026-11-28. Use events.list with singleEvents=true and skip cancelled events. Clients (name, email): Jordan Kim, jordan.k@example.com; Priya Shah, priya.shah@example.com; Leo Martins, leo.m@example.com; Ava Brooks, ava.b@example.com. Match each session to a client by attendee email, else by the client's name in the event title. A regular client had 4 or more sessions in the past window. For each regular client with no session in the next window, return name, last_session, sessions_in_past_window, usual_slot (weekday and time), a free_slot in the next window at their usual time if the calendar is free then, and a two-sentence friendly message offering that slot. Return only JSON: {clients: [...], unmatched_events: [event titles]}. Do not create, change or delete any event."
}
  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, with your repository as the resources URL. 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 answer is JSON in the session's result and in the run.completed webhook. The software shows the trainer a short list on Monday: who has slipped, when they last came, and a message ready to edit and send from the software's own messaging. The trainer decides who to contact and what to say; the agent sends nothing and books nothing.

What the trainer checks: clients who are away on purpose, such as an injury or a holiday, whom they simply skip; the free_slot, against bookings the trainer keeps outside Google Calendar; and unmatched_events, sessions the agent could not tie to a client because the title used a nickname. Adding that nickname to the client's record in the software fixes it for the next run.

Run it on every Monday, per trainer

The software's scheduler sends one POST /o/{org}/sessions per connected trainer on Monday morning in the trainer's own timezone, with that trainer's agent id, the two windows and the client list in input, and a request_id that is a UUID v5 of the trainer's id and the date, so a retried job never starts the same check twice.

Runs past the key's concurrent limit are created queued and start, oldest first, as earlier runs finish, so a large Monday batch needs no retry loop. The key's webhook delivers each answer; the handler checks the signature and files the list under the trainer it saved with the execution_id.

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

Why run it on Rush?

Trainers do not write calendar events the same way: one invites every client, another types initials in the title, a third books pairs into one event. A query over the Calendar API counts events; it cannot tell that "PT JK" is Jordan Kim. The agent reads the events against the client list and says which ones it could not place, so the trainer sees the gaps rather than a wrong count.

Each trainer's calendar holds their clients' names and habits, so it belongs to that trainer's own agent: its runs read that calendar only, and the software company's own runs never see it. One template serves every trainer, a PATCH to it changes the rules for all of them at once, and GET /o/{org}/sessions?agent=<agent id> lists one trainer's runs with what each cost.

Frequently asked questions

Can the agent book the session for the client?

The Calendar scopes would allow creating an event, but the prompt forbids it. Booking stays with the trainer, who sends the message and books the slot once the client says yes.

What if the trainer keeps personal events in the same calendar?

Events that match no client are ignored for the count and listed by title in unmatched_events only when they look like sessions. The client list is what keeps a dentist appointment out of the results.

Does the client ever see Rush?

No. Only the trainer signs in, to Google. The message goes out from the software, if the trainer sends it.

What if a trainer revokes Google access?

Their agent's connection reads needs_reauth, and its runs cannot read the calendar until the trainer connects again with the same sign-in call. The software can show a reconnect button when it sees that status.

More Google Calendar jobs

More jobs like this: Run an agent per customer task

Keep reading