# Where Are the Gaps in My Book Next Week? A Salon App Finds Each Stylist's Open Slots From Their Google Calendar

A salon booking app makes one agent per stylist, signed into their Google Calendar, that finds next week's open slots and drafts a waitlist message.

[Run this on Rush](https://cloud.getrush.ai/run/find-open-slots-to-fill-next-week/google-calendar/). Opens the console with this prompt ready to send. Connect Google Calendar there first.

## What the agent does

This is for a company that sells booking and client-messaging software to independent stylists, barbers and nail technicians, many of whom rent a chair or a suite and keep their own appointments in Google Calendar, synced from whichever booking page they use. Every Friday they look at next week, find the gaps, and text a few regular clients or post that they have openings. The software company adds that to its app: each stylist's agent reads their calendar's busy times, finds the gaps long enough for a service they offer, and drafts the message. The company saves one agent as a template that names Google Calendar and makes one agent from it per stylist.

The company connects a Google Calendar of its own first, because a template names connections its creator has, and saves the template with `"connections": ["google-calendar"]`. When a stylist turns the feature on, the backend calls `POST /o/{org}/agents {"template": "<template id>", "name": "gaps-<stylist id>"}`, then `POST /o/{org}/agents/{agent}/connections {"type": "app", "name": "google-calendar"}`, and opens the `authorize_url` in a popup for that stylist, who signs in on Google's own page. Rush asks Google for that product's scopes only, `calendar.readonly` and `calendar.events`, and the template's instructions keep the agent to reading.

On a run the agent calls Google Calendar's `freeBusy` query, `POST https://www.googleapis.com/calendar/v3/freeBusy`, with `timeMin` and `timeMax` covering next week, `timeZone` set to the stylist's, and the primary calendar in `items`. Google's reference says the query accepts the `calendar.readonly` scope and returns each calendar's `busy` periods with a start and an end, so the agent learns when the stylist is booked without reading who the appointments are with. It subtracts the busy periods from the working hours the app sends in the prompt, keeps gaps at least as long as the stylist's shortest service plus the buffer they set, and rounds each gap's start to the quarter hour.

It returns the open slots by day and drafts one short message in the stylist's voice, from the sample messages the app keeps for them: the days and times available, which services fit each slot, and how to book. It sends nothing and creates no event. The stylist reads the draft in the app, edits it, and chooses whether to text their waitlist or post it, and the app's own messaging sends it.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "<agent id>",
  "input": "Find open slots in my Google Calendar for next week, 2026-11-23 to 2026-11-29, timezone America/Chicago. Call the freeBusy query with timeMin 2026-11-23T00:00:00-06:00, timeMax 2026-11-30T00:00:00-06:00, timeZone America/Chicago and items [{id: primary}]. Working hours: Tue to Fri 10:00 to 19:00, Sat 09:00 to 16:00; closed Sun and Mon. Services and lengths: trim 45 min, color 120 min, cut and color 150 min. Buffer 15 min after each booking. Keep gaps at least 60 min long (shortest service plus buffer), starting on a quarter hour. Draft one message under 60 words in the voice of these samples: 'Hey! Had a couple spots open up this week, grab one before they go.' and 'Openings Thu and Sat, book on my page.' Return only JSON: {slots: [{day, start, end, fits: [service]}], draft_message}. Read busy times only; do not list, create, update 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 app shows the slots on a week view and the draft message under it. The stylist edits the message, picks which slots to offer, and sends it to their waitlist or copies it to a post. Nothing goes to a client until the stylist sends it.

What the stylist checks: that the calendar the agent read is the one their booking page writes to (a stylist who books into a second calendar shows as wide open), personal plans that never made it into the calendar, and that the message offers only the services they want to fill those slots with. A slot the agent offers is a gap in the calendar, not a promise the stylist is free.

## Run it on every Friday afternoon

The app's scheduler sends one `POST /o/{org}/sessions` per stylist with the feature on, Friday at 3 p.m. in each stylist's time zone, with their agent id as `agent`, next week's dates, hours and services in `input`, and a `request_id` that is a UUID v5 of the stylist id and the week. Every stylist's run starts at once, and a retried job starts no second run.

A stylist who gets a cancellation midweek can press Find gaps again, which starts the same request for the rest of the week from that moment.

## Why run it on Rush?

Each stylist signs in to Google on Google's page and that sign-in belongs to their own agent: the software company registers no Google app, holds no Google token, and one stylist's run can read only that stylist's calendar. Each session lists the Google account it acted as in `accounts`, so the company can answer a stylist who asks which runs read their calendar.

One template serves every stylist; when the app adds a rule, such as never offering a slot that starts in the last hour of the day, one `PATCH` to the template reaches every next run. Each run has its own computer and a record of each call and what its model calls cost, and `GET /o/{org}/sessions?agent=<agent id>` lists a stylist's runs with their `total_cost_usd`.

## Frequently asked questions

### Does the agent see who my appointments are with?

Not with this prompt. Google's free/busy query returns only the start and end of busy periods, not titles or attendees, and the prompt forbids listing events. Rush's Google Calendar sign-in could read events, which is why the instructions say exactly which call to make.

### Can it book the client into the slot?

Rush's Google Calendar sign-in includes `calendar.events`, so it could create an event, but this agent does not: booking stays in the stylist's booking page, which already handles deposits and reminders. The agent finds the gaps and drafts the message.

### What if a stylist keeps appointments in more than one calendar?

Google's free/busy query takes a list of calendars in `items`, so the app can send every calendar the stylist books into, and the busy periods of all of them are subtracted together.

### Does the stylist need a Rush account?

No. They sign in to Google from the booking app. The agents, their runs and their cost belong to the person who created the software company's API key.

## More Google Calendar jobs

- [Prepare a Brief for Every External Meeting on Each Sales Rep's Google Calendar](https://getrush.ai/run/prepare-meeting-briefs/google-calendar/)
- [Total Each Consultant's Billable Meeting Hours by Client From Google Calendar](https://getrush.ai/run/total-billable-hours-by-client/google-calendar/)
- [Find Personal-Training Clients With No Next Session Booked in Each Trainer's Google Calendar](https://getrush.ai/run/find-clients-without-a-next-session/google-calendar/)

## More jobs like this: Run an agent per customer task

- [Which Orders Are Stuck Between Paid and Shipped? A Back-Office App's Morning Check of Each Marketplace's PlanetScale Database](https://getrush.ai/run/find-orders-stuck-between-paid-and-shipped/planetscale/)
- [Flag Subcontractors' Expiring Insurance Certificates in Each Contractor's OneDrive](https://getrush.ai/run/flag-expiring-insurance-certificates/onedrive/)
- [Flag Products in Each Online Store's Airtable Catalog That Are Not Ready to List](https://getrush.ai/run/flag-incomplete-product-listings/airtable/)

## Keep reading

- [Connect Google Calendar to Rush once, then name it on any run](https://getrush.ai/integrations/google-calendar/)
- [Start your first run from the developer API quickstart](https://getrush.ai/docs/quickstart/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
