Skip to main content
You can set up a Google Apps Script that monitors a Google Drive folder for new files and automatically sends them to a Parabola flow via email. This is useful when you receive files from external partners or systems that drop files into a shared Drive folder.

Prerequisites

  • A Parabola flow with an Extract from email step configured (you’ll need the generated email address)
  • A Google Drive folder you want to monitor
  • Access to Google Apps Script

Step-by-step setup

1

Set up your Parabola flow

Create a flow with an Extract from email step and copy the generated inbound email address. This is the address the script will send files to.
2

Open Google Apps Script

Go to script.google.com and create a new project.
3

Paste the script

Replace the default code with the following script. Update FOLDER_ID with your Google Drive folder ID and EMAIL with your flow’s generated email address:
const FOLDER_ID = 'YOUR_FOLDER_ID_HERE';       // Replace with your folder ID
const EMAIL = 'example@inbound.parabola.io';   // Replace with your flow's generated email address

function checkForNewFiles() {
  const props = PropertiesService.getScriptProperties();
  const lastChecked = props.getProperty('lastChecked');
  const now = new Date();

  // On first run, just record the time and exit
  if (!lastChecked) {
    props.setProperty('lastChecked', now.toISOString());
    Logger.log('First run — timestamp saved. New files after this will trigger emails.');
    return;
  }

  const folder = DriveApp.getFolderById(FOLDER_ID);
  const files = folder.getFiles();
  const lastCheckedDate = new Date(lastChecked);
  const newFiles = [];

  while (files.hasNext()) {
    const file = files.next();
    if (file.getDateCreated() > lastCheckedDate) {
      newFiles.push(file);
    }
  }

  if (newFiles.length > 0) {
    newFiles.forEach(file => sendEmailWithAttachment(file));
  }

  props.setProperty('lastChecked', now.toISOString());
}

function sendEmailWithAttachment(file) {
  const fileName = file.getName();
  const fileBlob = file.getBlob();

  GmailApp.sendEmail(
    EMAIL,
    `New file added: ${fileName}`,
    `A new file was added to your watched Google Drive folder.\n\nFile: ${fileName}\nAdded: ${file.getDateCreated()}`,
    {
      attachments: [fileBlob],
      name: 'Drive File Watcher'
    }
  );

  Logger.log(`Email sent for: ${fileName}`);
}
To find your folder ID, open the folder in Google Drive and copy the string of characters after folders/ in the URL.
4

Run the script once manually

Click the Run button on checkForNewFiles to initialize the timestamp. This prevents the script from emailing all existing files on the first trigger run. You’ll be asked to authorize permissions — click through to approve.
5

Set up a time-based trigger

  1. In the Apps Script editor, click the clock icon (Triggers) in the left sidebar
  2. Click + Add Trigger
  3. Set it to run checkForNewFiles on a time-driven trigger (e.g., every 5 or 15 minutes)
Apps Script trigger settings

Things to know

  • Large files — Gmail has a 25 MB attachment limit. If you expect larger files, you can modify the script to send a Drive link instead of an attachment.
  • Google-native file types — Google Docs, Sheets, and Slides need to be exported to a format like PDF before attaching. The script above handles standard file types (CSV, PDF, XLSX, etc.), but additional export logic is needed for native Google formats.
  • Polling delay — Google Drive doesn’t support true real-time triggers for file changes. The script polls on whatever interval you set in the trigger (e.g., every 5 minutes).
  • CC yourself on notifications — To receive a copy of each email, add cc: 'your-email@example.com' to the options object in sendEmailWithAttachment.
  • Authentication — You’ll be asked to authorize permissions when you first run the script manually and again when the trigger fires for the first time.
Last modified on March 25, 2026