Filter and PUT Multiple Email Attached Images with HTTP Module

:bullseye: What is your goal?

I need the ability to separate email attachments by file type (pdf vs images). I receive emails from customers that typically have a single purchase order in pdf format, but occasionally have image files included. There could be a single image file or possibly 10 or more. Im all set with the pdf separation path in my scenario as the filtering works just fine for those.

Ideally, I would like to check my existing database to see if the attached email files already exist but am having much difficulty getting the image files parsed in a way that I can filter if they dont exist and then POST them with HTTP, GET the newly POSTed image files and then extracting the file IDs in a comma separated string that is usable for my HTTP PUT module further down the line.

Below is an example of the specific router leg Im struggling with screenshots showing the required information. Disregard the other router destinations as I only wanted to show what the final design actually looks like and didnt know if the routing would make any difference when suggesting a solution.

  1. Webhook - email received with multiple file attachments. (1) Tracking # 1053778 Purchase Order.pdf and (5) Screenshot xxx.jpg

  2. Text Parser - pulls the Tracking # from the email subject as this is the key reference used for all orders

  3. Iterator - pointed to pull all attachments from email

  4. Router - filters added after each leg to separate pdf from image files

     Route 1 - filters by Iterator filename to push pdf attachments here
     
     Route 2 - filters by Iterator filename to push anything that is not a pdf to POST all files with HTTP module.
     I would like to confirm if the email attached images already exist before POSTing duplicate ones, but that isnt a priority right now.
     This was the only way I could get the HTTP module to POST all filtered image files.
     The Sleep module was added to slow the POST as it was too fast and missing images.
     
     Route 3 - Added an Array aggregator to prevent multiple runs for all remaining modules.
     HTTP GET module to pull all database files, including newly POSTed ones in Route 2.  I need a way to find the file ID of either the existing or newly POSTed files text formatted with comma separate string to include all image files matching the email attachments
     HTTP GET module to pull all database orders followed by Iterator > filtered by Tracking # > Aggregator.
     HTTP PUT module that will need to be formatted with JSON below to include comma separated string from previous module
    
{
      "requestingUserID": 792136,
  "customFields": [
    {
      "customFieldID": 709088,
      "name": "Attachments/Photos",
      "attachmentIDs": [fileID1,fileID2,fileID3,fileID4,fileID5],
      "isHidden": false
    }
  ]
}

Sorry, for some reason I cant paste screenshots here and the file upload only accepts one file.

:thinking: What is the problem & what have you tried?

No matter what Ive tried, I cannot gather and filter the file IDs to be aggregated into a comma separated value to be use in the HTTP JSON coding. Ive used various combinations of Iterators, Array aggregators, Text aggregators, HTTP modules. Just when I get some early modules to do something, adding iterators or aggregators makes them disappear to following modules.

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

Sorry where are you trying to send the files? What does the documentation say about multiple files?

Hi Stoyan

The database I use is FMX and their API documentation requires I add multiple file ID’s separated by commas in order to PUT them to an existing work order already built in the platform.
```

{
  "customFieldID": 709088,
  "name": "Attachments/Photos",
  "attachmentIDs": [fileID1,fileID2,fileID3,fileID4,fileID5],
  "isHidden": false
}

The issue is I dont have the FMX file ID’s until I POST them from the email image attachments. So I would like 1. a way to filter if the email attached images already exist in an FMX HTTP GET module and then 2. POST them into FMX if they do not already exist. 3. I need to then extract the newly created FMX file ID’s and format them fileID1,fileID2,fileID3 etc that will then be selectable in the HTTP PUT JSON code above. You helped me out earlier this week with a text aggregation issue that I needed to do something similar with multiple fileID’s

However I tried to replicate this but I could not get it to work, Im assuming because of this scenarios particular pattern and placement of iterators and aggregators.

Thanks

Anyone out there that can assist? I know there is something stupid Im missing or not understanding how certain Make modules work. Or maybe Im asking something very complex? Either way, finding a solution to this problem would go far with other parts of my scenarios where I need to do similar things. But Im not that advanced yet in Make and am running against deadlines. I appreciate anything that could help me get past this roadblock for me.

Thanks