Coding a Gmail Scenario

Hi all! I have very little experience with make but am attempting to code a scenario that sends recurring emails in gmail. Specifically, the scenario should select all emails in one of my Gmail folders and forward each one to the same email address at different days of the month recurrently. Essentially, all emails in this Gmail folder should be forwarded to the recipient at different days of the month. The order in which the emails within this folder are forwarded is irrelevant.

My current thought process:
(1) use the “watch email” module to select all emails within the folder
(2) use a “tool”, possibly “iterator” to separate each email within the folder
(3) use another “tool” to randomly select an email
(4) send a randomly selected email with the “send email” module
(5) repeat daily

I’m not entirely sure if steps 2 and onwards are feasible or how I would implement them. All help is appreciated! Thanks in advance!

You won’t need step 2 since the outputs from watch email are separate bundles. You can use an aggregator to combine the bundles into an array. From there use the shuffle() function to randomize the order of the array. Then just use the first() function to select the 1 array items from the randomized array and sent the email. Schedule it for daily and that’s basically it.

May I ask what you are using this automation for?

1 Like

Thanks for the suggestions! I’ve added the “shuffle()” and “first()” array functions to the aggregate array module under the Group by drop down menu, separating the 2 with a comma and a line - this appears to work. I then attached a send an email module to the aggregate array module and, in the Content drop-down menu added: “get(array;1)”. Although, upon running it, the code works, it doesn’t appear to be forwarding emails… After turning scheduling “on” and reviewing the log file, it appears the final 2 modules are not actually connected… Do you notice anything?

Viewing in “Diagram”

Viewing in “History”

Thanks again!

You will need to have the “shuffle()” and “first()” array functions setup on the Send an Email module. But you have to map the email from the array aggregator with the map() function before shuffling the array. Can you upload the blue print or show me screen shots of how you have each of the modules setup? Can’t really tell from the screen shots shown.

I’ve attached a screenshot for each of the 3 modules in the scenario:

Thanks for helping!

Your first module needs to have the folder you mentioned mapped.
Your second module is setup incorrectly. For Aggregated Field check off Select All. Delete the text in the “Group By” field.
You last module now needs to map the email from the array on the “To” field. copy and paste this into the To field:
{{get(shuffle(8.array); “1.from.address”)}}
What this does is it will shuffle the array so it will be randomized. Then it will get the first array on that list and retrieve the “address” that is nested under “from” collection.

Hope this helps!

Hey! Last question (hopefully!). I’ve reconfigured the 3 modules and added the line of code you suggested to the “To” section of send email. Unfortunately, whenever I run the scenario once, the following error message appears:

The operation failed with an error. Validation failed for 1 parameter(s).

This error message refers to the send email module. When I expand the error prompt this appears:

Any suggestions?

I’ve also attached a screenshot of the final module below…

Thanks again for helping - really appreciate it!

Guess it got copied weird to the field.
Delete that “1.from.address”
Replace it with this instead:
1.from.address
It needs to be plain text.

Thanks for the suggestion. I replaced “1.from.address” with 1.from.address (this section of the code is no longer formatted and now appears plain). Unfortunately, when I run the scenario, the same error prompt still appears. Any ideas…?

A screenshot of the error prompt is attached below:

Thanks for helping!

Your mapping the “To” field. Switch off the “Map” button. Sorry maybe my verbiage in the previous directions were confusing since I was using the word map.

I tried toggling the “map” buttons on and off in practically all modules and still am receiving the same error notification. I’m relatively sure there’s an issue with the line of code in the send an email module. When I replace this with my email address and run the scenario, I receive an email with no subject and content - but no error…

Is the first module returning any emails? When I myself ran it multiple times it ignores any emails previously pulled. So when you test it you need to choose where to start.

I have selected a start date - but no end date. The 1st and 2nd module appear to be working correctly. In fact, I already have the scenario programmed to send an email daily to my personal email. Since the final module isn’t working correctly, it sends the following email, daily, at the time the scenario is programmed to send the email.

So the first module is returning at least 1 email correct? Not really sure why it wouldn’t work. It works on my end. Here are my settings:
1st module


2nd module

3rd module

Take a look an make sure your scenario is setup the same way.

Thanks for sending me those screenshots! Almost everything was inputted the same apart from the folder in the watch email module. I realize now that the path entered for the get function (1.from.address) is valid only for non-nested folders (at least that seems to make sense - I no longer receive the error notification when I change the folder to a non-nested one). According to the make documentation dot notation should be used in the path of the get function to access nested objects. Do you have any suggestions for how to alter the path so I can use it for a single nested folder - not entirely sure what dot notation means in this context?

Also (unless I’m completely mistaken), the line of code you suggested: {{get(shuffle(2.array); 1.from.address)}} extracts an email address from the shuffled array, nothing else. However, what I actually want to achieve with this scenario is forwarding the content and (if possible) the corresponding subject of an email I have received to myself. Would this required a different path?

Thanks a lot for the help so far (apologies if I didn’t clarify my requirements for the scenario initially).

Even if it’s a nested folder you can still extract the data you need from mapping. The dot lets you “dig” further into the array. You should take some of the training courses Make offers. Particularly the ones that deal with mappings. Mapping is probably the most difficult thing to learn as a beginner in Make but once you master it you will have so much more flexibility in what you can build.

If you want the body of the email and the email, you need to shuffle the array prior to the send email module and use the get function to pick the first array. Then in each field add in the correct mapping to extract the email in the To field and content for the body field.

Hope this helps!