Pull the trigger - Action, Scheduler!

Automated processes run in two ways: Either they are set in motion by external triggers, such as the arrival of an email in a mailbox; or they run according to "scheme F", i.e. according to a schedule. However, this schedule can be intelligently designed and does not necessarily have to be undemanding. In this case, tracking data is to be read into a core system at different times for each day of the week so that it can be sent immediately to customers as a status message. However, as tracking data arrives well before this time, it must be buffered and may only be forwarded later. Otherwise, trucks would drive off in vain and have to wait for the notified goods. An expensive game in transport logistics.
From Monday to Friday, the transports are to be communicated to the clients of the individual transports with a provision time of 5 p.m. every day. This is handled by our transport management system, which reads the notifications in a specific format. Service provider B sends the messages themselves as Excel lists by email to service provider A, who then converts them into the modern JSON format. The reason: Excel is an opaque, proprietary format for machine processing, even if it has great strengths for the end user on the PC. We reported on this in an earlier LinkedIn article.
On Saturdays, unlike the other working days, the transports should not be reported at 5 p.m., but at 6 a.m. on Sunday, when they are ready. However, the Excel list for these Saturday shipments only arrives on Monday during the course of the day, but should then immediately trigger the status report to the client.

How can this use case be easily implemented? As a leading automation and integration platform, Workato offers so-called "Scheduled Triggers". These are time-based configuration options at the start of a recipe (as Workato calls an automation process). Such a configuration can be, for example, a time every hour or every 10 minutes, but also a fixed time such as 5:15 pm. Of course, the time zone can also be set, which is particularly important in international business.
In the present case, however, a fixed time does not help, nor does a regular time. Instead, a differentiation between weekday and weekend is necessary, followed by a further differentiation between 5 p.m. and 6 a.m.

What would the world be without cron jobs, which are well known under Linux! To ensure maximum flexibility, Workato "Scheduled Triggers" also offer this option. In our case, we create two triggers: A trigger that covers the weekdays Tuesday to Friday 5 pm and starts the recipe at these times. In cron format, this looks like this: 5 17 * * 2-5: Five minutes after 5 pm, every day, every month, on weekdays 2 (Tuesday) to 5 (Friday). Another trigger that covers Saturday and sends the status message with a timestamp of Sunday 6 a.m. on the following Monday as soon as the Excel list has arrived. However, this second trigger should only be triggered on Mondays between 6 a.m. and 9 p.m., but every 30 minutes if a new Excel list has arrived. In cron format: */30 6-20 * * 1. translated: Every 30 minutes, between 6 am and 8(:59) pm, every day, every month, on the weekday Monday.

However, there is another option: instead of a cron trigger, two Ruby functions can also be used in one and the same recipe; one to check the day of the week and then another to check whether it is already 6 am or 5 pm. A lookup action is used to ensure that the Saturday transport is not transferred again on Monday at 5 pm if this was already the case at 6 am.
A little trick is used in the trigger condition: simple Ruby functions are used in the trigger configuration to check whether the array [1, 2, 3, 4, 5] contains the current day of the week (wday) and whether it is 6 am or 5 pm. 1 corresponds to Monday, 2 to Tuesday etc... If this is the case, the delivery of the status messages is initiated.

It is up to the developer to decide which method to use. As a friend of clarity and simplicity, the prudent developer should prefer self-explanatory constructs. The author therefore tends towards the first approach with two recipe calls, i.e. two separate triggers. Although this increases the number of recipes used, it helps the company to recognize the author's intention at a glance even months after commissioning. With this in mind: Pull the trigger!