Skip to main content

Scheduled Jobs Overview

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.

Set up Scheduled Job frequency

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

Schedule a job to run every minute, hour, day, week or month for reporting or ETL

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.

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

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.

Scheduled job steps allow you to query data sources or execute code on a schedule

info

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

Postgres

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

Supply a Postgres step with SQL to select data from a users table where date joined is within last seven days

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.

Create a transform data python step to process the data from the database and return a Slack message

Email

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

The Superblocks email integration can send emails with customized bodies to lists of recipients

Slack

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

The Superblocks REST integration can send calls to third party services including sending messages into slack channels

info

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

Run Scheduled Job

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

Final formatted report received via email

Slack message formatted as required and sent to chosen slack channel

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

Successfully deployed jobs will be run on the specified schedule and run against production environment settings

info

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