2 templates found
Category:
Author:
Sort:

Automatic email invoice archiving & data extraction with Gmail, Drive & AI

Automated Invoice Archiving Automatically fetch, store, and extract key information from invoices received via email from your ISP or utility provider (electricity, gas, telecom, water, etc.).The workflow saves the invoices to Google Drive (or optionally to your personal FTP/SFTP server) and logs all invoice details into Google Sheets via AI-powered extraction. Read: Full setup Guide How it works Scheduled TriggerRuns the workflow at a selected interval (e.g., every hour). You can freely adjust the timing. Gmail – Fetch MessagesReads your Gmail inbox and retrieves only messages coming from your ISP/utility provider’s email address, filtering for messages with PDF attachments. Gmail – Download Invoice Fetches the full email content and downloads the attached invoice (PDF). Google Drive – Upload File Uploads the invoice into a specific Google Drive folder of your choice. (Optional) Upload to FTP/SFTP Sends a copy of the invoice to your personal server via secure FTP/SFTP. AI Extraction Pipeline Extract PDF Text – converts the PDF into text (OCR not required if text-based). AI Agent (OpenRouter) – understands the invoice content and extracts structured fields (invoice number, date, provider name, total amount, tax info, line items, etc.) Code Node – sanitizes and parses the JSON from the AI model. Google Sheets – Append Invoice DataAdds a new row to your Google Sheet with all parsed invoice fields. (Optional) CleanupAutomatically deletes:– the Gmail message– the temporary file in Google Drive(Useful when you only want your FTP or Sheets copy.) Parameters to configure | Parameter | Description | Recommended configuration | | --- | --- | --- | | Gmail Credentials | OAuth2 credentials needed to read and delete emails. | Create OAuth credentials on Google Cloud → enable Gmail API → paste Client ID & Secret into n8n → “Connect OAuth2”. | | Sender Email Filter | Email address your provider uses to send invoices. | Example: billing@your-isp.com, invoices@utility.it, ciao@octopusenergy.it | | Google Drive Folder | Destination folder for saving invoices. | Copy the folder ID from the Drive URL and paste it into folderId. | | Google Drive Credentials | OAuth2 connection for file uploads/deletions. | Same Google Cloud project → enable Drive API → OAuth connect in n8n. | | FTP/SFTP Server (optional) | Upload invoices to your private server. | Host / IP · Port · Username · Password or SSH Key · Destination path (e.g. /home/user/invoices/). | | AI Model (OpenRouter) | Large-language model used to parse invoice text. | Example: gpt-4.1, llama-3.1, or any preferred OpenRouter model. | | Google Sheets Document | Destination spreadsheet for structured data. | Create a Sheet → add columns (Vendor, Invoice Number, Date, Amount, Service Type, etc.) → insert documentId & sheet name. | | Sheets Credentials (Service Account) | Used for writing into Google Sheets. | Create Service Account → download JSON → add to n8n → share the Sheet with the Service Account email. | | Trigger Interval | How often the workflow checks for new invoices. | Every hour · every 30 minutes · daily at set ti | Node-by-node breakdown Schedule Trigger Runs at the interval you choose (default: hourly).Start → triggers entire workflow. Gmail – Get Many Messages Filters inbox items using: Sender email (your ISP/utility address) Has attachment Unread or recent messages Downloads metadata + attachment references. Filter – Contains Attachment Ensures only messages with binary attachments continue. Gmail – Get Invoice Downloads: Full email JSON The invoice PDF (binary data) Google Drive – Upload File Uploads invoice PDF with a dynamic filename: {{ $json.from.value[0].name }}-{{ $json.date }}.pdf Requires: Google Drive OAuth2 credentials Folder ID (destination directory) HTTP Request – Download File Retrieves the raw PDF file from Google Drive for further processing. (Optional) FTP/SFTP Upload Uploads the PDF to your server using: Host / IP Port (default 22) Username Password or private key Destination path Filename is sanitized to ensure Unix compatibility. (Optional) Delete Temporary File Deletes the Google Drive file if you don’t want duplicates. (Optional) Delete Gmail Message Removes the original email once processed (optional inbox cleanup). Extract from File (PDF → Text) Reads the PDF and extracts raw text for AI processing. OpenRouter Chat Model LLM backend for the AI agent. Provides: invoice parsing field extraction structured reasoning AI Agent – Extract Invoice Fields The agent is instructed to return strict JSON only, containing keys such as: vendor_name invoice_number invoice_date total_amount tax_details line_items[] po_number po_date Works for most standard PDF invoices. Code – Clean & Parse JSON Sanitizes the AI output: Removes markdown fences Extracts valid JSON Parses into a clean JS object If the AI output is malformed, debugging info is returned. Google Sheets – Append Data Appends the extracted fields into a structured row.Example mappings: Vendor → {{ $json.vendor_name }} Invoice Number → {{ $json.invoice_number }} Date → {{ $json.invoice_date }} Amount → {{ $json.total_amount }} Service Type → {{ $json.line_items[0].description }} 💡 Tips & best practices Add multiple sender filters if you have more than one utility provider. Ensure invoices are text-based PDFs for best extraction results. Use Google Drive as a reliable long-term archive, or keep only FTP if you prefer local storage. Create charts in Google Sheets for tracking: Monthly utility cost trends Year-over-year comparison Consumption spikes (if included in invoices) ⚠️ Important notes Utility invoices contain personal and financial data. Keep your FTP/SFTP server secure. Google APIs require proper OAuth2 or Service Account setup; misconfiguration may cause permission errors. This workflow is for personal automation, not a replacement for official fiscal archiving. AI extraction quality depends on invoice formatting and the model you choose.

Paolo RoncoBy Paolo Ronco
328

Automate content analysis & multi-platform distribution with GPT-4

How It Works ⚙️ This workflow is a comprehensive, AI-powered system that acts as a virtual content manager for creators and marketing teams. It automates the entire content lifecycle, from ingestion and analysis to multi-channel distribution and performance logging. Multi-Source Ingestion: The workflow starts by ingesting new content from a trigger, such as a WordPress blog post or an RSS Feed from a YouTube channel. AI-Powered Analysis: The new content is sent to an OpenAI (GPT-4) node, which performs a series of high-value tasks. It instantly creates a summary, extracts keywords, analyzes the sentiment, and generates tailored post drafts for different social media platforms. Smart Distribution: A Buffer node then takes these AI-generated, platform-specific posts and schedules them for optimal times across your social media channels like Twitter, LinkedIn, and Facebook. Centralized Archiving: All of the content data, including the AI-generated summaries and insights, are automatically logged into a Google Sheets database. This creates a powerful, searchable archive and an analytics dashboard for tracking content performance. How to Set Up 🛠️ Import the Workflow: Copy the provided workflow JSON and import it into your n8n instance. Configure Credentials: OpenAI: Add your API Key. WordPress: Add your API credentials. Buffer: Add your API credentials. Google Sheets: Add your OAuth2 credentials. Customize Workflow Nodes: Node 1 (WordPress Trigger): Select your WordPress credential. You can also add other trigger nodes like RSS Feed Read Trigger if needed. Node 2 (OpenAI): You can customize the prompt to get different kinds of output or translate into more languages. Node 4 (Buffer): Select the social media profiles you want to post to. Node 5 (Google Sheets): Replace the placeholder [YOUR SPREADSHEET ID] and [YOUR CONTENT LOG SHEET NAME] with your own details and map the data columns. Save & Activate: Once all settings and credentials are configured, save the workflow and click the "Inactive" toggle in the top-right corner to make it live.

MarthBy Marth
137
All templates loaded