AI Automation

n8n Workflow Parses Gmail Invoices Into Sheets With Slack Alerts

A shared n8n workflow uses gpt-4o-mini to turn emailed invoice PDFs into spreadsheet rows and posts Slack alerts for payments due within seven days.

Illustration of an automated workflow moving invoice documents from an email inbox into a spreadsheet

A developer has shared a ready-made automation workflow that reads invoice PDFs from Gmail, records the key payment details in Google Sheets and sends a Slack alert when a bill is close to its due date or already overdue. The workflow is built in n8n, a workflow automation tool, and was published as a GitHub Gist by its author, Anas Iftikhar, on October 14, 2026. The author describes it as a response to a common frustration: invoices arriving in busy inboxes and getting lost before anyone acts on them.

How the workflow moves an invoice from inbox to spreadsheet

The process starts with a Gmail trigger that watches for any incoming email with a PDF attached. Once a match is found, an Extract from File node pulls the raw text out of the document. That text is then sent to gpt-4o-mini, a language model, which is called through Replicate, a platform that hosts AI models and makes them available through an API. The request uses an HTTP Request node with a Prefer: wait header, so the workflow waits for the model's reply before moving on.

The model is asked to return five pieces of information as structured JSON: the vendor, the invoice number, the total, the currency and the due date. A Code node then checks that reply and calculates how many days remain until payment is due. Structured output of this kind matters because a spreadsheet can only sort, filter and alert on values that sit in consistent fields.

Once the data is ready, the workflow writes a row to Google Sheets. The author says the sheet is matched on the email's message ID. If the same email is processed again, for example after a retry, the existing row is updated rather than duplicated. The email itself is then tagged with a label called Invoices/Processed in Gmail, which gives the user a visual record of what has been handled.

Slack alerts are the final step. If an invoice is due within seven days, or is already past its due date, the workflow posts a message to a Slack channel. The author has also added a separate error trigger. If any node in the chain fails, the trigger posts the name of that node and the error message to Slack, so problems do not go unnoticed.

Why the author moved away from the free Gemini tier

The author first tried to run the extraction step on the free tier of Google's Gemini model. That approach ran into repeated errors reading "model is experiencing high demand", which is a sign that the service was overloaded and rejecting requests. Switching the extraction to gpt-4o-mini through Replicate resolved the problem, according to the author's write-up.

For readers who prefer to stay on Gemini, the author suggests turning on the Retry On Fail option in n8n. This setting tells the workflow to try a failed step again instead of stopping. It does not guarantee success during periods of heavy demand, but it can smooth over brief overloads.

The episode highlights a practical point about building AI-powered automations. Free tiers are useful for testing, but a workflow that runs unattended on a real inbox needs a service that can handle regular requests reliably. Anyone copying this setup should expect to pay for model access and to set up their own credentials for each service.

Testing and known limitations

The author tested the workflow with three invoices that were made up for the purpose. Two used US dollars and one used British pounds, and the layouts differed from one another. According to the write-up, the extracted fields were correct in every case. Three test documents are a small sample, so the result should be read as an encouraging first check rather than proof that the workflow handles every invoice format.

The author is open about the gaps. The workflow does not yet handle multi-page invoices, and it cannot process several PDF attachments within a single email. Both situations are common in real business correspondence, where a supplier may send a long invoice or bundle several documents together. Anyone relying on the tool for those cases would need to check the output manually or adapt the workflow.

The author has asked readers for suggestions on what to change, which signals that the project is still in development rather than a finished product.

What to prepare before trying the workflow

Setting up the workflow requires accounts and credentials for Gmail, Google Sheets, Slack and Replicate. Before importing the workflow JSON from the Gist, the user needs to create a Google Sheet with the following headers: Processed At, Vendor, Invoice Number, Total Amount, Currency, Due Date, Days Until Due, Email Subject, From and Message ID. The Gmail label must also exist in advance. The Google Sheets node then needs the sheet's ID pasted into it.

  • Create the Google Sheet with the ten headers listed above.
  • Create the Invoices/Processed label in Gmail.
  • Add your own Gmail, Google Sheets, Slack and Replicate credentials in n8n.
  • Paste your sheet ID into the Google Sheets node.
  • Test with sample invoices before trusting the alerts with real bills.

Anyone adapting the workflow should also think about data handling. Invoices contain financial and contact details, so it is worth checking which services receive the document text and under what terms.

Outlook for finance-focused automation

Small teams and individuals are increasingly connecting email, spreadsheets and messaging tools with AI models to remove repetitive data entry. This workflow shows how far a non-specialist can go with a visual automation tool, a hosted model and a few well-chosen checks. Its real test will be how it copes with the harder cases the author has not yet addressed, such as long invoices and multi-document emails. Until those are covered, a human review step remains sensible for any bill that carries significant financial consequences.

Source: gist.github.com

Comments (0)