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
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.
Adding steps in Scheduled Jobs is exactly the same as defining Superblocks APIs within Applications or Workflows
Add a query to select users who have signed up in the past week.
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.
Add an Email step whose Body is the HTML formatted table returned in the previous step
Lastly, add a Rest API step to post a message to Slack, taking the contents from
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
Support for retry logic at specific steps in a job is coming soon.