Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

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

  1. Triggers every minute when a new email arrives in Gmail and downloads the attached PDF invoice.
  2. 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.
  3. Looks up the referenced PO number in Google Sheets and fetches applicable tax rules from a Notion database.
  4. 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).
  5. Writes the compliance result, matched rule, and any violations to a Notion Compliance Audit Log database.
  6. If the invoice passes, posts an approval message to Slack and archives the PDF to a Google Drive folder.
  7. If the invoice fails, posts a blocking alert to Slack and emails the supplier a rejection notice listing the violations.

Setup

  1. Connect your Gmail OAuth2 credential and ensure incoming invoice emails include a PDF as the first attachment (used as attachment_0).
  2. Add your Groq API credential and confirm the extraction schema fields match your invoice formats (invoice/PO numbers, totals, tax, HSN, and SEZ keywords).
  3. 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.
  4. 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.
  5. Connect Slack OAuth2 credentials and select the target channel for approval and failure notifications.
  6. Connect Google Drive OAuth2 credentials and set the destination folder where approved invoice PDFs are archived.

Requirements

  • n8n account (Self-hosted or Cloud)
  • Gmail OAuth2 credentials
  • Groq API credentials
  • Google Sheets OAuth2 credentials
  • Notion credentials
  • Slack OAuth2 credentials
  • Google Drive OAuth2 credentials
  • Google Sheets purchase order database
  • Notion Tax Rules and Compliance Audit Log databases
  • PDF invoice attachments

Customization

  • Tax Logic: Modify the Compliance Engine node to support different tax rules, GST percentages, VAT, Sales Tax, or country-specific regulations.
  • AI Extraction: Adjust the prompt or temperature in the AI Extract Invoice node to improve invoice field extraction and SEZ/LUT detection.
  • Communication: Customize the Slack notifications and supplier rejection emails to include internal policy links or compliance documentation.
  • Validation Rules: Extend the validation logic to verify supplier details, invoice dates, duplicate invoices, or additional compliance requirements.
  • Archiving: Change the Google Drive folder structure or integrate with other document management systems.

Additional info

Who's It For

  • Finance teams
  • Procurement departments
  • Accounts payable teams
  • Compliance officers
  • Organizations automating invoice validation and tax compliance

Add-ons & Enhancements

  • Government GSTIN verification APIs
  • Multi-currency invoice validation
  • ERP integration (SAP, Oracle, NetSuite, QuickBooks)
  • OCR support for scanned invoices
  • AI-based fraud detection
  • Approval workflows and digital signatures

Use Case Examples

  • SEZ Verification: Automatically verify Special Economic Zone invoices for zero-rated tax compliance.
  • Regulatory Blocking: Prevent invoice approvals when mandatory tax information is missing.
  • Audit Readiness: Maintain a complete compliance audit trail for internal and external audits.
  • Supplier Education: Automatically notify suppliers about tax or invoice formatting errors.
  • Fraud Detection: Detect discrepancies between supplier information and invoice contents.

Troubleshooting Guide

Issue Possible Cause Solution
False SEZ detection AI misinterprets address keywords Refine the AI extraction prompt and SEZ detection instructions
Email not triggering Gmail filter or attachment issue Verify Gmail Trigger configuration and ensure PDF attachments are included
Compliance engine error Missing extracted fields Ensure the Structured Output Parser returns all required fields
Slack alert fails Expired credentials Reconnect Slack OAuth credentials
Invoice archive fails Incorrect Google Drive folder configuration Verify Google Drive permissions and destination folder ID

Need Help?

If you need help customizing this workflow, integrating it with your finance and procurement systems, or extending it with AI-powered invoice processing, tax compliance, ERP integrations, and approval automation, our WeblineIndia team is ready to assist. Explore our Process Automation Solutions or connect with our n8n workflow development experts to build, customize, and scale your business automation with confidence.

Contact WeblineIndia to discuss your automation requirements or hire dedicated n8n developers for end-to-end workflow implementation and support.

About

AI-powered n8n invoice compliance workflow that extracts invoice data with Groq Llama 3.3, validates purchase orders and tax rules using Google Sheets and Notion, logs audit records, archives approved invoices to Google Drive, and sends Slack and Gmail notifications. Automate AP, invoice validation, and compliance.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors