[n8n] Auto Invoice & Receipt OCR to Google Sheets – Support Google Drive, Gmail, & Telegram Triggers

Now $0

Automatically process invoices and receipts using Gemini OCR, extracting data directly into Google Sheets from multiple sources including Google Drive, Gmail, and Telegram. This powerful, free (for a limited time) workflow ensures your bookkeeping is always accurate, organized, and efficient, significantly reducing manual effort and potential errors.

This product includes:

  • n8n template (JSON file)

  • Google Sheet template

  • Google Sheet template

$

Automate Invoice & Receipt OCR (Google Drive, Gmail, Telegram) to Google Sheets via Gemini API

Automatically process invoices and receipts using Gemini OCR, extracting data directly into Google Sheets from multiple sources including Google Drive, Gmail, and Telegram. This powerful, free (for a limited time) workflow ensures your bookkeeping is always accurate, organized, and efficient, significantly reducing manual effort and potential errors.

Who is this for?

This workflow is ideal for busy entrepreneurs, startup founders, freelancers, small business owners, bookkeepers, and accountants who aim to eliminate manual, repetitive, and error-prone bookkeeping tasks. Whether you regularly manage expenses from physical paper receipts, digital invoices, or email attachments, this workflow will dramatically streamline your bookkeeping processes and save you significant time and effort each month.

What problem is this workflow solving?

Manual data entry of invoices and receipts is notoriously tedious, incredibly time-consuming, and highly susceptible to human error. Mistakes in bookkeeping can lead to financial inaccuracies, compliance issues, and wasted resources. By automating the extraction of invoice data, this workflow streamlines your financial management process, significantly improves accuracy, reduces operational overhead, and allows you to redirect valuable resources and attention toward strategic, revenue-generating business activities.

What this workflow does

This template provides a powerful, automated solution for invoice and receipt data extraction using Google’s Gemini API for OCR (Optical Character Recognition) via direct HTTP requests.

  1. Main Flow (Google Drive Trigger): The main workflow triggers (Google Drive Trigger New Files) whenever a new file (PDF or image) is added to a designated Google Drive folder. It uses a SplitInBatches node (Loop Over Items) to process incoming files one by one. For each file, it:
    • Downloads the file (Google Drive Get Receipt).
    • Converts it to base64 (Move file to base64 string).
    • Sends the file data and a detailed prompt to the Gemini API (gemini-2.0-flash model specified in the Prompt node, sent via the Gemini API HTTP Request node). The prompt requests structured JSON output with specific fields and formatting (like comma decimal separators, no currency symbols, and a dedicated currency field).
    • Parses the JSON response (JSON to string, Parse string nodes).
    • Appends the extracted data (Invoice Date, Category, Sender, Currency, etc.), along with the original filename and a link to the file, to a specified Google Sheet (Add to Google Sheets).
    • Includes Wait nodes to help manage potential rate limits.
  2. Supplementary flow 1 (Gmail Trigger): An additional trigger (Gmail Trigger) monitors your Gmail account for emails with a specific label. When a matching email with attachments arrives:
    • It loops through emails and attachments.
    • It renames the attachment using the format YYYY-MM-DD_SenderUsername (e.g., 2025-04-19_some.sender) using the Create File Name node.
    • It saves the renamed attachment to the designated Google Drive folder (Google Drive Save Files), which then triggers the core OCR process above.
  3. Supplementary Trigger 2 (Telegram Trigger): Another optional trigger (Telegram Trigger Image) allows you to forward photos of physical receipts to your configured Telegram bot:
    • It renames the image file using the format YYYY-MM-DD_Telegram (e.g., 2025-04-19_Telegram) via the Create File Name For Telegram node.
    • It saves the renamed image to the designated Google Drive folder (Google Save Files 2), also triggering the core OCR process.

