Question

How do I Loop and trigger Zap based on labeled email attachments?

  • 4 July 2023
  • 1 reply
  • 107 views

I have a Zap which simply uploads an attachment from my email to Google Drive. However, I specifically want to trigger it based on putting a label on the mail, not trigger for each attachment as I add the label manually after having received the email. Without the Attachment trigger, it seems impossible to loop over the attachments individually. 

I considered everything:
- Can I have a double trigger, first trigger on label then attachments → No, other way around is possible with filter but that won't trigger as I don't add the label on receiving the email.
- Can I use webhooks to chain triggers → No because the trigger of the second webhook must be the first webhook, so you still can't add another trigger.
- Can I somehow loop over the Attachments field → No because it is a single URL that hosts all documents

My last effort was to loop by number over Attachment Count. That atleast gives me the right amount of loops, however, I can't actually change the input between loops. I can set the File to Attachment 1, but that can't be updated to Attachment 2 on the second loop because I can't do “Attachment ” + LoopCount. Kinda makes the looping logic pointless to me if you can't make the input data variable. I also don't know how many attachments I will have, so I can't just copy paste for every item. 

So my question is, how do I make it such that the below field is updated to “Attachment 2 Attachment” on the next loop etc…?

 


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 7
Badge +11

Hi @JelleFm, welcome to the Community!

Hmm, that’s a tricky one! I’m wondering if you could use custom pill mapping in a Formatter (Utilities > Line Itemizer) action for this. Custom pill mapping it’s a way of manually referencing fields that aren’t in the selected sample. So say the testing sample in the Zap only has 2 attachments, you’d select the potential 3rd attachment fields by manually writing out the name of the field, in a specific way, so that when the Zap runs it would be able to loop through the third attachment if it’s present.

For example you’d type in {{nodeid__attachment_3__filename}} and {{nodeid__attachment_3__attachment}} into Formatter (Utilities > Line Itemizer) action. And replace the nodeid part with the relevant NodeID for the Zap. You can find out more about where to find that nodeid value in the following guide:


So I’m thinking you’d set up the Formatter action like so:
a9c9e6bf38bb6c995afa287034d31628.png
You’ll notice that there’s an exclamation mark next to the two fields I manually typed in, that’s due to those fields not being present in the trigger sample. But when the Zap runs if there’s 3 attachments then it should be able to select the name and file for the third attachment and add it to the line items that it generates. I’m not sure what the maximum number of attachments would be but I’d suggest manually typing in the field names for as many as might be present, swapping out the number in the field name to match the attachment number you’re wanting to reference.

Then you’d select those line item properties to be used for the loop. And the loop should ignore the blank fields for attachments that aren’t present. So if an email that triggers the Zap only has 2 attachments only 2 will be added to the loop. And if an email that triggers the Zap has 3 then 3 will be added to the loop.


Does that approach sound like it would do the trick? If I’ve misunderstood what you’re wanting to do here or if you encounter any issues on setting that up just let me know!