Update Google Drive Files Based on Email Subject

I’m looking to set up a scenario where email attachments are used to update Google Drive files. I have one email inbox which will receive 2 different reports, each with a unique subject line and file name. I want the scenario to update a specific Drive file for each report. For example, my inbox receives 2 weekly emails:

  • subject “Inventory Report” with attachment “Inventory Report.csv”
  • subject “Active Rentals” with attachment “Active Rentals.csv”

I want each CSV to update its respective location on Google Drive. I have done this successfully in the past for a single email to update a single file. Where I’m having trouble now is implementing the conditional routing for different subjects or file names.

Here’s what I have so far:

  1. Gmail filters are set up to move the incoming emails to a label folder “Reports”
  2. Watch Emails looks for folder “Reports”, filter type: Gmail, query: has:attachment is:unread, mark as read when fetched, max results: 2
  3. Iterate Attachments on previous step
  4. Router splits the workflow in two
  5. Each branch to the Drive: Update a File modules has the filter Condition: email Subject = “Inventory Report” or Subject = “Active Rentals” for the correct destination file.

When I run this, the Gmail modules pick up only 1 attachment and nothing gets updated in Drive. What am I missing? Any help would be appreciated.

EDIT: Adding the blueprint and output bundle from the first Watch Emails module. No other modules produced any input or output bundles.
blueprint.json (17.2 KB)
Gmail-WatchEmails_Output.txt (21.9 KB)

Welcome to the Make community!

You didn’t share how your filters are set up, or what the output bundles look like.

If you need further assistance, please provide the following:

1. Screenshots of module fields and filters

Please share screenshots of relevant module fields and filters in question? It would really help other community members to see what you’re looking at.

You can upload images here using the Upload icon in the text editor:
Screenshot_2023-10-07_111039

2. Scenario blueprint

Please export the scenario blueprint file to allow others to view the mappings and settings. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

Screenshot_2023-08-24_230826
(Note: Exporting your scenario will not include private information or keys to your connections)

Uploading it here will look like this:

blueprint.json (12.3 KB)

3. And most importantly, Input/Output bundles

Please provide the input and output bundles of the modules by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.
Screenshot_2023-10-06_141025

A.

Save each bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading them here will look like this:

module-1-input-bundle.txt (12.3 KB)
module-1-output-bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

1 Like

Thanks, I’ve edited my post to add the blueprint and output bundle from the first Watch Emails module. No other modules produced any input or output bundles.

Hello @DCuadra,
From the looks of it, sounds like the “Watch Emails” module only picked up one email and that email only had one attachment.

If you right-click Watch Emails, you have the option to Choose Where to Start.
It may be that the last time it ran, it only picked up one of the two emails because the other was picked up on a previous test run?
You can try using that option and select the first of a pair of these emails and see if that helps grab both of them.

Far as I can tell the Scenario looks good, but maybe @samliew or someone else will have something else to add here.

1 Like

You did not select “Change file content” and map the new file data to replace the old one.

Therefore only the file has been renamed.

Screenshot_2024-05-04_120506

1 Like

Hi guys. Thanks for the input. After some testing, I found that the Gmail: Iterate Attachments step was not necessary and the scenario works when I remove it. Since the Watch Emails step is already pulling 2 records, the Iterate step was redundant.

Setting Watch Emails to screen all available files did let it capture both pending attachments. I had to keep resetting this during testing since every time I did a test run it would revert to “From now on”.

As @samliew suggested, I also needed to add the file name and data mapping in the Drive: Update a File modules to make the content update correctly. Everything seems to be working now.

Thanks!

2 Likes

No problem, glad I could help!

1. If you have a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

others can save time when catching up with the latest activity here, and

  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

samliewrequest private consultation

Join the Make unofficial Discord server!