Highlight Features

  • Advanced OCR Technology: Uses Google’s Gemini API to recognize and extract data from invoices/receipts with high accuracy.
  • Multi-source Input: Automatically processes files from Google Drive, attachments in Gmail, and images sent via Telegram.
  • Complete Automation: Eliminates manual data entry, automatically transferring extracted data into Google Sheets.
  • Time Savings & Error Reduction: Frees up your time and minimizes common errors associated with manual data entry.
  • Structured Output: Data is returned in the requested JSON format, making it easy to integrate and use.
  • Flexible & Customizable: Easily adjust the prompt, categories, data fields to extract, and configure triggers.
  • Powerful Integration: Connects popular work tools (Google Workspace, Telegram) into a seamless process.

Setup

  1. Credentials: Add the following credentials in n8n, using the names specified in the template or your own:
    • Google OAuth2: For Google Drive, Google Sheets, Gmail.
    • Telegram: For the Telegram bot trigger
    • Gemini API Key: Obtain a free API key from Google AI Studio. You will need to paste this key directly into the Query Parameters of the Gemini API (HTTP Request) node in the workflow.
  2. Google Drive: Create a specific folder in your Google Drive where all invoices/receipts will be stored and processed from. Update the target Folder in the Google Drive Trigger New Files, Google Drive Save Files, and Google Save Files 2 nodes to use your designated folder.
  3. Google Sheets: Create a new Google Sheet, or clone this Sheet template. Ensure it has columns matching the desired output fields (see default list below, including Currency). Update the target Spreadsheet and Sheet Name in the Add to Google Sheets node to point to your sheet.
  4. Gmail (Optional): Create a label in Gmail (e.g., “receipts”). Update the Label filter in the Gmail Trigger node to use the label you created. Consider setting up filters in Gmail to automatically apply this label to relevant emails.
  5. Telegram (Optional): Configure the Telegram Trigger Image node with your bot credentials.
  6. Gemini API Node: Open the Gemini API (HTTP Request) node. In the “Query Parameters” section, replace the placeholder API key with your actual Gemini API Key. Verify the URL uses the correct model name by referencing the Prompt node’s model value (gemini-2.0-flash by default).
  7. Customize Prompt: Open the Prompt (Set) node.
    • Crucially, change the first line “My company is Sisu Digital…” to reflect your company or remove it if not needed.
    • Review the list of categories and the specific formatting instructions (e.g., comma for decimals, no currency symbols, date format, “N/A” for notes) to ensure they match your requirements. You can adjust these details here.
  8. Activate Workflow: Test each trigger path (Drive upload, labeled Gmail, Telegram photo) with sample files/emails/messages, then activate the workflow.

How to customize this workflow to your needs

  • Gemini Prompt/Model: Modify the prompt text, the list of categories, or the detailed formatting instructions within the Prompt (Set) node. You can also change the model value in the Prompt node to use a different Gemini model (ensure the model supports the API endpoint used in the HTTP Request node).
  • Extracted Fields: Modify the prompt in the Prompt node to extract different fields or change formatting. Update the parsing logic in the Parse string node if needed, and ensure your Google Sheet columns match in the Add to Google Sheets node. The default extracted fields (based on the updated prompt) are:
    • Invoice Date: (DD/MM/YYYY)
    • Category: (From predefined list)
    • Sender: (Issuing company)
    • Description: (Brief details)
    • Amount (0% VAT): (Net amount, comma decimal, no currency symbol)
    • VAT %: (Rate number, comma decimal, no % sign, “0,0” if none)
    • Total: (Gross amount, comma decimal, no currency symbol)
    • Currency: (Uppercase abbreviation, e.g., “EUR”, “USD”)
    • Note: (Relevant notes, or “N/A”)
    • (Added by workflow): File Name, File URL
  • Triggers & Targets: Enable/disable or modify the Gmail and Telegram triggers. Select your desired Google Drive folder, Google Sheet, and Gmail label directly within the respective nodes.
  • File Naming: Adjust the Javascript code in the Create File Name (for Gmail) or Create File Name For Telegram nodes to change the renaming pattern. Current formats: YYYY-MM-DD_SenderUsername (Gmail), YYYY-MM-DD_Telegram (Telegram).
  • Configuration Method: Update configuration like folders, sheets, and labels directly within the relevant nodes. For easier management of multiple settings, consider adding a central ‘Set’ node at the beginning of the workflow to define these values and use expressions to reference them in other nodes.

