Repeat last module if a condition is met

:bullseye: What is your goal?

I want my automation to search for Gmail emails meeting specific criteria, but if it doesn’t find any, it repeats the search a set amount of time with a set delay between each search, until it finds an email or returns an error.

:thinking: What is the problem?

I haven’t found any way to produce that behavior explained above.

:test_tube: What have you tried so far?

I tried using the “Retry” error handler but it doesn’t work, since the email search returning 0 bundles doesn’t count as an error (if I understood correctly). I could use a If-else module that adds a timer + another Gmail search if the total amount of bundles is 0 but I would like to avoid that if possible?

:camera_with_flash: Screenshots: scenario setup, module configuration, errors

Hey there,

yeah retry is only for errors. This one is not producing any errors so it wont work.

Cleanest one I use is to add a mailhook that only triggers when the corresponding email is received. What is your use case here exactly? What does the whole scenario do?

Hmm this could be a good idea, I will have to look that up. The whole scenario triggers when a PayPal IPN (instant payment notification) is received via a PayPal webhook. Then, it searches for the email that PayPal sends along that payment to retrieve some additional information. This information is then treated with Google Sheets.

Here are the criteria the search is looking for: the email address, the invoice number (retrieved from the IPN), and the transaction ID (also retrieved from the IPN).

I assume using a Gmail webhook would make the IPN unusable? The issue with that is that sometimes I don’t receive any email despite receiving a IPN :thinking:

You could do it backwards. Fire a mailhook when the email is received and then search for the payment in paypal.

Or you could built a secondary scenario that searches for the email and retriggers it self after a delay if the email is not found.

Or you could have an if/else module that checks if the email is found, and if its not, add a delay and check again after some time. Repeat if necessary or add a large enough delay that one is enough.

Thanks for your suggestions! I wish there was a built-in way to repeat the last module but I guess I’ll have to do with workarounds. I appreciate your help!