Automate Text Extraction from PDFs & Images with n8n and Vertex AI

This n8n workflow automates extracting text from PDFs and images uploaded to Google Drive using Vertex AI and an AI chat model. It converts the extracted data into categorized CSV files, saving hours of manual data entry and categorization errors for users handling financial or transaction documents.
googleDriveTrigger
lmChatGoogleGemini
extractFromFile
+5
Workflow Identifier: 1100
NODES in Use: Google Drive Trigger, Switch, Google Drive, Extract from File, HTTP Request, Convert to File, Google Gemini Chat Model, Chain LLM
Automate text extraction with n8n and Vertex AI

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What This Workflow Does

This workflow watches a Google Drive folder for new PDF or image files.
It then extracts transaction text from these files.
After extracting, it uses AI to organize the data into CSV files with category tags.
The CSV files are saved back to Google Drive.
This helps remove slow manual data entry and speeds up financial reporting.


Who Should Use This Workflow

This workflow is useful for anyone handling many bank statements or receipts as PDF or image files.
Users who need fast, automated extraction and sorting of transaction data will benefit most.
No advanced technical skills are needed to run the workflow after setup.


Tools and Services Used

  • n8n Automation Platform: Runs the workflow.
  • Google Drive: Stores input documents and output CSV files.
  • Google Cloud Vertex AI (Gemini model): Extracts text from images.
  • Openrouter API: Parses PDF text via AI to CSV.
  • Google Service Account: Grants n8n access to Google Drive and Vertex AI.

Inputs, Processing Steps, and Output

Inputs

  • New PDF or image files uploaded to a specific Google Drive folder.

Processing Steps

  • Detect new file in Google Drive folder.
  • Identify if file is PDF or image using MIME type.
  • If PDF, download and extract raw text from file.
  • Send extracted PDF text to Openrouter AI for parsing into categorized CSV data.
  • If image, download and send to Google Vertex AI (Gemini) to extract text.
  • Use AI prompt to parse image text into categorized CSV format.
  • Convert AI returned text into CSV file format.
  • Upload CSV file to a specified Google Drive folder.

Output

  • Structured CSV files with transaction data and assigned categories saved in Google Drive.

Beginner Step-by-Step: How to Use This Workflow in n8n

Importing and Setup

  1. Download the workflow file using the Download button on this page.
  2. Open your n8n editor (self-host or cloud-hosted).
  3. Click “Import from File” and select the downloaded workflow file.
  4. After import, add your Google Service Account credentials in the Google Drive Trigger and related Google Drive nodes.
  5. Enter Openrouter API Key credentials in the HTTP Request node for AI parsing.
  6. Update folder IDs, service account emails, or file paths in node settings if different from defaults.
  7. Check the AI prompt JSON in the HTTP Request node and copy/paste it exactly if needed:
  8. {
      "model": "meta-llama/llama-3.1-70b-instruct:free",
      "messages": [{
        "role": "user",
        "content": "You are given a bank statement.{{encodeURIComponent($json.text)}}. Read the PDF and export all the transactions as CSV. Add a column called category and based on the information assign a category name. Return only the CSV data starting with the header row."
      }]
    }

  9. Test the workflow manually by uploading sample PDF and image files to the configured Google Drive input folder.
  10. Check the output folder for the generated CSV files.

Activating for Production

  1. Toggle the workflow to “Active” in n8n.
  2. Keep the workflow running (cloud or self-host n8n) to ensure continuous file monitoring.
  3. Monitor workflow executions in the n8n dashboard for any errors.

Common Problems and Failures

  • Google Drive Trigger does not detect new files.
    Cause: Folder missing share permissions for service account.
    Fix: Share the folder with the Google Service Account email with Editor rights.
  • HTTP Request node returns 401 Unauthorized.
    Cause: API Key is missing or invalid in Openrouter’s HTTP Header Auth.
    Fix: Update the API Key in credentials and test again.
  • Vertex AI fails to extract text from images.
    Cause: Vertex AI API not enabled or service account lacks proper roles.
    Fix: Enable Vertex AI API and assign roles in Google Cloud Console.

Customization Ideas

  • Change the watched folder ID in Google Drive Trigger to any folder you want.
  • Edit the AI prompt in the HTTP Request node to extract more details like merchant names.
  • Add conditions in the Switch node to support TIFF or other file types.
  • Insert Email nodes after uploads to send file processed alerts.
  • Use Google Gemini models for PDF text parsing by replacing Openrouter with Vertex AI nodes.

Summary of Benefits and Results

✓ The workflow saves many hours weekly by removing manual entry.
✓ It reduces errors by letting AI categorize transactions.
✓ It puts clean CSV files automatically into Google Drive.
✓ It allows users to focus on analysis instead of data entry.
✓ The workflow is easy to set up and activate with no coding needed.


Automate text extraction with n8n and Vertex AI

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

The Google Drive Trigger node can miss new files if the monitored folder is not shared with the service account. Ensure the service account has Editor permission on the folder.
The error occurs when the Openrouter API Key is missing or invalid. Update the Openrouter API Key in the HTTP Header Auth credentials for the HTTP Request node.
Vertex AI fails if its API is not enabled or the service account lacks necessary roles. Enable Vertex AI API in Google Cloud Console and assign correct roles.
Yes, but the HTTP Request node configuration must be adjusted to match the different provider’s API requirements.

Promoted by BULDRR AI

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.