Scheduled actions
Scheduled actions are currently in beta.
Interval supports running actions on a fixed schedule. For example, you might build an action to sync data with an external service that runs every night. This functionality can be thought of as an extremely user-friendly alternative to cron scripts.
info
Scheduled actions are available on our Teams plan and higher. View pricing ›
Configuring schedules
Action schedules are configured in the Interval dashboard. The action must already be deployed to a production environment to access its settings; action settings do not exist in Dev mode.
To access an action's settings, click the Settings icon in the top-right corner of the screen and click All actions. On the next screen, click the Settings icon next to the action you want to configure. Then, click the Schedule tab.
To enable a schedule for an action, the action must first have the backgroundable
setting turned on.
Supported schedules
Actions may be scheduled to run:
- Hourly
- Daily
- Weekly
- Monthly
Handling errors and requesting input
Sometimes, you'll want to throw an error from an action. Just like other actions, when an error occurs, you'll automatically be notified.
Additionally, if your scheduled action requests input via an I/O method, you'll be notified so that you can provide input.
Being able to collect input from a scheduled action makes Interval an extremely powerful tool for cron-style workflows. Traditionally, when an unexpected condition is encountered during the execution of a cron job, you would stop execution, manually resolve the issue and re-run your job.
With Interval, when an unexpected condition is encountered, you can use an I/O method to collect input that resolves the issue, allowing your scheduled action to complete successfully.
Consider this example that syncs data from an external service every night:
- TypeScript
- JavaScript
import { Action, io } from "@interval/sdk";
export default async Action(async () => {
const data = await fetch("<some_external_url>").then(resp => resp.json());
for (let row of data) {
if (!row.email) {
const [, email] = await io.group([
io.display.markdown(`
## An issue was encountered syncing data.
No email was present in the row, provide an email before continuing.
`),
io.input.email("Enter an email:"),
]);
row.email = email;
}
// Now every row is guaranteed to have an email
// We can insert the row into our app's database
}
});
const { Action, io } = require("@interval/sdk");
module.exports = async Action(async () => {
const data = await fetch("<some_external_url>").then(resp => resp.json());
for (let row of data) {
if (!row.email) {
const [, email] = await io.group([
io.display.markdown(`
## An issue was encountered syncing data.
No email was present in the row, provide an email before continuing.
`),
io.input.email("Enter an email:"),
]);
row.email = email;
}
// Now every row is guaranteed to have an email
// We can insert the row into our app's database
}
});
Specifying a runner
By default, the owner of your organization is listed as the runner of any scheduled transaction. Optionally, you may set another user in your organization as the runner.
In most cases, this isn't important. However, the person you choose:
- Receives notifications when an error occurs, the transactions completes, or requires input.
- Is listed as the runner in your organization's transaction history.