Back to Catalog

Classify & auto-sort invoices in Google Drive with GPT-4o

Rahul JoshiRahul Joshi
537 views
2/3/2026
Official Page

Description:

Automatically classify invoices by industry (Retail, Manufacturing, or EdTech) using GPT-4o-powered AI parsing in this intelligent n8n automation template. Designed for teams managing high-volume billing data, this workflow fetches invoices from Google Drive, extracts PDF text, classifies each document using AI, and automatically moves files to the correct folder based on the predicted industry.

This smart auto-sorting system turns your invoice processing into a zero-touch AI workflow—ideal for finance teams, document processing agencies, and operations managers dealing with multi-client or multi-industry invoicing pipelines.

What This Template Does (Step-by-Step)

📂 Google Drive Search

  • Scans a designated folder (e.g., “Incoming Invoices”)
  • Collects all PDF files available for classification

⬇️ Download & Extract PDF Text

  • Downloads each file using Google Drive API
  • Extracts invoice text from PDFs using the “Extract from File” node

🔁 Batch Handling

  • Loops through each invoice in a batch using the SplitInBatches node
  • Ensures each document is processed one at a time

🧠 GPT-4o Mini via LangChain Agent

  • Sends extracted invoice content to GPT-4o AI
  • Classifies the document into one of: Retail, Manufacturing, EdTech
  • Returns clean, structured classification output

🔀 Smart Switch Logic

  • Evaluates the classification result
  • Routes the invoice to the correct folder based on its predicted industry

📁 Auto-Move Files

  • Uses Google Drive API to move files into industry-specific folders:
  • Retail → Folder A
  • Manufacturing → Folder B
  • EdTech → Folder C

Required Integrations:

✅ Google Drive (OAuth2 authentication) ✅ Azure OpenAI (GPT-4o or compatible model) ✅ LangChain agent setup in n8n

Best For:

🧾 Finance teams classifying vendor or client invoices 🏭 Companies handling multi-industry procurement 🧠 AI automation agencies building custom document sorters 🗂️ Back-office automation for Google Drive file workflows

Key Benefits:

💡 No manual labeling required — AI classifies based on content 📦 Automatically moves files to clean, organized folders 🔄 Works in batch mode for bulk invoice handling 💬 Simple prompt customization for other classification types 🧠 GPT-4o-powered classification ensures high accuracy

Classify and Auto-Sort Invoices in Google Drive with GPT-4o

This n8n workflow automates the process of extracting information from invoice PDFs in Google Drive, classifying them using an AI agent, and then sorting them into appropriate folders. This streamlines invoice management and reduces manual effort.

What it does

  1. Manual Trigger: The workflow is initiated manually, allowing you to run it on demand.
  2. Google Drive File Listing: It lists all PDF files from a specified folder in Google Drive (e.g., an "Unsorted Invoices" folder).
  3. Loop Over Items: Each identified PDF file is processed individually in a loop.
  4. Extract from File: For each PDF, the workflow extracts its content (text) to be analyzed.
  5. AI Agent (GPT-4o): An AI agent, powered by an Azure OpenAI Chat Model (likely GPT-4o, given the directory name), analyzes the extracted text from the invoice. Its role is to:
    • Identify key information (e.g., vendor, amount, date).
    • Classify the invoice type (e.g., utility, software, travel).
    • Determine the correct target folder based on the classification.
  6. Switch Node: Based on the AI agent's classification, the workflow routes the invoice to the appropriate branch. This allows for different actions based on the invoice type.
  7. Google Drive File Movement: The workflow moves the processed invoice PDF from the initial unsorted folder to its newly determined, categorized folder in Google Drive.

Prerequisites/Requirements

  • n8n Instance: A running n8n instance.
  • Google Drive Account: A Google Drive account with a designated "Unsorted Invoices" folder and pre-existing categorized folders (e.g., "Utilities," "Software," "Travel") where invoices will be moved.
  • Azure OpenAI Service: Access to Azure OpenAI Service with a deployed chat model (e.g., GPT-4o) and an associated API key.
  • n8n Credentials: Configured n8n credentials for:
    • Google Drive (OAuth2 or API Key).
    • Azure OpenAI Chat Model (API Key and endpoint details).

