What the agent does
This is for a company that sells software to residential property managers. The software holds the listings: each unit, its address and whether it is available, has an application pending or is leased. The viewings themselves live in each leasing agent's own Microsoft 365 calendar, booked by phone and email. So a unit leased on Thursday still has viewings booked for Saturday, a viewing booked in a hurry has no address, and two viewings overlap across town. The company saves one agent as a template with "connections": ["microsoft-calendar"] and instructions that forbid changing any event, and makes one agent from it per leasing agent with POST /o/{org}/agents {"template": "<template id>", "name": "viewings-<user id>"}, storing the agent id on that user.
Each leasing agent connects their calendar once from the software's settings page. The company's backend calls POST /o/{org}/agents/{agent}/connections {"type": "app", "name": "microsoft-calendar"} and opens the authorize_url in a popup, where the leasing agent signs in on Microsoft's page. Rush's Microsoft Calendar app asks for Calendars.ReadWrite, its one permission. The software company registers no Microsoft app and stores no token.
On a run the agent reads Microsoft Graph's calendar view, GET /me/calendarView with startDateTime and endDateTime for the coming week in the office's offset, which returns each occurrence of a recurring event as its own entry. It sends Prefer: outlook.timezone so times come back in local time and Prefer: outlook.body-content-type="text" so event bodies come back as plain text, and follows @odata.nextLink until the week is complete. A viewing is an event whose subject starts with "Viewing" or that carries the Viewing category; other events matter only for overlaps.
The backend puts the current listings in the prompt. The agent matches each viewing to a unit by the address in its location or subject, then flags: a unit that is leased or has an application pending, a viewing that matches no listing, no location at all, no phone number or email for the applicant in the body, an overlap with another event, a time outside the showing hours, and a viewing that starts less than 15 minutes after one at a different building ends. It returns JSON for the software to show and changes nothing: Calendars.ReadWrite would let it move or cancel events, and both the template and the prompt forbid it.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "<agent id>",
"input": "Check viewings from 2026-11-16T00:00:00-05:00 to 2026-11-22T23:59:59-05:00. Read GET /me/calendarView for that range with Prefer: outlook.timezone=\"Eastern Standard Time\" and Prefer: outlook.body-content-type=\"text\", following @odata.nextLink. A viewing is an event whose subject starts with 'Viewing' or whose categories include 'Viewing'; use other events only to find overlaps. Showing hours are 09:00 to 19:00. Listings (unit_id, address, status): <listings JSON from our database>. Match each viewing to a listing by the address in its location or subject. For each viewing return: event id, start, subject, matched unit_id or null, and every problem that applies from: unit_leased, unit_application_pending, no_listing_match, no_location, no_applicant_contact, overlaps_other_event, outside_showing_hours, under_15_minutes_after_viewing_elsewhere. Return only JSON: {viewings: [...], other_events_checked: number}. Do not create, update, delete, accept or decline any event."
}- 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.
- 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.
- 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 it to the leasing agent as a list for next week, each viewing with its problems in plain words and a link to the unit's listing, and highlights the viewings for leased units first because those are the calls to make today.
The leasing agent decides what to do with each flag. A viewing for a leased unit becomes a call to the applicant offering a similar unit; a missing phone number means finding the original email. A flag can also be wrong: an address written differently from the listing ("Apt 4B" against "Unit 4B") shows up as no match, and back-to-back viewings at two buildings on the same block show a short gap that is fine. The agent's list is where they start, and their own calendar is where they fix it.
The session's accounts names the Microsoft account the run read, and the transcript shows each Graph call, so the software company can answer a manager who asks what the agent looked at.
Run it on every Sunday evening, per leasing agent
The company's scheduler sends one POST /o/{org}/sessions per connected leasing agent each Sunday, with that agent's id as agent, their office's week and timezone and the current listings in input, and a request_id that is a UUID v5 of the user id and the week, so a retried job starts no second run. Runs past the key's concurrent limit are created queued and start as earlier ones finish.
The more useful trigger is a listing changing state. When a unit is marked leased, the backend starts the same request for every leasing agent who shows that building, covering the next 14 days, so the viewings that just became pointless are flagged the same hour.
The use case this job follows, with its automation and trigger: Run an agent per customer task.
Why run it on Rush?
A sync between the listings and the calendars would have to parse free-text events that each leasing agent writes their own way. The agent reads them as written and matches on the address, and says when it cannot. Each leasing agent's Microsoft account is connected to their own agent only, so a run for one never reads a colleague's calendar, and the leasing agent can remove Rush's access in their Microsoft account at any time.
The company keeps one template. Adding a check, such as flagging viewings with no parking note, is one PATCH to the template that reaches every leasing agent's next run. GET /o/{org}/sessions?agent=<agent id> lists one leasing agent's runs and their total_cost_usd, what each run's model calls cost, so the company can see the check's model cost per seat.
Frequently asked questions
Does a leasing agent need a Rush account?
No. They sign in to Microsoft once from the software's settings. The agent, its runs and the bill belong to the person who created the software company's API key.
Will the agent cancel viewings for leased units?
No. It could, since the calendar permission allows edits, so the template and the prompt forbid any change. Cancelling a viewing means telling the applicant, and the leasing agent does that themselves.
Some leasing agents use Google Calendar. What then?
Rush lists Google Calendar as its own app. The company saves a second template that names google-calendar, with the same instructions and a prompt that reads Google's events instead, and makes each leasing agent's agent from whichever template matches their calendar.
What if an office books viewings in a calendar other than the default one?
/me/calendarView reads the signed-in person's default calendar. Graph also reads one of the person's other calendars with /me/calendars/{id}/calendarView, so the template's instructions can name that calendar for an office that books viewings there.
More Microsoft Calendar jobs
More jobs like this: Run an agent per customer task
- Where Are Last Month's Receipts? A Bookkeeping App Collects Each Freelancer's Emailed Receipts From Their Gmail (Gmail)
- Which Supplier Prices Went Up This Month? A Field-Service App's Check of Each HVAC Contractor's OneDrive Price Lists (OneDrive)
- How Did My Client's Site Do Last Month? A Reporting App Drafts Each Agency's Client Reports From Vercel Web Analytics (Vercel)