n8n

How to Automate Month-End Receipt and Invoice Pull from Gmail to Drive?

Speed up monthly bookkeeping by pulling PDF receipts and invoices from Gmail and filing them in Google Drive. You choose a date range and an optional email step, and the system sorts and stores the right files for finance work.

A secure webhook starts the run with a start date, end date, and a send email flag. A dated folder is created in Google Drive and the webhook responds right away with the folder link so you can track results. Emails with attachments are fetched from Gmail. Each attachment is checked for PDF, the text is read, and a size check prevents sending very long text to the AI. OpenAI then confirms if a file matches your target phrase, like receipt or invoice, set in the Configure node. Matched PDFs are uploaded to the Drive folder. If the flag is on, the matched files are bundled and sent in one Gmail message to your chosen address.

Set up needs Gmail, Google Drive, and OpenAI credentials in n8n. Adjust Match on, maxTokenSize, replyTokenSize, and your recipient email. Expect faster month end close, fewer filing mistakes, and easier audits. Ideal for finance teams, bookkeepers, and solo founders who get many vendor receipts.

What are the key features?

  • Webhook start accepts start date, end date, and a send email flag, then returns a 202 response with the Google Drive folder link.
  • Creates a dated folder in Google Drive to keep each run separate and easy to audit.
  • Pulls Gmail messages with attachments within the selected date range to limit noise.
  • Filters attachments to PDFs and reads the text content for analysis.
  • Checks text size against a configurable token limit to control AI cost and prevent errors.
  • Uses OpenAI to confirm if the PDF matches your target phrase, like receipt or invoice.
  • Uploads only matched PDFs to the Drive folder, keeping storage clean.
  • Optionally aggregates matched PDFs and sends them in one Gmail message to your chosen address.

What are the benefits?

  • Reduce manual sorting from 2 hours to 10 minutes each month
  • Streamline invoice filing by 80 percent with one run per period
  • Cut misfiled documents by up to 90 percent through AI checks
  • Handle higher email volume without extra headcount
  • Connect Gmail and Google Drive seamlessly with one webhook start

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Gmail, Google Drive, OpenAI and Webhook.site. See the Tools Required section above for links to create accounts with these services.
  3. In the n8n credentials manager, create a Gmail OAuth2 credential. Double click the Gmail nodes and in the 'Credential to connect with' dropdown, click 'Create new credential', then follow the on screen instructions to integrate Gmail.
  4. Create a Google Drive OAuth2 credential. Open the Google Drive nodes, choose 'Create new credential', and follow the prompts to authorize access to your Drive.
  5. Set up OpenAI access. Open the OpenAI node, choose 'Create new credential', and paste your API key from your OpenAI account API page. Name the credential clearly, for example OpenAI Prod.
  6. Configure the Webhook node. Note the webhook URL and set header authentication in the node. Add the expected header key and value so only trusted calls can start the workflow.
  7. Open the Configure node and set Match on, maxTokenSize, replyTokenSize, and sendInvoicesTo. Keep maxTokenSize high enough for typical PDFs and reserve replyTokenSize as shown.
  8. In the Gmail Get emails with attachments node, confirm the date filter fields use the webhook body startDate and endDate values.
  9. In the Google Drive Create folder node, keep the folder location as root or change to a specific parent folder ID if needed. Save changes.
  10. Test the webhook using Webhook.site or a tool like Postman. Send a POST with JSON including startDate, endDate, and sendEmail. Confirm you receive a 202 response with the Drive folder URL.
  11. Run a small test window first. Check the Drive folder for uploaded PDFs and confirm the optional Gmail message arrives with attachments when sendEmail is true.
  12. Troubleshoot common issues: if long PDFs are skipped, raise maxTokenSize; if Gmail returns no emails, review label or date filters; if Drive upload fails, recheck Drive credential; if AI returns false often, refine the Match on phrase to better fit your documents.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Gmail

Sign up

No cost: Personal Gmail (Gmail API has no usage-based pricing; quotas apply)

Google Drive

Sign up

Drive API: $0 (no additional cost; quota-limited)

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

Webhook.site

Sign up

Free tier: $0, public API available; free URLs expire after 7 days and accept up to 100 requests

Credits:
Written by Tom

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.