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.
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.
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.
- AI action
- AI response
{{ 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.
AI-generated content may differ from the example below.
This week, Retool introduced several new features and enhancements:
1. **Typography Enhancements**: New rebrand fonts were added, alongside newly created typography components specifically for the sign-in page.
2. **NFC Tag Support**: Users can now read and write NFC tags within the platform.
3. **Semgrep Testing Support**: The platform now supports testing for writing `semgrep` rules.
4. **Action Mirroring**: Functionality was added to support mirroring actions that affect the app template.
5. **Global Split Pane Rendering**: Children of a global split pane can now be rendered across all pages.
6. **Cypress Enhancements**: New tabs have been added to the Cypress testing editor for improved usability.
7. **Global Component Tree Update**: A split pane feature was added to the global component tree.
8. **SSO Test Connection Management**: Users can now open the SSO test connection page in a new tab.
9. **Session-Specific State Management**: The platform now retains session-specific state variables like `current_user` and `viewport` during test generation.
10. **App Template Copying**: New support for copying app templates to mirror after slice loads was introduced.
11. **Enhanced App Testing UI**: A new user interface for app testing has been implemented, featuring expanded value code editors for query mocks and preconditions.
12. **Database Archiving Safeguards**: Safeguards have been integrated for Retool Database archiving processes.
For detailed information on these features, please check the [latest edge release notes](https://docs.retool.com/releases/edge).
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:
Property | Value |
---|---|
To | The email address to receive the notification. |
Subject | Retool Self-hosted version {{ Object.keys(fetchPosts.data)[0] }} |
Finally, set Body to Markdown mode, and include the summary:
{{ 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.
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: