The solution above is an hallucinated AI post and incorrect on many points. Zynate has been warned about this before and can now no longer post on this forum.
Hey @WISE825 hope all is well. Welcome to the community.
I see you are looking to automate changes to file on your local computer (meaning not the files which are local to the n8n container or remote system.
Since n8n doesn’t have access directly to your computer’s file system, I can think of two ways to go about it.
you can run a local script, which would be monitoring for changes on your computer and call the webhook in n8n (if you want to use n8n for the rest of the scenario).
if you are running a self-hosted setup of n8n, you can mount the folder where the new files are created to the n8n within your docker-compose.yaml file.
You run a sync with some cloud storage, and then n8n needs to only integrate to that cloud storage for monitoring.
The second approach is easier, because in that case you can use the Local File trigger, but this will only work if you self-host.
If you wish to use the first approach, the code for the monitor could look something like this (I’ll use python for this example):
import time
import requests
from pathlib import Path
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
WEBHOOK_URL = 'https://your.n8n.url/webhook-test/filemonitor'
WATCHED_FOLDER = '/your/folder_to_monitor/'
class PdfCreatedHandler(FileSystemEventHandler):
def on_created(self, event):
if event.is_directory:
return
file_path = Path(event.src_path)
# Trigger only for .pdf files
if file_path.suffix.lower() != ".pdf":
print(f"Ignored non-PDF file: {file_path.name}")
return
print(f"New PDF detected: {file_path.name}")
# Optional: small delay to ensure file is fully written
time.sleep(1)
try:
with open(file_path, "rb") as f:
files = {"file": (file_path.name, f, "application/pdf")}
response = requests.post(WEBHOOK_URL, files=files)
if response.ok:
print(f"Uploaded: {file_path.name}")
else:
print(f"Upload failed: {response.status_code} - {response.text}")
except Exception as e:
print(f"Error handling {file_path.name}: {e}")
if __name__ == "__main__":
path = Path(WATCHED_FOLDER)
if not path.exists():
print(f"Folder does not exist: {WATCHED_FOLDER}")
exit(1)
print(f"Watching folder for new PDFs: {WATCHED_FOLDER}")
event_handler = PdfCreatedHandler()
observer = Observer()
observer.schedule(event_handler, path=str(path), recursive=False)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
Then in the workflow you can create a webhook, and accept the event on post requests. The requests will include the file itself. From here you can do whatever you want with the file and build what ever logic (below is the most simple example):
In case you wish to mount the folder or do the cloud sync - let me know and I will help you with the setup.
No problem, in case you wish to go with cloud sync route and monitor your files on Google Drive, you would need to start with a Goole Drive Trigger node and configure it to monitor for File Created events:
When the even happens, the trigger will yield data, which you can use in later nodes. One such piece of important data will be the file’s id, what you can do is put a Download node right after to fetch the new file. After that the workflow is the same - you have a binary with the name and then you can introduce any logic you want to route the file to the required recipient.
Great ! Just out of curiosity, how does the system figure out who each document should be sent to? How does that part work? Let me explain — each PDF is basically a payment receipt that I need to send out to multiple people once a month. So if I had two files in the same folder, either locally or in Google Drive, named “Mario_Gomez.pdf” and “Mario_Gonzalez.pdf” , how would the system know which one to send to which person?
The logic is for you to define. You can build a sheet with prefixes to query when the file needs to be sent, of you can create a Code node to find the matching email, if there are not too many. The logic could range from “if the file name starts with send it to email , if the file name start with send it to email ” or it could be a more complicated system where the value is extracted from the PDF itself, it is basically up to you.
In my example above I sent with the most simplest route - in the Edit Fields node, I am setting the recipient with either one of TWO emails based on the prefix of the file. In your case, I assume there is more than two recipients, so you will probably want to come up with a more manageable solution - like a database or a sheet.
Thanks again for your answer, your advice really helped me get started! I decided to go with Google Drive , Google Sheets, and Gmail for this setup. I’ve already created all the credentials, but I’m still not sure how I should connect the nodes properly.
Is there a node that lets me filter the files before sending them? I thought maybe I had to use the Edit Fields node… but now it’s a mess lol.
There is a Filter node if you wish to filter something out. If you want me to take a look at the workflow, please explain the logic you came up with and attach the workflow here.
Hi! Sorry for the delay, I wanted to push forward on my own as far as I could. Now I’m sending everything over.
So the idea is still the same as before, but now the PDF files I want to send will be stored in a Google Drive folder, and I’ll be using a Google Sheets document to send each file to the right employee.
There are about 100 employees, and the plan is to send each file to their Gmail address.
I’m not sure if I’m on the right track, but if you’re still around—thank you so much for helping me out You’re a hero without a cape!
Hey @WISE825 great job, definitely on the right track there, it is working already, the only thing I would probably change is … instead of pulling all rows from the sheet, I would use the filter and pull only the one that you need. Pulling other 99 rows is just waste of bandwidth and memory.
Hi, I was working on other tasks for a while, and when I returned to the workflow, this error showed up in Google Drive Trigger. After doing a bit of research, I assumed it was because my OAuth credentials had expired after seven days .
The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.
Error code
EAUTH
Node type
n8n-nodes-base.googleDriveTrigger
Node version
1 (Latest)
n8n version
1.102.3 (Self Hosted)
Time
31/7/2025, 11:19:54 a. m.
So does that mean I need to create new credentials every time I want to change my workflow, every seven days?
Also, I understand that for a company to work with this workflow, they need to have a Google Workspace account, right?
I did it, It was easier than I thought. But now my issue is, why does it only let me send one email at a time? It’s like the trigger only detects the last PDF uploaded to Drive, but not if I upload several. Where could the problem be?
I actually tried uploading the same PDFs with a slight change in the file name, and I’m not really sure if this just started happening or if it’s been like this and I hadn’t noticed. But the issue is that only one of the files I uploaded gets sent
Slight change in the name is not updating, it’s creating event for the trigger. Also make sure you are testing with activating the workflow and not with firing it manually. Manual tests sometimes only pulls part of the data (like one example).
Ok, let’s start from the beginning, you want to find new pdfs uploaded, then based on the file name, find email address to send this doc to and send it, right?