Import and run a workflow from an app
You can run Retool Workflows from apps and classic apps. This is useful for reducing complexity as it enables you to:
- Break down complex sets of queries into more manageable functions that perform specific actions (e.g., perform multiple API requests).
- Reuse the same actions across multiple apps, reducing the amount of duplication (e.g., transform and store data in Retool Vectors).
The app triggers the specified workflow, passing the provided data for it to use. If the workflow produces data, it is returned back to the current app.
You can also run another workflow from a workflow. Use the Workflow block within a workflow for the same functionality described here.
- Apps
- Classic apps
To trigger a workflow from your app, open the Chat tab and prompt your agent with the workflow's name:
The triggered workflow is run on behalf of the app's authenticated user.
Open the Code tab, add a new query, and select Import a Workflow. This populates a query with the Retool Workflows resource. You then select the workflow to run and specify the parameters to pass:
| Parameters | Description |
|---|---|
| Raw | Reference raw data. This can be any value, such as a string or all JSON data from a previous block (e.g., query1.data). |
| JSON | Create a set of key-value pairs using input fields. |
| None | Do not pass any data. |
You do not have to pass any data to the specified workflow. For example, you may want to run a workflow that retrieves data to then use in the app.
Return data to the app
Workflows run from within an app or classic app operate in a similar way to a webhook-triggered workflow.
In order to make data from the workflow available to the app, you must include a Response block in the workflow. The data returned from the Response block is sent to the app once the workflow run completes (available as startTrigger.data for classic app users). If you want to trigger a workflow without returning data back to the app, you don't need a Response block.