Skip to main content

Scheduled Jobs

Execute a set of steps on a schedule every minute, hour, day, week or month.

What is a Scheduled Job?

Scheduled Jobs execute business logic across your data sources and APIs on a recurring interval every minute, hour, day, week or month.

Example use cases

  • Email a product usage report from your prod db enriched with Salesforce data every Monday at 9:00 AM
  • Send a message to the #orders channel in Slack every day at 6:00 PM with an order summary grouped by product sold

In this guide we'll schedule a job to send a new user report to email and Slack.

  1. Setup Scheduled Job Frequency
  2. Add Steps
  3. Run Scheduled Job
  4. Manage Scheduled Jobs

1. Setup Scheduled Job Frequency

On the Superblocks Home page, click Create New followed by Create Schedueld Job

Picking your schedule is as simple as creating a recurring event in Google Calendar. Create a job that runs once a week on Mondays at 8:00 AM.

2. Add Steps

Continue setting up the job by adding an integration for the first step. We're going to get information in our users database to start, so let's add a step for Postgres.

info

Adding steps in Scheduled Jobs is exactly the same as defining Superblocks APIs within Applications or Workflows

2a. Postgres

Add a query to select users who have signed up in the past week.

2b. Python

Next, use Python to transform the user data. We can reference the output of the previous getUsers Postgres step, via getUsers.output. Here we use the Python Pandas library to convert the SQL table output to HTML, and separately create a custom message for Slack. Both are returned in a dictionary.

2c. Email

Add an Email step whose Body is the HTML formatted table returned in the previous step

2d. Slack

Lastly, add a Rest API step to post a message to Slack, taking the contents from {{transformData.output.slack_message}}.

note

For API steps that authenticate with Oauth, only headless methods are supported in scheduled jobs.

3. Run Scheduled Job

Your schedulued job is now complete. Click "Run Test" to see the resulting email and Slack message.

Click "Deploy" so the scheduled job now runs on the specified schedule

note

Support for retry logic at specific steps in a job is coming soon.

4. Manage Scheduled Jobs

You can view the results of all your scheduled jobs in the Audit Logs page filtered by Status (Success, Running, Error), Mode (Deployed, Testing) and Triggered by source. In the event that your scheduled job doesn't run as expected, check the audit logs here for any errors. For more information on audit logs, see our audit logs documentation here.