I made a Workflow to log user activity in my apps. I can trigger it from my app and pass the JSON parameters that contain the values I want to log. In short, it works as designed (and was super easy to make.)
Now, I want to integrate this workflow into 10 different Retool applications. It would help if the resource query could be copied between apps or made into a module so I don't have to configure all the fiddly parameters each time.
It isn't that big of a deal to create the resource query by hand for each app, but it makes using a workflow for this solution more effort than modularizing the logging SQL query itself and placing it in each app. Making something more effort is hard to explain to my friends, and "workflows are cool!" isn't persuasive enough for them.
I started using a workflow instead of the "local to the app" SQL query because I'm constantly looking for ways to reduce the number of times I go to the app's DB. My performance scores are laaaaaaaaame.
Does anyone else have a similar need for reusing workflow queries between apps?
Great question! I just did some testing out and think I have a viable solution for you. You can setup the workflow's webhook url as a Rest API resource and then reference it as a resource in new entry in the Query Library. Here is what I did for my query. If you use {{ }} values then you will create variables that the query will want to collect values for later:
Make sure that query is saved and shared, so we can then import it into our app.
Select the query we just created and you will see fields that are based off the two {{ }} variables that I setup earlier when I created the query in the library.
Great question! And no problem! I could have been a bit more explicit there.
It is specifically the API key that is tied to the workflow that is needed. If you go in your workflow and navigate to the triggers in the left menu and then click on your webhook you should see the below with an Api Key. That is what you will need to pass in your headers as X-Workflow-Api-Key.
You do not need to explicitly do this when you pick the Workflow resource from the app because that part is "abstracted" by Retool and done for you. To create a query "template" though in the Query Library the workflows resources are not directly supported so we couldn't use that. Instead I had to create a basic Rest API resource that pointed to the webhook in its place and therefore needs that header added so then we could create the reusable query off of that.
Thank you for your continued help! I snagged the API key as described and tried it out with Query Library test and in Postman. In the query library, I both explicitly defined the API key in the header as part of the query, or left it to inherit from the resource configuration.