# How Does Time-Tracking Software Draft Each Consultant's Weekly Timesheet From Their Microsoft Calendar?

A time-tracking app for consultancies makes one agent per consultant that reads their Microsoft calendar each Friday and drafts the week's timesheet.

[Run this on Rush](https://cloud.getrush.ai/run/draft-weekly-timesheet-from-calendar/microsoft-calendar/). Opens the console with this prompt ready to send. Connect Microsoft Calendar there first.

## What the agent does

This is for a software company that sells time tracking and billing to small consultancies: IT advisers, management consultants, engineering firms. Consultants put off timesheets, and most of what they would type on Friday is already in their Outlook calendar: a workshop with one client, two calls with another, the internal planning meeting. The company adds Draft my week: every Friday afternoon each consultant finds a timesheet filled in from their own calendar, mapped to the firm's client codes, waiting to be corrected and submitted.

The company saves the agent once as a template with `POST /o/{org}/agents`, with `"connections": ["microsoft-calendar"]` (it connects a Microsoft calendar of its own first) and instructions that keep it to reading. When a consultant turns the feature on, the backend makes their agent with `{"template": "<template id>", "name": "timesheet-<user id>"}`, calls `POST /o/{org}/agents/{agent}/connections {"type": "app", "name": "microsoft-calendar"}`, and opens the `authorize_url` in a popup for that consultant, who signs in on Microsoft's page. Rush asks Microsoft for `Calendars.ReadWrite`, the scope its Microsoft Calendar product names; the template's instructions and every prompt forbid creating, changing or deleting an event.

A run reads `GET /me/calendarView` with `startDateTime` and `endDateTime` for Monday to Friday. Microsoft's reference says the calendar view returns the occurrences, exceptions and single instances of events in the range, so a weekly recurring call appears once for each week it happened. The run sends `Prefer: outlook.timezone` with the consultant's time zone so times come back in local hours, selects `subject`, `start`, `end`, `categories`, `attendees`, `organizer`, `isAllDay`, `isCancelled`, `showAs` and `sensitivity`, and follows `@odata.nextLink` to the end.

Each event is matched to a client code from the firm's list in `input`: first by an Outlook category named for the client, which many consultants already use, then by the attendee email domains the list gives for each client. An event with only colleagues is Internal; cancelled events, all-day events and events shown as free are left out; an event marked private counts as unassigned time with no subject. It totals hours per client per day, rounded to the firm's increment, and lists every event it could not place so the consultant decides.

## Start it with one API call

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

```json
{
  "agent": "<agent id>",
  "input": "Draft my timesheet for 2026-11-16 to 2026-11-20 from my Microsoft calendar. Call GET /me/calendarView with startDateTime 2026-11-16T00:00:00-05:00 and endDateTime 2026-11-21T00:00:00-05:00, header Prefer: outlook.timezone=\"Eastern Standard Time\", $select subject,start,end,categories,attendees,organizer,isAllDay,isCancelled,showAs,sensitivity, following @odata.nextLink. Client codes: HARB (category Harbor Co-op, domain harborcoop.example), MLT (category Millton Schools, domain millton.example), GRN (category Greenway Logistics, domain greenway.example). Our own domain: northbeam.example. Match by category first, then attendee domain; only colleagues means INTERNAL; two clients in one event goes to unplaced. Skip cancelled, all-day and showAs free events. Private events: UNASSIGNED with no subject. Round each day's total per code to 0.25 h. Return only JSON {days: [{date, entries: [{code, hours, events: [subject]}]}], unplaced: [{date, start, end, subject, reason}]}. Read only: do not create, update, accept, decline 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 session's answer is the JSON, which the app's webhook handler loads into the consultant's draft timesheet for the week, each line showing the events it came from. Unplaced events appear in a short list beside it with the reason each could not be placed.

What the consultant checks before submitting: hours the calendar does not show, such as travel or work between meetings; meetings that ran over or ended early; an event matched to a client by one stray attendee; and the unplaced list. The draft is a starting point, and the app submits nothing until the consultant presses Submit.

## Run it on every Friday afternoon, per consultant

The app's scheduler sends one `POST /o/{org}/sessions` per consultant with the feature on, at 15:00 on Friday in each consultant's time zone, with their agent id as `agent`, the week's dates and the firm's client list 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. Every consultant's run starts at once, and those past the key's `max_concurrent` wait as `queued` until a slot frees.

A consultant back from leave can press Draft again for any past week, and the app sends the same request with that week's dates.

## Why run it on Rush?

Each consultant's Microsoft sign-in is theirs, held in Rush's connection under their agent. The company keeps no Microsoft tokens and registers no Microsoft app, since the consultant signs in to Rush's app on Microsoft's page, and a session's `accounts` names the Microsoft account it read, so the company can show a consultant which runs opened their calendar.

Each Friday is a session per consultant with its own computer, a record of each Graph call and its model cost, which the company adds up per consultant with `GET /o/{org}/sessions?agent=<agent id>`. A calendar holds things a timesheet does not need, so the prompt turns private events into unassigned time with no subject, and the transcript shows exactly what was read.

## Frequently asked questions

### Why does Rush ask for write access to the calendar?

Rush's Microsoft Calendar sign-in asks for `Calendars.ReadWrite`, the one scope that product names, so the same connection can serve jobs that book meetings. Microsoft's reference lists `Calendars.ReadBasic` as enough to read a calendar view; this agent's instructions forbid every change, and the transcript records each Graph call.

### What about a second calendar for client work?

This prompt reads the default calendar. Microsoft's reference has the same view for any of the user's calendars, `/me/calendars/{id}/calendarView`, so a consultant who keeps client work on a second calendar can have the app name it in `input`.

### Does it read meeting notes or agendas?

No. It selects the subject, times, categories, attendees and a few flags, never the event body. That is enough to place most meetings and keeps agendas and dial-in details out of the run.

### What if two clients are in one meeting?

The agent puts that event under unplaced with both clients named, and the consultant splits the time. A guessed split would put wrong hours on an invoice.

## More Microsoft Calendar jobs

- [Which Managed IT Clients Are Due a Quarterly Business Review? Read It From Outlook Calendar](https://getrush.ai/run/find-clients-due-a-business-review/microsoft-calendar/)
- [Propose Interview Times From Each Recruiter's Microsoft 365 Calendar](https://getrush.ai/run/propose-interview-times/microsoft-calendar/)
- [Are Next Week's Viewings Ready to Go? A Property Management App's Check of Each Leasing Agent's Outlook Calendar](https://getrush.ai/run/check-next-weeks-property-viewings/microsoft-calendar/)

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

- [Explain Each User's Monthly Profit and Loss From Their Own QuickBooks](https://getrush.ai/run/explain-monthly-profit-and-loss/quickbooks/)
- [Read Supplier Invoice PDFs From Each Customer's OneDrive Into Draft Bills](https://getrush.ai/run/extract-supplier-invoices/onedrive/)
- [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/)

## Keep reading

- [Connect Microsoft Calendar to Rush once, then name it on any run](https://getrush.ai/integrations/microsoft-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/)
