I want to run retool workflow from module and pass parameters to the workflow from module. JSON or Raw doesn't matter. Could you please help me and tell how should i refer to module parameters in workflow?
Thanks in advance,
Vladyslava.
I want to run retool workflow from module and pass parameters to the workflow from module. JSON or Raw doesn't matter. Could you please help me and tell how should i refer to module parameters in workflow?
Thanks in advance,
Vladyslava.
You would make an API call from your module to the workflow. Look into 'webhooks' on the Retool documentation.
Hi @Vlada_Dieieva,
Welcome to the community!
To run a Retool workflow from a module and pass parameters, you can follow these steps:
Trigger the workflow from the module: In the module, define the query you want to trigger the workflow for. In the Query JSON with SQL query, set the trigger to "Success event handler." This will execute the workflow whenever the query successfully completes.
Pass parameters to the workflow: In the parent app, use the Inspector to pass data to the module's data input. Set the data input to {{ queryName.data }}
to trigger the module query based on the result of queryName
. The module will watch for changes to queryName.data
and pass the updated data to the workflow.
Reference module parameters in the workflow: Within the workflow, you can access the parameters passed from the module using the data
object. For example, if you passed a parameter named customerID
, you could access it in the workflow as data.customerID
.
Here's an example of how to pass parameters to a workflow from a module:
Module:
{
"query": {
"sql": "SELECT * FROM customers WHERE id = {{ customerID }}",
"trigger": "Success event handler"
}
}
Parent App:
{
"elements": [
{
"type": "Query",
"name": "queryName",
"query": {
"sql": "SELECT * FROM customers"
}
},
{
"type": "Module",
"name": "customerModule",
"dataInput": "{{ queryName.data }}",
"module": "path/to/module.json"
}
]
}
Workflow:
{
"elements": [
{
"type": "Code",
"language": "javascript",
"code": "console.log(data.customerID);"
}
]
}
In this example, the customerModule
will be triggered whenever the queryName
query completes successfully. The module will pass the customerID
parameter to the workflow, which can then be accessed using data.customerID
.
Hope this helps.
Patrick