Skip to main content

Retool Workflows tutorial

A hands-on introduction to Retool Workflows.

Retool Workflows enables you to build, schedule, and monitor jobs, alerts, and ETL tasks. You can automate processes without the need for user interaction and take action based on conditions.

This guide explains how to build a workflow that performs a weekly check for new features added in the latest edge release of Retool. If new features have been added, the workflow sends a notification using Retool Email. You can also trigger the workflow to check at any time with a webhook event.

1. Create a new workflow

Sign in to your Retool organization, select the Workflows tab in the navigation bar, then click Create new > Workflow.

Create a new workflow

A workflow's name is initially set to My First Workflow - Name. Click the name of this workflow in the toolbar and set it to Subscribe to the Retool Release Notes.

2. Configure triggers

You can trigger workflows on a schedule, by sending a webhook event, or by polling a streaming service with a query trigger. This workflow uses two types of triggers:

  • A schedule trigger to run every week.
  • A webhook trigger to manually run the workflow. This allows you to run the workflow at any time.

Click Edit triggers in the startTrigger block to open the Triggers tab.

Create schedule

First, enable the Schedule trigger. Configure it to run every Friday at 5 PM, then click Save changes.

Configure webhooks

Next, enable the Webhook trigger.

3. Fetch release notes

Workflows are comprised of blocks that perform specific actions, such as interacting with data or performing custom logic. You connect blocks together to define their control flow, which represents the order of operation in which they run.

This workflow uses the Resource query block. You would primarily use this to query resources—data sources you've connected to Retool—but you can also use it to interact with APIs and fetch JSON data with the REST API resource.

Retool releases a new edge release for self-hosted deployments every week and publishes the corresponding release notes. You can use the JSON feed of the edge release notes to subscribe to notifications. In this section, you'll subscribe to the release notes and get a list of everything in the added category for the most recent release.

Click and drag from the startTrigger block to create a new block, then select the Resource query block type. Click on the block name and change it to fetchPosts.

This block defaults to the REST API resource with a GET action type. Specify the JSON feed in the URL field.

JSON feed
https://docs.retool.com/data/releases/edge.json

Click Run to retrieve the JSON feed data. The JSON feed contains an array of objects, items, that contain information about each release.

Next, add a JavaScript Code block that gets the most recent post. Click or drag from to create a new Code block. Name this block getRecentPost, and copy and paste return _.first(Object.values(fetchPosts.data)); to return the most recent post.

Finally, add one more JavaScript Code block that returns an array of every change in the added category. Title this block fetchAdded, and paste return fetchLatest.data[0].added into the code block.

4. Check for added functionality

Use the Branch block to perform different actions based on whether the input value meets a truthy condition. Branch blocks allow you to create two different paths for a workflow to take, depending on whether the condition evaluates as true or false. In this case, the workflow needs to check if the most recent release notes contain any features labeled added.

First, click or drag from fetchAdded to add a Branch block, then rename it to containsAdded. In the If statement, specify the following condition: fetchAdded.data.length. This condition evaluates to true if there are any features in the added array.

5. Summarize changes using AI

You can leverage AI in workflows to perform actions, such as summarizing text or generating images. This workflow uses an AI action to generate a summary of changes.

Click and drag from the If statement in containsAdded to add an AI action block, then rename it to summarizeChanges. Select the Generate text action and instruct the AI model to generate a summary.

Instructions
{{ fetchAdded.data }} contains a list of features that Retool added this week. Write me a summary of the added features. Link to the latest edge release notes at https://docs.retool.com/releases/edge for more information.

6. Send an email notification

You can connect many communication platforms and services to Retool, such as Slack, Twilio, SendGrid, and Microsoft Teams.

Finally, the workflow must send an email with:

  • The Self-hosted Retool version number.
  • The AI-generated summary.

You can use Retool Email to send emails without any extra configuration. Click and drag from the AI action block to add a new Resource query block, then rename it to sendEmail. Configure the block with the following values:

PropertyValue
ToThe email address to receive the notification.
SubjectRetool Self-hosted version {{ Object.keys(fetchPosts.data)[0] }}

Finally, set Body to Markdown mode, and include the summary:

Message body
{{ summarizeChanges.data }}

Next, create a new Retool Email block that sends an email if there are no changes in the added category. Click and drag from the Else branch of the containsAdded block. Set the same To and Subject field, and include a summary stating that nothing was added this week: Retool did not add any features in this week's release.

7. Add an error handler

If an error occurs at any point in the workflow, it will fail and you won't receive your weekly update email. Set up a global error handler that sends you an email if something goes wrong. You can use various types of block types as error handlers—in this example, you'll use a Resource query block to send an email.

Open the Blocks menu and drag the Resource query block onto the canvas. The block does not need to be connected to other blocks. Rename the block errorHandler.

Click the ••• menu and select Add global error handler. Next, change the resource type to Retool Email, and configure the block to send an email that tells the recipient that the workflow failed.

8. Test and deploy the workflow

Now that the workflow is complete, you can manually run it to test. Click Run in the toolbar to run the workflow. You can also test the workflow by calling the webhook trigger. To do so, open the Triggers tab and select the Webhook trigger. Click Copy > Copy as cURL to copy a cURL command to run in the CLI.

Copy a webhook cURL command

Run the command to trigger the workflow:

curl -X POST --url "https://api.retool.com/v1/workflows/090bb051-1534-4279-b863-35gfk8223/startTrigger" \
-H 'Content-Type: application/json' \
-H 'X-Workflow-Api-Key: retool_wk_xxxxxxxx'

Workflows run automatically once deployed. If you want to test the schedule trigger and receive notifications automatically, click Deploy in the toolbar.

Wrap up

At this point, you have successfully created a workflow that will keep you informed about the features that Retool adds in every week's edge release.

To continue learning about workflows, explore the guides for other common features: