Quick overview
This workflow monitors a Gmail inbox for PDF invoices, uses Groq (Llama 3.3) to extract structured invoice fields, validates the invoice against Purchase Orders in Google Sheets and tax rules in Notion, logs an audit entry to Notion, and notifies Slack and the supplier based on pass/fail.
How it works
- Triggers every minute when a new email arrives in Gmail and downloads the attached PDF invoice.
- Extracts text from the PDF and sends it to Groq (Llama 3.3) to parse invoice fields into a structured JSON schema, including SEZ/LUT detection.
- Looks up the referenced PO number in Google Sheets and fetches applicable tax rules from a Notion database.
- Validates the invoice against the PO (existence, approval status, currency, and total amount) and against Notion tax rules (SEZ/import/domestic matching and GST expectations).
- Writes the compliance result, matched rule, and any violations to a Notion “Compliance Audit Log” database.
- If the invoice passes, posts an approval message to Slack and archives the PDF to a Google Drive folder.
- If the invoice fails, posts a blocking alert to Slack and emails the supplier a rejection notice listing the violations.
Setup
- Connect your Gmail OAuth2 credential and ensure incoming invoice emails include a PDF as the first attachment (used as
attachment_0).
- Add your Groq API credential and confirm the extraction schema fields match your invoice formats (invoice/PO numbers, totals, tax, HSN, and SEZ keywords).
- Connect Google Sheets OAuth2 credentials and update the spreadsheet/document ID, sheet name, and columns (including
po_number, status, currency, and total_amount) used for PO lookup.
- Connect Notion credentials and set the Tax Rules and Compliance Audit Log database IDs, ensuring the tax rules database includes properties like transaction type, HSN code, expected GST, and reverse charge.
- Connect Slack OAuth2 credentials and select the target channel for approval and failure notifications.
- Connect Google Drive OAuth2 credentials and set the destination folder where approved invoice PDFs are archived.
Additional info
How To Customize Nodes
- Tax Logic: Edit the Compliance Engine node to change GST percentage checks or add rules for different regions (e.g., VAT or Sales Tax).
- AI Sensitivity: Adjust the "Temperature" or "Prompt" in the AI Extract Invoice node to increase or decrease the strictness of SEZ detection.
- Communication: Update the Slack and Email nodes to include links to your company’s internal compliance portal or tax guidelines.
Add‑ons
- Government Portal Integration: Extend the workflow to verify GSTIN numbers directly against government databases via API.
- Multi-Currency Support: Add a node to convert foreign currency invoices to your functional currency for consistent tax reporting.
- ERP Sync: Replace the Google Sheets audit log with a direct "Push" to SAP, NetSuite, or QuickBooks for approved invoices.
Use Case Examples
- SEZ Verification: Automatically identifying invoices from Special Economic Zones to ensure zero-rated tax is applied correctly.
- Regulatory Blocking: Stopping payments to suppliers who fail to provide a valid LUT (Letter of Undertaking) reference.
- Audit Readiness: Maintaining a continuous, real-time log of every compliance check performed for end-of-year tax audits.
- Supplier Education: Automatically notifying vendors of specific tax errors in their invoices, reducing repetitive manual queries.
- Fraud Detection: Identifying mismatches between supplier emails and the data printed on the invoice document.
Troubleshooting Guide
| Issue |
Possible Cause |
Solution |
| False SEZ Detection |
The AI is misinterpreting similar keywords in the address. |
Refine the "Special Rule" instructions in the AI Extract Invoice prompt. |
| Email Not Triggering |
Gmail filters are too broad or the attachment is not a PDF. |
Check the Gmail Trigger node filters and ensure attachments are being correctly downloaded. |
| Compliance Engine Error |
Missing data fields from the AI node. |
Ensure the Structured Output Parser includes all fields required by the script. |
| Slack Alert Fail |
Webhook or OAuth token expired. |
Re-authenticate your Slack credentials in the n8n settings. |
Need Help?
Regulatory compliance is a moving target, and a "one-size-fits-all" approach rarely works for complex finance industries. If you need assistance customizing this workflow for specific regional tax laws, or if you want to integrate this with your existing ERP or proprietary database, our n8n workflow development team is ready to help.
Our expert team specializes in building robust, audit-ready automation for the finance and procurement sectors.
Contact WeblineIndia to discuss your compliance automation goals or to build a tailored solution for your team!