Cómo guardar adjuntos de Gmail en Drive con n8n (Full Transcript)

Crea un flujo en n8n que detecta emails por palabra clave, descarga adjuntos y los sube a una carpeta de Google Drive automáticamente.
Download Transcript (DOCX)
Speakers
add Add new speaker

[00:00:00] Speaker 1: If you've been thinking about dipping your toe into learning how to create N8N automations, but you're not sure where to start, let's take a look at one automation that's simple to build and useful to everyone. We've probably all been in a situation where we need to collect files from a group of people. Maybe it's receipts from a trip, tax documents from family members, invoices from contractors. Whatever it is, you just need everyone to send you a file. And that's where things usually get a little messy. You could set up a shared folder and send everyone a link, but there's always someone who says they can't upload, they're not sure how it works, or they're on their phone and it's confusing. But just about everyone knows how to attach a file to an email. So instead of trying to teach people how to upload to a shared folder, you could just say, email me the file and include this one keyword in the subject line. Hi, I'm Garak, and in this video, in partnership with our friends at Hostinger, we're going to build a simple N8N automation that watches your inbox for that keyword, automatically grabs the attachment, and drops it into a shared folder for you, all on its own, running 24-7. And along the way, we'll see how accessible N8N really is. To build this automation, I'm going to be using an N8N installation running on Hostinger, but what you see in this video will work on any N8N instance. If you would like to follow along using Hostinger, point your browser at hostinger.com slash start N8N. Under services, select self-hosted N8N to see the current plans and prices. If you're just getting started, the entry-level KVM1 and KVM2 plans are more than powerful enough to run basic automations and workflows, so I suggest starting there, with KVM2 offering the best value in that range, since it doubles everything in the KVM1 plan for a few dollars more per month. And if you eventually start running complex processes or need to handle a higher volume of triggers, you can always upgrade for additional RAM, storage, and CPU power to keep your automations running smoothly. Just click choose plan, and make sure you have the 24-month option selected for the best value. For even more of a discount, click have a coupon code, and enter start N8N for an additional 10% off. Once you've run through the setup steps, you'll see your Hostinger dashboard. Under VPS, select the server where you installed N8N, and click manage. Then click manage app. On the overview page, we see several pre-built templates for various workflows we could customize for ourselves, but for this exercise, we're going to build ours from scratch, so I'll click create workflow. This gives us a completely blank canvas with just this add first step button we can use to add the initial trigger for our workflow. So again, for this workflow, we want our N8N to monitor our inbox for emails with a specific keyword in the subject line, then grab the attached file from the email and drop it into a folder for easy access. So let's add the first step of this workflow by clicking add first step, which opens this panel to the right, asking what will trigger this workflow to start. And this is where you'll see a variety of trigger types—manual triggers, app triggers that react to events like receiving email, schedule-based triggers, webhooks, and more. More often than not, though, you'll probably just search for the trigger you want to use in the search nodes field. So in this case, I know I want the workflow to go into action when it sees a new message come into my Gmail account, so I'll type Gmail. I'll select the Gmail result, and we can see that we have one trigger available, which is on message received. Let's select that to add it as our first node. And that takes us into the node parameters and settings where we can specify how it behaves. For example, under pull times, you can specify how often the workflow checks your email. The default is every minute, which is probably the best one to choose, so the workflow will grab any new attachments within a minute of you receiving them. But you can see the other options available here. Below that we have event, which is the actual Gmail activity that triggers the workflow, and it's set to message received, which means the workflow runs whenever a new message arrives. Now, most importantly, in order for this workflow to work, the node has to have access to your Gmail account. This is set up here at the top under credentials to connect with. Now, I've already set up my Gmail account here, but if you haven't done so already, you would click create new credential. Basically, to give the workflow access to our Google account, we're going to connect using the OAuth2 authentication method. Notice these two fields here labeled client ID and client secret. So instead of just giving N8n your Google password, which would be pretty insecure, OAuth2 lets you create a special set of secure keys. Now again, I've already done this with my own Google account, but if you're not familiar with how to do this, I'll put a link to a previous video I did on N8n where I walk through the process step by step. But keep in mind that the Google Cloud Console interface is always changing, so you might instead try doing a search for N8n Gmail OAuth setup Google Cloud Console to make sure you get the most up-to-date information. It is a one-time process, and once it's done, you can reuse your credentials in any workflow you build. Basically, once you went through that setup, you'll be given the client ID and client secret information to paste into here. Again, I've already done that, so I'm just going to cancel this for now. And I already have my Gmail account that I've authorized selected here under credential to connect with. And again, your credentials will always be available to any workflow you create once you've set it up the first time. So if I leave everything as is and close this for a moment, you can see that we've now added our first node or trigger. Now, an issue with this trigger that we just added is that currently it's set up to be triggered by any email that comes into this account. We only want it to be triggered by a specific keyword in the subject line. So let's double-click this and go back into its parameters. And here at the bottom, I'll click add filter. For the type, I'll choose search. And let's say that the keyword I want people to put in the subject line in their emails to me is receipt 2026 in all caps. So in this field, I'll type subject colon receipt 2026 in all caps, and then has colon attachment. So here we're using Gmail's built-in search syntax. It tells N8n to only trigger when an email contains our keyword in the subject line, and it includes an attachment. Now, if you want to play it extra safe, you could also add is unread. Now, technically, because this trigger checks Gmail every minute, it'll only process new messages that match that filter going forward. But adding is unread gives you an additional safeguard in case something gets rechecked later. Now, I can test this by sending myself an email that has the keyword in the subject line and which has an attachment. I'll do that from another computer right now. I'll give that a second. And now I'll click fetch test event. And if you don't see any errors and instead see something like this in the output area, you know that it's working. All right, so that's all we need for this trigger configuration. Let's close this and go back to the workflow canvas. Okay, we've now configured our first trigger to detect incoming emails with our keyword and that have attachments. This trigger's job is just to detect the email quickly, but it doesn't automatically pull down the full attachment data. So next, we need to add a step to fetch the message and download the attachment so we can then pass the file to Google Drive. I'll click the plus button here to the right to add another node. And we'll search for Gmail again. And here we'll select get a message. Again, since we have previously set up the Gmail credential, it's already selected here at the top and we don't need to enter that again. The resource and operation settings are also correct because they're set to get a message. Now, the message ID field is currently showing the ID of the test message we sent earlier. But we want this node to work for any new email that triggers the workflow, not just this specific message. So in the message ID field, we'll use the simple n8n expression. Now, don't let this scare you. This just tells the node to fetch the exact message that triggered the workflow. Next, I'm going to turn off simplify so we can see more settings. And here we'll select download attachments and make sure it's enabled. And we can test this by clicking execute step. And I can see that I configured it correctly because I can see the file name of the file I attached to the test email. So now we can close this window and go back to our workspace again. All right. So our workflow is now set up to access my Gmail account and detect any new emails that have both the keyword and the subject line and which have an attachment. Next, we want to have n8n automatically pass the attachment to a Google Drive node and tell it where to store it. I'll click the plus button next to our second node. And here, I'll search for Google Drive and select it. Now, if you wanted to use another cloud service like Dropbox or OneDrive, you could search for and select them from here instead. But in this case, I'm using Google Drive and we want to choose upload file. And now we just need to configure this node. At the top, again, I've already created my Google Drive credential, so it's already selected. If you haven't done that already, you'll need to create a new credential. And I'm going to leave the default selections under resource and operation since we're uploading a file. Now, under input data field name, we need to tell Google Drive which file to upload. Over here on the left with binary selected, we can see the attachment is called attachment underscore zero. So that's how Google is identifying attachments to the emails. So that's what I'll type in this field, attachment underscore zero. But if you see something else here under binary, be sure you enter the name you see and not attachment zero in this field. All right, next, we need to tell Google Drive where to save the file. Under parent drive, I'll leave the menu set to my drive, which is the main Google Drive folder. Under parent folder, I'll click the menu and here I'll find a folder called 2026 receipts that I previously created in my Google Drive. All right, and now I'll click execute step. And again, if everything is configured correctly, I won't see any error messages. And now if I go to my Google Drive and I look in my 2026 receipts folder, there's the receipt from the email. So this node is now working, which means our entire workflow should now be working. So let's test it out. I'll go back to the main workflow canvas. And I'll quickly send myself another email with the keyword in the subject line and with an attachment. And I'll click execute workflow, which will run the entire workflow. And after just a few seconds, we see that the workflow was successfully triggered. And if I go back to my receipts folder on Google Drive, there's the attachment from the most recent email. And that's it. I didn't download anything. I didn't drag any files. I didn't manually upload anything. I just sent an email with a keyword and within a minute, the attachment was automatically organized for me. Now, the last step is to make sure this workflow runs automatically going forward. So I'll come back here to the workflow and I'll click publish. Your button might be labeled activate in some cases, but here I'll click publish. And now this workflow is live and actively running, which you can see by this confirmation message here. Your workflow will now regularly check Gmail for events and trigger executions for them. So from now on, any email I receive that includes the keyword in the subject line and has an attachment will be automatically saved 24 seven. So this wasn't a complicated workflow. We didn't write code. We didn't build a custom upload portal. We just connected a few simple building blocks together. Instead of asking people to change their behavior or force them to learn a new tool, we built an automation around what they already know how to do. Send an email with an attachment. And once this workflow is published, it just runs quietly on your server. Every time someone includes that keyword and attaches a file, it's automatically collected and organized for you. And that's the power of N8n. It doesn't have to be about building massive, complex systems on day one. As you just saw, you can start with one practical workflow that immediately saves you time and then build from there. From the workflow we just built, you could expand in lots of useful ways. You could automatically rename files with the sender's name and date. You could sort receipts into monthly folders. You could send a confirmation reply when a file is received. You could even add an AI step to summarize or categorize the email before storing it. But even without adding on, we've already built something pretty useful. If you'd like to try this for yourself, visit hostinger.com slash start N8n to check out their self-hosted N8n plans. Once you build one automation like this, you'll start seeing opportunities everywhere. And if you found this video helpful, be sure to like and subscribe and search our channel for more N8n tutorials. So until next time, I'm Garrick, thanks for watching, and we'll see you soon.

