LangChain Automate

LangChain Automate streamlines the process of classifying and organizing PDF invoices and receipts from Gmail. Triggered by a webhook, it scans emails within a specified date range, extracts attachments, and uses OpenAI to determine if each PDF matches your defined criteria. Matched PDFs are automatically uploaded to a uniquely named Google Drive folder, enhancing document management efficiency. Optionally, it can email the collected PDFs to your accountant, ensuring timely financial record-keeping.

7/8/2025
20 nodes
Complex
webhookcomplexlangchainnoopgoogle driverespondtowebhookgmailreadpdffiltersticky noteadvancedlogicconditionalintegrationapi
Categories:
Communication & MessagingComplex WorkflowWebhook Triggered
Integrations:
LangChainNoOpGoogle DriveRespondToWebhookGmailReadPDFFilterSticky Note

Target Audience

Target Audience


- Small Business Owners: Those who need to manage and classify invoices or receipts effectively.
- Accountants: Professionals looking for an automated solution to organize financial documents.
- Freelancers: Individuals who require a streamlined method to handle expense documentation.
- Teams Using Google Drive: Groups that rely on Google Drive for document storage and collaboration.
- Users of OpenAI: Anyone interested in leveraging AI to classify documents based on content.

Problem Solved

Problem Solved


- Manual Document Management: This workflow automates the process of classifying and organizing invoices and receipts, saving time and reducing human error.
- Email Overload: It filters and processes only relevant emails with attachments, minimizing clutter.
- Storage Organization: Automatically creates dated folders in Google Drive, ensuring that files are well-organized and easily accessible.
- AI Classification: Utilizes OpenAI to accurately determine the type of documents, enhancing the reliability of classification.

Workflow Steps

Workflow Steps


1. Trigger via Webhook: The workflow starts when a webhook receives a request containing a start date and end date to filter emails.
2. Create Google Drive Folder: A new folder is created in Google Drive named based on the date range (e.g., invoices_YYYY-MM-DD_YYYY-MM-DD).
3. Fetch Emails: Retrieves emails with attachments from Gmail within the specified date range, ensuring that only relevant emails are processed.
4. Iterate Over Attachments: Each email attachment is checked, filtering specifically for PDF files.
5. Read PDF Content: Extracts text from each PDF, skipping those that exceed the token limits defined in the configuration.
6. AI Classification: Sends the PDF content and filename to OpenAI to determine if they match the specified criteria (e.g., "receipt or invoice").
7. Upload Matched PDFs: If OpenAI confirms a match, the original PDF file is uploaded to the created Google Drive folder.
8. Email Invoices: If the initial webhook request includes a flag to send an email, all successfully matched PDFs are aggregated and sent via Gmail to the specified address.

Customization Guide

Customization Guide


- Change Classification Terms: Modify the Match on parameter in the Configure node to classify different types of documents (e.g., change to "contract").
- Adjust Token Limits: Update the maxTokenSize and replyTokenSize values to accommodate longer documents or different AI response needs.
- Specify Email Recipient: In the Configure node, set the sendInvoicesTo field to the desired email address for sending the aggregated PDFs.
- Toggle Email Sending: Control the sendEmail boolean to determine if the workflow should send emails with the matched documents or just upload them to Google Drive.