AI Agent: Gmail PDF Classifier & Drive Uploader
Integrates with:
Overview
Unlock Automated Document Organization with this AI Agent
Tired of manually sifting through emails for important PDFs like invoices, contracts, or payslips? This AI Agent automates the entire process. It connects to your Gmail, scans incoming emails for PDF attachments, and uses OpenAI's intelligence to understand the content of each PDF. Based on your defined criteria (e.g., looking for the word 'invoice'), it then automatically uploads the relevant PDFs to a specific folder in your Google Drive, keeping your documents neatly organized and easily accessible.
Key Features & Benefits
- AI-Powered PDF Classification: Leverages OpenAI to analyze text within PDFs, ensuring accurate identification of documents like invoices, contracts, or payslips based on your custom keywords.
- Automated Gmail Scanning: Continuously monitors your Gmail for new emails with attachments, triggering the workflow automatically.
- Targeted Document Extraction: Focuses specifically on PDF files, extracting their text for analysis and filtering out other attachment types.
- Customizable Filtering Logic: Easily define the specific keyword (e.g., "invoice," "contract," "receipt") in the 'Configure' node to instruct the AI on what types of documents to identify.
- Direct Google Drive Upload: Seamlessly archives matched PDFs into your chosen Google Drive folder, maintaining an organized digital filing system.
- Time-Saving Automation: Drastically reduces manual effort involved in email processing, document identification, and cloud storage.
- Configurable AI Parameters: Allows adjustment of token limits for OpenAI interaction, helping to manage API usage and costs.
- Built-in Checks: Includes logic to handle emails without attachments, non-PDF files, and PDF text exceeding token limits.
Use Cases
- B2C E-commerce: Automatically archive PDF invoices from suppliers (e.g., shipping, marketing tools) received in Gmail to a 'Supplier Invoices' Google Drive folder, streamlining bookkeeping.
- B2B SaaS Companies: Efficiently sort and store client-signed PDF contracts or service agreements from Gmail into specific client folders on Google Drive, ensuring compliance and easy retrieval.
- Solopreneurs & Freelancers: Keep finances organized by auto-filtering PDF receipts for business expenses from email and saving them to a 'Tax Deductibles' Google Drive folder.
- Founders/CTOs: Automate the collection of important financial reports or compliance documents received as PDFs via email into a secure 'Financials QX' Google Drive folder for review.
Prerequisites
- An n8n instance (Cloud or self-hosted).
- OpenAI API Key with access to a suitable model (e.g., gpt-3.5-turbo, gpt-4).
- Gmail account credentials for n8n (OAuth2 recommended).
- Google Drive account credentials for n8n (OAuth2 recommended).
Setup Instructions
- Download the n8n workflow JSON file.
- Import the workflow into your n8n instance.
- Configure the 'On email received' (Gmail Trigger) node: Authenticate your Gmail account with n8n. Ensure 'Download Attachments' is enabled in the node's options.
- Configure the 'OpenAI matches PDF textual content' node: Select your OpenAI credential or create a new one using your API Key. Choose your preferred model (e.g., gpt-3.5-turbo).
- Configure the 'Upload file to folder' (Google Drive) node: Select your Google Drive credential or create a new one to authenticate your account.
- In the 'Configure' (Set) node:
a. Set the
Match on
field to the primary keyword OpenAI should use to identify relevant PDFs (e.g., 'invoice', 'payslip', 'contract'). This value is case-sensitive for the prompt. b. Update theGoogle Drive folder to upload matched PDFs
field with the full URL of your target Google Drive folder. The workflow extracts the folder ID from this URL. c. Optionally, adjustmaxTokenSize
(maximum tokens from PDF text to send to OpenAI) andreplyTokenSize
(max tokens for OpenAI's 'true'/'false' reply). Default values (4000 and 50 respectively) are provided as a starting point. - Review the prompt in the 'OpenAI matches PDF textual content' node. The default prompt asks OpenAI to return only 'true' or 'false' in lowercase. If you modify it, ensure the 'Is matched' IF node condition is updated accordingly.
- Activate the workflow. It will check for new emails based on the Gmail Trigger's poll time settings (default is every minute).
Want your own unique AI agent?
Talk to us - we know how to build custom AI agents for your specific needs.
Schedule a Consultation