Setup/Usage

  1. Import the Workflow: Import the provided JSON into your n8n instance.
  2. Configure Credentials:
    • Update the "Google Drive" node with your Google Drive credentials. Ensure the service account or OAuth scope has permission to list files, read file content, and move files within your Google Drive.
    • Update the "Azure OpenAI Chat Model" node with your Azure OpenAI Service credentials, including your API key, resource name, and deployment name.
  3. Specify Google Drive Folders:
    • In the "Google Drive" node (the first one listing files), configure the "Folder ID" to point to your "Unsorted Invoices" folder.
    • In the "Switch" node, configure the conditions to match the classifications provided by your AI agent and define the output branches.
    • In the subsequent "Google Drive" nodes (for moving files, not explicitly shown in the JSON but implied by the "Switch" node's purpose), configure the "Destination Folder ID" for each categorized folder.
  4. Customize AI Agent Prompt: Review and potentially customize the prompt within the "AI Agent" node to optimize invoice classification for your specific needs and invoice types.
  5. Execute Workflow: Click the "Execute workflow" button to run the workflow. It will process all PDF invoices in your specified unsorted folder.

Related Templates

Automated YouTube video uploads with 12h interval scheduling in JST

This workflow automates a batch upload of multiple videos to YouTube, spacing each upload 12 hours apart in Japan Standard Time (UTC+9) and automatically adding them to a playlist. ⚙️ Workflow Logic Manual Trigger — Starts the workflow manually. List Video Files — Uses a shell command to find all .mp4 files under the specified directory (/opt/downloads/单词卡/A1-A2). Sort and Generate Items — Sorts videos by day number (dayXX) extracted from filenames and assigns a sequential order value. Calculate Publish Schedule (+12h Interval) — Computes the next rounded JST hour plus a configurable buffer (default 30 min). Staggers each video’s scheduled time by order × 12 hours. Converts JST back to UTC for YouTube’s publishAt field. Split in Batches (1 per video) — Iterates over each video item. Read Video File — Loads the corresponding video from disk. Upload to YouTube (Scheduled) — Uploads the video privately with the computed publishAtUtc. Add to Playlist — Adds the newly uploaded video to the target playlist. 🕒 Highlights Timezone-safe: Pure UTC ↔ JST conversion avoids double-offset errors. Sequential scheduling: Ensures each upload is 12 hours apart to prevent clustering. Customizable: Change SPANHOURS, BUFFERMIN, or directory paths easily. Retry-ready: Each upload and playlist step has retry logic to handle transient errors. 💡 Typical Use Cases Multi-part educational video series (e.g., A1–A2 English learning). Regular content release cadence without manual scheduling. Automated YouTube publishing pipelines for pre-produced content. --- Author: Zane Category: Automation / YouTube / Scheduler Timezone: JST (UTC+09:00)

ZaneBy Zane
226

Detect holiday conflicts & suggest meeting reschedules with Google Calendar and Slack

Who’s it for Remote and distributed teams that schedule across time zones and want to avoid meetings landing on public holidays—PMs, CS/AM teams, and ops leads who own cross-regional calendars. What it does / How it works The workflow checks next week’s Google Calendar events, compares event dates against public holidays for selected country codes, and produces a single Slack digest with any conflicts plus suggested alternative dates. Core steps: Workflow Configuration (Set) → Fetch Public Holidays (via a public holiday API such as Calendarific/Nager.Date) → Get Next Week Calendar Events (Google Calendar) → Detect Holiday Conflicts (compare dates) → Generate Reschedule Suggestions (find nearest business day that isn’t a holiday/weekend) → Format Slack Digest → Post Slack Digest. How to set up Open Workflow Configuration (Set) and edit: countryCodes, calendarId, slackChannel, nextWeekStart, nextWeekEnd. Connect your own Google Calendar and Slack credentials in n8n (no hardcoded keys). (Optional) Adjust the Trigger to run daily or only on Mondays. Requirements n8n (Cloud or self-hosted) Google Calendar read access to the target calendar Slack app with permission to post to the chosen channel A public-holiday API (no secrets needed for Nager.Date; Calendarific requires an API key) How to customize the workflow Time window: Change nextWeekStart/End to scan a different period. Holiday sources: Add or swap APIs; merge multiple regions. Suggestion logic: Tweak the look-ahead window or rules (e.g., skip Fridays). Output: Post per-calendar messages, DM owners, or create tentative reschedule events automatically.

Takuya OjimaBy Takuya Ojima
70

Automate Reddit brand monitoring & responses with GPT-4o-mini, Sheets & Slack

How it Works This workflow automates intelligent Reddit marketing by monitoring brand mentions, analyzing sentiment with AI, and engaging authentically with communities. Every 24 hours, the system searches Reddit for posts containing your configured brand keywords across all subreddits, finding up to 50 of the newest mentions to analyze. Each discovered post is sent to OpenAI's GPT-4o-mini model for comprehensive analysis. The AI evaluates sentiment (positive/neutral/negative), assigns an engagement score (0-100), determines relevance to your brand, and generates contextual, helpful responses that add genuine value to the conversation. It also classifies the response type (educational/supportive/promotional) and provides reasoning for whether engagement is appropriate. The workflow intelligently filters posts using a multi-criteria system: only posts that are relevant to your brand, score above 60 in engagement quality, and warrant a response type other than "pass" proceed to engagement. This prevents spam and ensures every interaction is meaningful. Selected posts are processed one at a time through a loop to respect Reddit's rate limits. For each worthy post, the AI-generated comment is posted, and complete interaction data is logged to Google Sheets including timestamp, post details, sentiment, engagement scores, and success status. This creates a permanent audit trail and analytics database. At the end of each run, the workflow aggregates all data into a comprehensive daily summary report with total posts analyzed, comments posted, engagement rate, sentiment breakdown, and the top 5 engagement opportunities ranked by score. This report is automatically sent to Slack with formatted metrics, giving your team instant visibility into your Reddit marketing performance. --- Who is this for? Brand managers and marketing teams needing automated social listening and engagement on Reddit Community managers responsible for authentic brand presence across multiple subreddits Startup founders and growth marketers who want to scale Reddit marketing without hiring a team PR and reputation teams monitoring brand sentiment and responding to discussions in real-time Product marketers seeking organic engagement opportunities in product-related communities Any business that wants to build authentic Reddit presence while avoiding spammy marketing tactics --- Setup Steps Setup time: Approx. 30-40 minutes (credential configuration, keyword setup, Google Sheets creation, Slack integration) Requirements: Reddit account with OAuth2 application credentials (create at reddit.com/prefs/apps) OpenAI API key with GPT-4o-mini access Google account with a new Google Sheet for tracking interactions Slack workspace with posting permissions to a marketing/monitoring channel Brand keywords and subreddit strategy prepared Create Reddit OAuth Application: Visit reddit.com/prefs/apps, create a "script" type app, and obtain your client ID and secret Configure Reddit Credentials in n8n: Add Reddit OAuth2 credentials with your app credentials and authorize access Set up OpenAI API: Obtain API key from platform.openai.com and configure in n8n OpenAI credentials Create Google Sheet: Set up a new sheet with columns: timestamp, postId, postTitle, subreddit, postUrl, sentiment, engagementScore, responseType, commentPosted, reasoning Configure these nodes: Brand Keywords Config: Edit the JavaScript code to include your brand name, product names, and relevant industry keywords Search Brand Mentions: Adjust the limit (default 50) and sort preference based on your needs AI Post Analysis: Customize the prompt to match your brand voice and engagement guidelines Filter Engagement-Worthy: Adjust the engagementScore threshold (default 60) based on your quality standards Loop Through Posts: Configure max iterations and batch size for rate limit compliance Log to Google Sheets: Replace YOURSHEETID with your actual Google Sheets document ID Send Slack Report: Replace YOURCHANNELID with your Slack channel ID Test the workflow: Run manually first to verify all connections work and adjust AI prompts Activate for daily runs: Once tested, activate the Schedule Trigger to run automatically every 24 hours --- Node Descriptions (10 words each) Daily Marketing Check - Schedule trigger runs workflow every 24 hours automatically daily Brand Keywords Config - JavaScript code node defining brand keywords to monitor Reddit Search Brand Mentions - Reddit node searches all subreddits for brand keyword mentions AI Post Analysis - OpenAI analyzes sentiment, relevance, generates contextual helpful comment responses Filter Engagement-Worthy - Conditional node filters only high-quality relevant posts worth engaging Loop Through Posts - Split in batches processes each post individually respecting limits Post Helpful Comment - Reddit node posts AI-generated comment to worthy Reddit discussions Log to Google Sheets - Appends all interaction data to spreadsheet for permanent tracking Generate Daily Summary - JavaScript aggregates metrics, sentiment breakdown, generates comprehensive daily report Send Slack Report - Posts formatted daily summary with metrics to team Slack channel

Daniel ShashkoBy Daniel Shashko
679