ai AI Insights
Arow Summary
El video muestra cómo crear una automatización sencilla en n8n (instalado en Hostinger o cualquier instancia) para recopilar archivos por correo: vigila Gmail en busca de un mensaje nuevo cuyo asunto contenga una palabra clave (p. ej., “RECEIPT 2026”) y que tenga adjuntos; luego obtiene el mensaje, descarga el/los adjunto(s) y los sube automáticamente a una carpeta específica de Google Drive. Explica la configuración del trigger “On Message Received”, el uso de filtros con la sintaxis de búsqueda de Gmail (subject:, has:attachment, opcional is:unread), la autenticación OAuth2 con Client ID/Secret, el nodo “Get a message” con descarga de adjuntos, y el nodo de Google Drive “Upload file” apuntando al campo binario (attachment_0) y a la carpeta destino. Finalmente, se prueba el flujo y se publica/activa para que corra 24/7, y se sugieren mejoras como renombrar, clasificar por meses, enviar confirmación o añadir IA.
Arow Title
Automatiza la recolección de adjuntos: Gmail → Google Drive con n8n
Arow Keywords
n8n Remove
automatización Remove
Gmail Remove
Google Drive Remove
adjuntos Remove
OAuth2 Remove
Hostinger Remove
workflow Remove
filtro de Gmail Remove
subject Remove
has:attachment Remove
is:unread Remove
On Message Received Remove
Get a message Remove
Upload file Remove
self-hosted Remove
Arow Key Takeaways
  • Usa un trigger de Gmail en n8n para reaccionar a emails nuevos.
  • Filtra con la sintaxis de búsqueda de Gmail: subject:PALABRA_CLAVE y has:attachment (opcional is:unread).
  • Configura OAuth2 (Client ID/Secret) en Google para conectar Gmail/Drive de forma segura.
  • Añade un nodo “Get a message” y habilita la descarga de adjuntos para obtener el binario.
  • Sube el archivo a Google Drive con “Upload file”, indicando el campo binario (p. ej., attachment_0) y la carpeta destino.
  • Publica/activa el workflow para que corra automáticamente 24/7.
  • Extensiones posibles: renombrado, carpetas mensuales, respuesta automática, clasificación con IA.
Arow Sentiments
Positive: Tono didáctico y entusiasta; destaca la simplicidad, accesibilidad y el ahorro de tiempo, con llamadas a la acción para probar Hostinger y seguir aprendiendo n8n.
Arow Enter your query
{{ secondsToHumanTime(time) }}
Back
Forward
{{ Math.round(speed * 100) / 100 }}x
{{ secondsToHumanTime(duration) }}
close
New speaker
Add speaker
close
Edit speaker
Save changes
close
Share Transcript