Nightly OneDrive receipts to Excel expense log with Outlook summary

By General Input

Drop receipts and invoices in OneDrive and every weekday at 11pm this agent parses them, fills your Excel expense log, and emails you a summary.

Integrations

  • Microsoft OneDrive
  • Microsoft Excel
  • Microsoft Outlook

Type

Agentic Task

Categories

  • Finance
  • Personal Productivity

Build an agent workflow that runs on a cron trigger every weekday at 11pm in my local time zone and turns the receipts and invoices I drop in OneDrive into a clean Excel expense log, with an Outlook email summary at the end.

Inputs the workflow should accept as configuration:

- inbox_folder_path: the OneDrive folder I use as my receipts inbox (default /Receipts).

- workbook_path: the OneDrive path to my Excel expense log (must be OneDrive for Business or SharePoint, since the Excel API does not support consumer OneDrive).

- worksheet_name and table_name: the named table inside that workbook the agent should append rows to. Assume the table already has columns Date, Vendor, Amount, Currency, Tax, Category, Description, and Source File (in that order).

- summary_recipient: the email address that gets the nightly Outlook summary (default: my own).

- categories: a list of expense categories the agent should classify each receipt into (default: Travel, Meals, Software, Office, Hardware, Marketing, Professional Services, Other).

- timezone: my local IANA time zone, used both for the cron schedule and for the 'last 24 hours' window.

On each run, the agent should:

1. Use Microsoft OneDrive to enumerate files added to inbox_folder_path in the last 24 hours. Prefer search_items scoped to that folder with a recency filter, and fall back to list_children and filtering by createdDateTime if search is unavailable. Skip anything that lives inside a year/month subfolder (those are already filed).

2. For each new file, download its content with Microsoft OneDrive's download_file_content. If the file is an Office document (.docx, .doc, .xls, .xlsx, .pptx), use download_converted_format with format=pdf so the agent can read the contents as a PDF. Image formats (JPG, PNG, HEIC) and PDFs go straight through.

3. Read the file and extract: transaction date (ISO yyyy-mm-dd), vendor name, total amount, currency code (default USD if not stated), tax amount if visible, the best matching category from the configured list, and a single short description (under 80 chars). If the receipt is unreadable or any required field is missing, do not invent values: add the file to an 'unparseable' list with a short reason.

4. For each successfully parsed receipt, append one row to the configured Excel table using Microsoft Excel's add_table_row. Match the values to the existing column order, and put the original OneDrive filename (and a web URL to the file if available) in the Source File column.

5. After the row is appended, move the original file in OneDrive into inbox_folder_path/{YYYY}/{MM}/ based on the parsed transaction date (creating the year and month subfolders if they do not exist) using Microsoft OneDrive's move_item. Leave unparseable files in the inbox so I can fix them tomorrow.

6. At the end of the run, send one Microsoft Outlook email via send_mail to summary_recipient. The email should include: number of receipts processed, total amount spent grouped by currency, a count of receipts by category, the top three highest individual expenses with vendor and amount, and a clearly labeled list of any unparseable files with the reason and a direct OneDrive link to each. Use a clean HTML body, not plain text. If there were zero new receipts and zero unparseable files, send a brief 'nothing to do tonight' email so I know the agent ran.

Operational details:

- Treat Microsoft OneDrive, Microsoft Excel, and Microsoft Outlook as separate connections, even though they share a Microsoft 365 sign-in.

- Honor Microsoft Graph throttling: on 429, wait the Retry-After value and retry with backoff.

- Be idempotent: never write the same receipt twice. Before adding a row, check that no existing row in the table has the same Source File filename.

- Cap each run at processing 100 receipts; if there are more, process the oldest 100 and mention the backlog in the email.

Related prompts

Explore more prompts
Spin up a OneDrive client workspace when a HubSpot deal closes wonWeekly HubSpot pipeline snapshot to Excel and SlackLog OneDrive proposals to HubSpot deals with a daily Slack digestNightly Fathom call filing to OneDrive client folders and a Notion CRM logOn-demand product planning partner for briefs and specsAnswer Slack questions from every tool you connectCampaign copy generator for emails, ads, and landing pagesDraft customer support replies grounded in your appsDaily sales assistant briefing for your pipelineDaily Chief of Staff brief from schedule, inbox, and team chat