Important Considerations

  • AI Accuracy: AI models can make mistakes. Always review the data extracted into Google Sheets for accuracy, especially with specific formatting like decimal separators. This workflow automates heavily but requires final verification.
  • Gemini API Usage: This template uses the Gemini API via HTTP Request. Be mindful of Google’s API rate limits, usage policies, and potential costs associated with the model used (gemini-2.0-flash by default), especially if you change it. Monitor Google’s terms.
  • Loops and Waits: The workflow uses SplitInBatches and Wait nodes to process items individually and pause execution, which helps prevent hitting API rate limits but processes files sequentially rather than in parallel.

Support Disclaimer

  • This workflow is provided as-is for your convenience. Use it responsibly, and feel free to build upon it for your unique needs!
  • This workflow has been thoroughly tested and is confirmed to be working flawlessly at the time of release. However, setup complexity or unexpected errors may occur depending on your environment, customizations, or API changes.
  • Please note that I cannot offer personalized support or troubleshooting for this template (without a fee!). If you encounter an issue, feel free to send me a message describing the problem. If the issue is determined to be a genuine bug within the shared template, I will do my best to fix it and update the workflow. Otherwise, the issue is likely due to a setup misconfiguration or modification on your side. In those cases, I recommend using ChatGPT or referring to n8n documentation to debug the problem.

FAQ – Frequently Asked Questions

1. Who is this workflow intended for?
This workflow is designed for users who have a basic understanding of n8n and are capable of troubleshooting issues on their own. If you’re familiar with optimizing prompts and handling minor issues, this product is a great fit for you.


2. How is the workflow installed and used?
The workflow comes pre-configured by default, which means you can import and run it immediately. However, to achieve optimal performance for your specific use case or business needs, you may need to customize and optimize the prompts.


3. What should I keep in mind during testing?
During testing, we recommend using low-cost models (such as mini or flash) and generating low-resolution images to save on costs. The primary goal is to ensure the workflow operates reliably before making any further optimizations. Note that the low-cost models may cause error to the workflow.


4. What are the default and alternative AI models?
By default, the workflow uses the GPT-4o model due to its stability and excellent ability to return data in the required JSON format. If you encounter any issues, you can try switching to ChatGPT-4o. Note that some other models (like Gemini Flash) may not return results in JSON format or support tool calls, which could cause the workflow to malfunction.


5. How do I troubleshoot if the workflow fails to run?
Please try the following steps:

  • Run the workflow in an incognito window with all plugins disabled.
  • Try using a different browser (for example, switch from Chrome to Safari).
  • Test on another computer or in a different network environment.
    Keep in mind that issues can stem from various sources, including limitations of the AI model, your self-hosted n8n server, the n8n platform itself, or even your local device or network settings.

6. How can I submit feedback or report a bug?
You can contact us to submit your suggestions, comments, or bug reports related to the workflow and documentation. Every piece of feedback is carefully reviewed to address bugs or incorporate quality improvements in future versions.


7. Is technical support included after purchase?
At present, purchasing the workflow provides you with the file only, without any technical support. In the future, we plan to offer additional support packages, including tutorial videos, technical consulting, and customization services based on customer needs.


8. Can I share or resell the workflow?
Please do not share or resell the workflow without obtaining prior permission from us. The product is protected by copyright, and unauthorized sharing or resale is strictly prohibited.


9. How do I submit feedback on my purchasing experience?
If you have any comments or suggestions regarding your purchasing experience, please send us a message. Your input is valuable to us and will help improve our services and product quality.


10. What is the refund policy?
Due to the nature of the workflow product, our shop does not currently offer refunds for purchases. In the future, we plan to sell our products on platforms that support refund policies. However, please note that the prices on those platforms will be significantly higher compared to purchasing directly from our shop.


If you have any further questions or need additional information, please feel free to contact us through our contact form.

Truly,
AI Automation Pro

Review Your Cart
0
Add Coupon Code
Subtotal