Glent Group invoice intake

Invoice intake agent

Watches a Gmail inbox for supplier invoices, reads each attachment with Claude, and turns it into an AP bill ready for Sage Intacct - with a review screen, a “key this into Sage” sheet, JSON/XML payloads and a CSV that drops into the purchase invoice log.

  1. Gmail (invoices@…)
  2. Claude reads the PDF/image
  3. Sage-shaped bill
  4. review
  5. post / export

It runs on the accounts machine, not in the cloud. Once started, it lives at http://localhost:8765 in your browser. API keys, the Gmail token and every invoice stay in the data folder on that machine. Nothing is hosted online, and this website holds no data - it is the front door: get the app, set it up, and see how the workflow goes.

The three pages

The Inbox page: a ledger table with one invoice from Northbank Mechanical Services, its net, VAT and gross totals, zero open checks and a Needs review status
Inbox. Every attachment that came in, with its totals, the number of open checks and its status. The counters filter the list; Download log CSV sits at their right.
The review page: editable extracted fields and line items on the left, the Key into Sage entry sheet on the right
Review. The extracted data on the left is editable and the line editor recalculates totals. On the right sit the document and the Key into Sage sheet, in the order of Intacct's bill screen.
The Settings page: masked API key field with a reveal button, model choice, and the Gmail OAuth client fields
Settings. Every key is pasted here and masked; the eye button reveals it so you can check a paste. Connect Gmail saves the page and opens Google's sign-in.

Get it running

One machine, one browser tab. The first start takes a minute or two while it sets itself up; after that it starts straight away.

  1. Download the app with the button above (or from the releases page) and unzip it somewhere sensible, such as a folder called Invoice agent in Documents.
  2. Have Python 3 on the machine. On Windows, install it from python.org and tick Add python.exe to PATH in the installer. Macs and Linux machines usually have it already.
  3. Start it. On Windows, double-click run.bat. On a Mac, open Terminal, type bash (with a space), drag run.sh into the window and press Enter. The window that opens is the app running - leave it open while you work; closing it stops the app.
  4. Open http://localhost:8765 in your browser. The Inbox will tell you what still needs connecting.

Prefer a different port, or want the data folder in a synced location? Set INVOICE_AGENT_PORT or INVOICE_AGENT_DATA before starting; otherwise nothing needs configuring outside the Settings page.

Set up, on the Settings page

Every key field is masked; the eye button reveals it so you can check a paste. Save with the button at the top or the bottom of the page.

Claude

Paste an API key from the Claude Console. Test key checks it without spending tokens. Sonnet 5 is the default and is plenty for invoices; Haiku 4.5 is cheaper if volume gets high.

Gmail

The app talks to the Gmail API with OAuth, so it needs an OAuth client rather than a password:

  1. Google Cloud Console → create a project → APIs & Services → Library → enable Gmail API.
  2. OAuth consent screen → External → add the invoices mailbox as a test user (or publish the app if it is a Workspace account).
  3. Credentials → Create credentials → OAuth client ID → Desktop app. Paste the client ID and secret into Settings, save.
  4. Click Connect Gmail, sign in as the invoices mailbox, allow access. The token lands in the data folder and refreshes itself.

If Google complains about redirect_uri_mismatch, create the client as Web application instead and add the redirect URI shown on the Settings page.

The search box uses Gmail's own syntax (has:attachment is:unread label:Invoices, from:@supplier.co.uk, and so on). After a message is processed it is marked read and labelled Invoices/Processed, and that label is always excluded from the next search, so nothing is read twice.

Sage Intacct

Optional. With Web Services credentials (sender ID and password, company ID, user ID and password) an approved invoice can be posted straight in as an AP bill - as Draft by default, so accounts can check it inside Intacct before it posts. Without them, everything still works: you get the entry sheet, JSON, the XML gateway body, and the CSV.

Sage coding

The maps that turn extracted lines into Intacct fields. IDs must match what exists in the Intacct company exactly - copy them from the vendor, GL account, project and tax detail lists there.

SettingUsed for
Vendor mapsupplier name on the invoice → VENDORID (fuzzy on case, punctuation and Ltd)
GL account by categorylabour / materials / plant / subcontract / services / expenses / other → ACCOUNTNO
VAT tax details20 / 5 / 0 / reverse charge → Intacct tax DETAILID
Project mapsite code or PO prefix → PROJECTID
Payment termsdays on the invoice → TERMNAME
CIS / retention controldeductions become negative lines to these accounts
Location / departmentstamped on every line

Anything that cannot be mapped is listed as a check on the invoice and blocks Approve until you fill it in. You can type a vendor or project ID straight on the invoice.

What gets extracted

For every invoice or credit note: supplier (name, address, VAT and company numbers, remittance email), invoice number and dates, payment terms, PO number and other references, project / site, one-line description, currency, every line with net / VAT rate / VAT / category, net-VAT-gross totals with a VAT breakdown, VAT treatment (including the domestic reverse charge for construction services), CIS labour/materials split and deduction, retention withheld, amount payable, bank details for the payment run, plus a confidence score and a list of things to check by hand. Totals are re-checked arithmetically after extraction.

Statements, remittances, quotes and marketing PDFs are filed under Not an invoice rather than mapped.

Workflow

  1. Check inbox now (or set a polling interval in Settings) - or drop a PDF onto Process upload to test.
  2. Each attachment appears in the Inbox as Needs review with the number of open checks.
  3. Open it: the left side is the extracted data (editable, with the line editor recalculating totals), the right side is the document and the Key into Sage sheet in the order of Intacct's bill screen.
  4. Save changes rebuilds the Sage payload. Approve once the checks are clear.
  5. Post to Sage (if connected) or Mark keyed in by hand; Query parks it.
  6. Download log CSV on the Inbox for the purchase invoice log - one row per invoice, columns matching the entry sheet.

Things to know