Hi any chance i can use workflow for this use case?
I got a inventory management with rest api i need to detect when a new product is created and then pass is and save it to a retool db and show that info in a table for internal use and then also send that to another rest api is that possible?
Yes, great idea! Use Retool Workflow to detect new records from a REST API and send them to another REST API. Here is a basic workflow:
- Add a Call API block to your workflow and configure it to call the REST API that returns the inventory data.
- Add a Filter block after the Call API block and configure it to filter the data to only include new records.
- Add a Save to Database block after the Filter block and configure it to save the new records to the Retool database.
- Add a Call API block after the Save to Database block and configure it to call the REST API that you want to send the new records to.
You can use the following steps to configure the Filter block to filter the data to only include new records:
- In the Filter block, click the Add condition button.
- In the Condition field, select the Date field that contains the creation date of the inventory records.
- In the Operator field, select the
Greater than or equal to operator.
- In the Value field, enter the current date.
This will filter the data to only include inventory records that were created on or after the current date.
You can also use the Filter block to filter the data by other criteria, such as the product category or the supplier.
Here is an example of a Retool Workflow that detects new inventory records from a REST API, saves them to the Retool database, and sends them to another REST API:
# Call the API to retrieve the inventory data.
response = workflow.call_api("https://my-api.com/inventory")
# Filter the data to only include new records.
new_records = filter(lambda record: record["created_at"] >= datetime.datetime.today(), response.json())
# Save the new records to the Retool database.
# Call the API to send the new records to another REST API.
workflow.call_api("https://my-other-api.com/inventory", method="POST", body=json.dumps(new_records))
This is just a basic example, but it should get you started.
awesome thank you so much