Run a scenario 3 times per day at random times, between 0900 - 1200; 1300 - 1600; 1700 - 2100

Hello,

I’d like my scenario to run 3 times per day, at random times between three different time blocks

once from 0900-1200
once from 1300 - 1600
once from 1700 - 2100

Thanks!

Hello @Ben_Leonard nice to meet you.

All scenarios have Schedule setting panel.
The schedule setting panel lets you adjust the running schedule of the scenario. By default, a scenario runs every 15 minutes, but within this panel, you can customize the run schedule and the interval. For more information you can visit the link Scheduling a scenario (make.com)

Examples:
1.Press the Schedule panel settings:
CleanShot 2024-03-27 at 15.19.59

  1. For your case use Time from → Time:

3.You can add item for all 3 blocks by clicking Add item :

//VLAD

1 Like

thanks but how do I make it random between the times I mentioned?

kind of like the solution here, but 3 different time blocks

It’s a bit more complex than the one in the post you linked, but it can definitely be done :slight_smile:

In this example, I decided to use variable to create the timestamps, making it a bit more convenient to build the stringified JSON structure to make the API call to Make.

I’m starting off from a default schedule scenario:

In my scheduling scenario, I define the variables:

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 2,
                    "module": "util:SetVariables",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "variables": [
                            {
                                "name": "scenarioID",
                                "value": "enter_your_scenario_id_here"
                            },
                            {
                                "name": "timeWindow1",
                                "value": "{{formatDate(setMinute(setHour(addDays(now; 1); 9 + floor(random * 3)); 0 + floor(random * 60)); \"HH:MM\")}}"
                            },
                            {
                                "name": "timeWindow2",
                                "value": "{{formatDate(setMinute(setHour(addDays(now; 1); 13 + floor(random * 3)); 0 + floor(random * 60)); \"HH:MM\")}}"
                            },
                            {
                                "name": "timeWindow3",
                                "value": "{{formatDate(setMinute(setHour(addDays(now; 1); 17 + floor(random * 4)); 0 + floor(random * 60)); \"HH:MM\")}}"
                            }
                        ],
                        "scope": "roundtrip"
                    },
                    "metadata": {
                        "designer": {
                            "x": -346,
                            "y": -38
                        },
                        "restore": {
                            "expect": {
                                "variables": {
                                    "items": [
                                        null,
                                        null,
                                        null,
                                        null
                                    ]
                                },
                                "scope": {
                                    "label": "One cycle"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "variables",
                                "type": "array",
                                "label": "Variables",
                                "spec": [
                                    {
                                        "name": "name",
                                        "label": "Variable name",
                                        "type": "text",
                                        "required": true
                                    },
                                    {
                                        "name": "value",
                                        "label": "Variable value",
                                        "type": "any"
                                    }
                                ]
                            },
                            {
                                "name": "scope",
                                "type": "select",
                                "label": "Variable lifetime",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        "roundtrip",
                                        "execution"
                                    ]
                                }
                            }
                        ],
                        "interface": [
                            {
                                "name": "scenarioID",
                                "label": "scenarioID",
                                "type": "any"
                            },
                            {
                                "name": "timeWindow1",
                                "label": "timeWindow1",
                                "type": "any"
                            },
                            {
                                "name": "timeWindow2",
                                "label": "timeWindow2",
                                "type": "any"
                            },
                            {
                                "name": "timeWindow3",
                                "label": "timeWindow3",
                                "type": "any"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

With this, we can then fill in the stringified JSON in the Make an API call module:

image

{
"scheduling": "{\"type\":\"indefinitely\",\"interval\":60,\"restrict\":[{\"days\":[1,2,3,4,5,6,7],\"time\":[\"{{2.timeWindow1}}\",\"{{2.timeWindow1}}\"],\"months\":[1,2,3,4,5,6,7,8,9,10,11,12]},{\"days\":[1,2,3,4,5,6,7],\"time\":[\"{{2.timeWindow2}}\",\"{{2.timeWindow2}}\"],\"months\":[1,2,3,4,5,6,7,8,9,10,11,12]},{\"days\":[1,2,3,4,5,6,7],\"time\":[\"{{2.timeWindow3}}\",\"{{2.timeWindow3}}\"],\"months\":[1,2,3,4,5,6,7,8,9,10,11,12]}]}"
}

This pushes our scheduling correctly:
image

And it’s visible in my scheduled scenario as well:

Hope that helps!

Thomas - Nola Digital

1 Like

Thanks!!

Ok so bear with me…I want to check I understand. I need to create a new scenario, and paste the first code there to create a ‘tool’ module. And change the scenario ID as appropriate.

what do I do with the second code?

Cheers!

I’m getting closer…

what goes in here?

image

I also get this error " * Referenced module ‘Make - Make an API Call’ [2] is not accessible."

Thanks!