Auto-file forwarded receipt emails into QuickBooks
Every weekday at 6pm, turn forwarded receipt emails into clean QuickBooks expense entries with the right category and the original receipt attached.
Build an agent workflow that turns forwarded receipt emails in Gmail into clean expense entries in QuickBooks Online. It should run on a cron trigger every weekday at 6pm in my local timezone.
On each run, the agent should:
1. Use Gmail List Messages with a query like `label:receipts is:unread` (make the query configurable so I can change the label or sender filter later) to find new forwarded receipts I haven't processed yet.
2. For each message, call Gmail Get a Message with format=full to read the headers and body, and Gmail Get Attachment for any PDF or image attachment so it has the actual receipt file.
3. Extract the structured fields from the email body and attachment: vendor name, transaction date, total amount, tax amount, currency, payment method hint if present, and a one-line description of what was purchased. Be tolerant of forwarded-email noise ("Begin forwarded message", quoted blocks, signature).
4. Use QuickBooks Query Entities to pull the chart of accounts (Account entity where AccountType = 'Expense') once at the start of the run, plus the list of existing Vendors. Cache both in memory for the rest of the run.
5. For each receipt, reason about the vendor and description to pick the best-fitting expense Account from the chart of accounts. For example: Uber/Lyft → Travel, AWS/Vercel/GitHub → Software/Subscriptions, DoorDash/Grubhub/restaurants → Meals & Entertainment, Staples/Amazon office supplies → Office Supplies. If no expense account is an obvious fit, fall back to a configurable default (e.g. "Ask My Accountant" or "Uncategorized Expense").
6. Match the vendor against existing QuickBooks Vendors by name (case-insensitive, fuzzy). If no match exists, call QuickBooks Create Vendor with the parsed vendor name.
7. Call QuickBooks Create Purchase to record the expense. Use PaymentType = CreditCard by default (make this configurable), set the AccountRef to a configurable payment account (the credit card or bank account the receipt was paid from), and add a single line item with the chosen expense Account, the amount, the tax, the vendor as EntityRef, the transaction date as TxnDate, and the one-line description as the Memo/Description.
8. Use QuickBooks Manage Attachables to upload the original PDF or image and link it to the new Purchase so the source document lives on the transaction in QuickBooks.
9. Once the purchase posts successfully, call Gmail Modify Message Labels to remove the UNREAD label and add a "Filed" label (create it if it doesn't exist) so the same receipt never gets filed twice on the next run.
Handle errors per-message: if any single receipt fails (can't extract a total, QuickBooks rejects the purchase, attachment upload fails), skip it, leave the email unlabeled so it gets retried, and continue with the rest. At the end of the run, print a short summary: how many receipts were filed, total amount posted, and the IDs of any that failed.
Make the following user-configurable inputs at the top of the agent: the Gmail search query, the "filed" label name, the default payment account name in QuickBooks, the fallback expense account name, and the schedule.
Additional information
What does this prompt do?
- Scans your Gmail receipts label each evening for new forwarded receipts you haven't filed yet.
- Reads the email body and any PDF or image attachment to pull out vendor, date, total, tax, currency, and a short description.
- Picks the right QuickBooks expense category for each receipt by reasoning about the vendor, so Uber lands in Travel and AWS lands in Software.
- Posts a purchase to QuickBooks with the original receipt file attached, then labels the email as processed so it never gets filed twice.
What do I need to use this?
- A Gmail account where you forward or auto-label your business receipts.
- A QuickBooks Online company you can post expenses to.
- A Gmail label (for example, "Receipts") that you apply to receipts you want filed.
How can I customize it?
- Change the schedule, for example to run hourly during the day or just once a week.
- Swap the Gmail search filter to match how you organize receipts (a different label, a folder, or a sender like billing@stripe.com).
- Adjust the vendor-to-category rules so recurring vendors always land in your preferred QuickBooks account.
- Choose which payment account the expense posts against, like a specific company credit card or bank account.
Frequently asked questions
Will this work if my receipts come as PDF attachments instead of email body text?
How does it know which QuickBooks category to use?
What if the same receipt gets forwarded twice?
Can I review expenses before they post to QuickBooks?
Does the original receipt get attached to the QuickBooks expense?
Stop hand-entering receipts into QuickBooks.
Connect Gmail and QuickBooks once, and Geni files your forwarded receipts every weekday at 6pm.