Back to Templates

Extract and log Outlook invoices to OneDrive Excel with GPT-4.1-mini

Created by

Created by: AI Solutions || legalgpts
AI Solutions

Last update

Last update 2 days ago

Share


Invoice Processor – Microsoft 365

Automatically extract, log, and archive invoices from your Outlook inbox using GPT-4.1-mini, OneDrive, and Excel — no manual data entry required.

Who It's For

This workflow is built for small business owners, finance teams, and operations managers who receive invoices via email and need a hands-free way to capture, organize, and track them. It works entirely within the Microsoft 365 ecosystem — no third-party apps required.

How It Works

The workflow runs on a daily schedule (default: 7 AM) and fetches all unread emails from a specified Outlook folder. Each email body is cleaned from HTML to plain text and passed to GPT-4.1-mini, which extracts 14 structured invoice fields — including vendor name, invoice number, issue date, due date, and total amount due. If the email includes a PDF attachment, the workflow fetches it via the Microsoft Graph API, checks whether a dated subfolder exists in OneDrive (Invoices/YYYY-MM-DD), creates one if needed, and uploads the file as VENDOR-YYYY-MM.pdf, capturing the shareable link. All extracted data is appended to an Excel table for record-keeping. Finally, processed emails are marked as read and a formatted HTML digest summarizing all invoices is sent via Outlook.

How to Set Up

  1. Add your Microsoft Outlook OAuth2 credential — used to fetch emails and send the digest.
  2. Add your Microsoft Graph OAuth2 credential — used for OneDrive folder creation, PDF upload, and Excel append.
  3. In Outlook — Get Unread Emails, update foldersToInclude to your target Outlook folder ID (find it via Graph Explorer).
  4. In Excel — Append Invoice Row, update the workbook, worksheet, and table IDs to match your tblInvoices tracker file in OneDrive.
  5. In Code — Build Digest Email, replace YOUR_ONEDRIVE_FOLDER_URL with a direct link to your Invoices folder.
  6. In Outlook — Send Daily Digest, replace [email protected] with your recipient address.

Requirements

  • Microsoft Outlook OAuth2 credential
  • Microsoft Graph OAuth2 credential (Generic OAuth2 with https://graph.microsoft.com/.default scope)
  • OpenAI API credential (GPT-4.1-mini)
  • An Excel workbook in OneDrive with a table named tblInvoices containing columns matching the field list
  • A PDF Link column added to your tblInvoices table

How to Customize

  • Change the schedule: Adjust the cron expression in Schedule — Daily Trigger to run more or less frequently.
  • Add more fields: Extend the extraction prompt in AI — Extract Invoice Fields with additional fields and add matching columns to your Excel table.
  • Modify the folder structure: Edit Code — Build Upload Path to change how PDF subfolders are named or organized in OneDrive.
  • Filter by sender or subject: Add a Filter node after Outlook — Get Unread Emails to process only emails matching specific criteria.

Support: [email protected] | Automated Intelligent Solutions