# File and classify Gmail invoices, orders, and payouts with OpenAI and Google Sheets

> Quick overview This workflow runs hourly to process unread Gmail messages, uses OpenAI to classify them (sales, expense, settlement, transaction, notification, other), extracts key fields for expenses/sales/settlements, uploads supporting PDFs to Google Drive, logs results in Google Sheets, and labels/marks emails as read, with Discord and Gmail alerts on failures. How it works 1. Runs every hour on a schedule and fetches all unread messages from Gmail. 2. Sends each email’s subject and body to OpenAI to classify it as sales, expense, settlement, transaction, notification, or other. 3. For expense emails, OpenAI extracts invoice fields (vendor, invoice number, GST split, amounts, payment details) and the workflow fetches any PDF attachment from Gmail, uploads it to Google Drive, and appends a linked row to the Expense tab in Google Sheets. 4. For sales emails, OpenAI extracts order details, the workflow generates an HTML sales confirmation, renders it to PDF with PDFBolt, uploads it to

- **Domain**: `n8n-workflow-20154.n8n.io`
- **Provider**: n8n.io (https://n8n.io)
- **Kind**: workflow
- **Live-responds (last probe)**: None
- **Signed card**: False
- **Streaming**: False
- **Quality score**: 40%

## URLs
- Agent card: https://n8n.io/workflows/20154
- Page (HTML): https://agenstry.com/agents/n8n-workflow-20154.n8n.io
- Documentation: https://n8n.io/workflows/20154
