Store attachements from Gmail to Drive and send them to a chat

Hey community, experts, pros, all! :wink:

Need some help:

Background: I am currently building an automation that is being implemented in our kindergarten. The kindergarten administration sends out newsletters to all parents with 2-5 file attachments (PDFs, image files, Office documents).

Recently, we introduced Mattermost as a messaging tool to streamline communication and make it more direct. Thus, I have expanded my workflow to ensure that whenever the kindergarten administration sends an email to the parent distribution list (which forwards emails to all invited parents), the message along with attachments should also be posted in a specific Mattermost channel.

Challenge: The main challenge I am facing is that the number of attachments varies, and I am using Google Drive as an intermediate storage solution to provide the files as links. However, I am struggling with retrieving the email attachments (plural) and sending all the files to the Mattermost chat. Currently, I can only send links, and even then only one link at a time. My goal is to forward all attachments from the email.

Current Workflow: The intended workflow is as follows:

  1. Email & Attachments Retrieval:
  • Gmail retrieves incoming emails with the label “Kiga.”
  • Using a loop, I instruct the automation to save all attachments (with filenames) to Google Drive with the “Google Drive Upload” piece.
  • Unfortunately, this approach only works for the first attachment; additional attachments are ignored, and instead, the first attachment is duplicated multiple times on Drive.
  1. Sending to Mattermost:
  • After uploading, I attempt to individually retrieve the files via the “Drive” Get Files action, so I can then send them along with the email body text to the Mattermost channel using the “Send to Mattermost” piece.

Can anyone explain me how to collect multiple files at once (I thought a loop is perfect for it…) and how send to a mattermost (or any other chat) multiple files. I just thought Drive “Read file” in a loop piece would work, but not for me).

As alternative I will also happy to get a kind of template about similar workflow.

many thanks in advance!
Simon

@ashrafsam Maybe this usecase would something for your new planned AI Feature ?

Can you share the flow step setup? The Gmail trigger will return a list of attachments, and it should upload all the files instead of just one.

@kishanprmr thank you ! :wink:

New email recieved with 2 attachements

Now I try to fetch and store the attachements inside a loop with the google drive piece. It shows “2 items” in that list… but it stores just twice the first attachement on google drive.

@kishanprmr Ah ok it works now! IT was my fault - arghh… :wink:

Another question in the same flow…

I want to fetch the files I just uploaded from Google Drive and forward them to a chat (Discord, Mattermost). Special feature: I want to send the files as files and not as url/link. Is this possible and if so, HOW?

So far the files always arrive as such:

Flow:

Another idea of mine would be:
I have to cache the files on Drive on ActivePieces first, so that I can forward them as files. Can you give me some input here?

Many greets
Simon

My first question I could resolved by myself.

How can I send multiple files in one “post” to Discord (as attachments)?

Should I simply refer to the previous “Loop”, which pulls the files from the GoogleDrive folder? I have the problem that I can only send 1 file at a time.

Do you want to send a file in Discord or Mattermost? The Mattermost piece currently only supports the text field. Let me check their API docs and get back to you.

@kishanprmr
To mattermost would be great!

Would be great. I add the API doc for you:
https://api.mattermost.com/#tag/schema

But in general - if I want to send bulk files at once - I need to fetch the payload of the looped piece (in that case the files in a g drive folder) or make this no sense?