When talking about automation, it's inevitable to think about tasks and actions to be performed based on time, but also that those tasks might be repetitive on a weekly basis. For instance, switching an irrigation system on every day at 6 a.m., and then switching it off at 7:30 a.m.; or something as simple as sending a reminder every Friday at 4 p.m. to a technician who's responsible for a particular system that needs to be calibrated in order to guarantee its correct operation.
In this article, you'll learn how to create Scheduled Events that will allow executing weekly alerts or actions, enabling your application to automate repetitive actions that should be triggered based on time.
NOTE: This article assumes that you already have a basic knowledge about the Ubidots Events engine. If not, we strongly recommend checking this article before, as some information in this guide may be unfamiliar otherwise.
Requirements
Ubidots licensed account.
1. What exactly are scheduled events?
In practical terms, scheduled events are actions triggered on a regular basis. Their main purpose is to send data, trigger alerts, or execute processes using any of the Event’s built-in actions.
In a single scheduled event you can set multiple schedules, each with its own activation logic and input data, but sharing the same event actions. To that end, scheduled events use a JSON object as the input data for the schedule, letting you send customized data and therefore triggering different behaviors in your application.
2. Setting the trigger conditions
1. To begin, head to the “data” tab →"Events" and hover over the “+” button, located at the upper right corner of the screen, and click on the “add new scheduled event” button.
2. Then, choose the days of the week in which the schedule will be triggered. You can select multiple days.
3. Next, use the “time” field to choose the time at which the schedule should be triggered.
4. Optionally, define the input data that will be sent when the event triggers. Click on the "input data" button to create a JSON object with your desired parameters. This allows you to send data to any Ubidots variables and trigger distinct actions based on this input data. An example of a valid JSON:
{"value":0, "context":{"type":"deactivation"}}
4.1. In case you want to log the input data to an existing variable for control and debugging purposes, you can optionally click on the toggleable button to turn this option on. Choose the variable where the input data will be logged.
4.2. Choose the variable to log the input data to by clicking on the “variable” field and selecting the variable in the modal that opens up.
PRO TIP: Use the "+ Add Schedule" button to create additional schedules with unique data and timing.
3. Choose the actions to trigger
After finishing all the steps in the “triggers” tab and clicking on “next”, you’ll move onto the “actions” tab. There, you’ll be able to select and configure the action that will be triggered when the event is activated.
Click on the “+ add action” button to start this process. These are the options you can choose from:
For a detailed explanation on how each of the actions work and how to configure them, visit their respective article (linked above).
4. Wrapping up
After completing the action configuration and clicking on “next”, you’ll proceed to the final step, the “settings” tab. There, you’ll identify your event.
Start this stage by naming your event and, optionally, giving it a description so that it’s easy to distinguish from other events later on.
Another optional step is to use a tag on the event. This is a great tool to control what your end users see in your app. In this case, for instance, you could decide that your end user sees one event, but not another, using tags. Learn more about tags here.
Click on the “save” button to finish creating the event.