Configure startTrigger data for scheduled workflows

Would it be possible to add fixed start parameters to a scheduled/cron workflow?
I'd like to schedule the same workflow at different times, and with different contexts, without needing to modify the workflow.

For example, kicking of workflows that run during business hours of different timezones - the workflow itself doesn't need to change, but each run it needs to look at different data, which could be identified by startTrigger data.

2 Likes

You definitely can! I would look into environment variables for the specified context changes you need. For example, create parameters like timezone, businessHoursStart, and businessHoursEnd, and assign them values for each schedule. You could dynamically set these too based on where these companies are located.

You can then create multiple triggers for your schedules. For each scheduled trigger, provide the parameters or context data needed for that specific instance of the workflow. The workflow can then access these parameters during execution. Once you have this done then you can utilize the parameters.

Hopefully this puts you down the right track and or a retool dev can confirm or deny this haha. Good luck!

Here are the docs.

2 Likes

This is for cloud retool, apologies - I didn't state that earlier.
What I was think was adding a little JSON editor in the scheduling config, such that I could have different JSON startTrigger values for the 12:00am and 06:00am runs.

They use the same workflow, but for each run, I want the workflow looking at a different set of data. As an example, I might to a batch of emails at 12:00am for all my customers in one part of the world, so my startTrigger might be:

{
  "customer_ids": [34, 36, 40]
}

and at the 6:00am run, I'd run the same workflow, but for these customers:

{
  "customer_ids": [12, 13, 16]
}

(as an example)

Hi @hansontools

If you're using static customer_ids for batch data processing in different calls, you can pass them in two separate objects and then filter using the JS block. Alternatively, if the customer_ids are dynamic, you can implement logic to filter them based on the trigger time.

2 Likes

I do this for a workflow that calls in for specific times with dynamic data. Definitely look into what ZeroCodez said @hansontools

Thanks for reaching out, @hansontools. And thanks for all the suggestions, everybody else. :slightly_smiling_face: I do think there's probably a way to get this working - and I'm interested in seeing some of those ideas - but I can see a built-in option unlocking some neat use cases.

I'll talk to the team, see what they think, and update you here when I have news!

3 Likes

Maybe a retool db table with customer_id and hour_of_day. Add a couple blocks at the beginning of the workflow using momentjs to get the current hour and resource query to get the IDs to run.

*edit typo

2 Likes

Lots of workarounds here, thanks folks for contributing!

I solved this problem using cron-job.org, which allows you to invoke a URL (i.e. the workflow trigger URL), include custom headers (workflow API key), and POST custom JSON payloads… at cron schedules you define.

Moreover, cron-job.org has an API, so if you want, you could even build a UI in Retool to list and manage your Workflow cron jobs, and kind of keep it all in Retool

3 Likes