Making the flow change it’s own trigger value based on the Discord OAuth token lifecycle!
Alright! Get ready for some recursive stuff! 🔁 In this one we’re going to make your own flow automatically update it’s own recurrence values, so that it can automate its own runtime schedules. Now I want you to follow along closely, because we’re going to involve a few actions that we will add and remove during development… Which is a bit important later on 😂. First, let me introduce you to the “Power Automate Management” connectors – and more specifically the “Get flow” and the “Update flow” actions. Not many knows about its existence, but we can actually manipulate the flow application using it’s schema-structure. For some of the Logic Apps developers out there, this will be the same schema-structure as when you develop them in code view.
The specific demo I’m using for this tutorial is an expansion of my previous flow from blogpost – Power Automate: Store your API Access tokens in Azure Key Vaults and automatically renew them! – recursion.no
Keep in mind that even if it’s a specific demo, the techniques used can be applied to whichever flow you may use it with in the future. So let’s go!… 😎
- Create a dynamic trigger for our flow based on it’s own value fetched from other external services.
- Learn about how to store and backup your Power Automate schema in SharePoint
- Learn how to manipulate your Power Automate schema to change it’s own trigger during flow runtime
- A dedicated SharePoint List
- Power Automate Premium license to use HTTP actions (Only for the Demo purpose, and not necessary to your specific needs)
- A basic understanding of JSON and Logic Apps Schemas
Creating the SharePoint list
First of all, let’s get the prerequisites out of the way. Create a new SharePoint list and call it “Dynamic Flow Scheduler“. In that list, start with creating a single column representing your flow’s schema structure.
Creating your flow (Demo scenario)
For this particular demo purpose, I’m going to use the flow to refresh a Discord Token and set the flow’s trigger recurrence to the next expire_in value from the response payload.
For this Demo, I’m also adding four Key Vault Secret values from my Azure Key Vault to authenticate my HTTP-calls. The first two are for the Discord authentication, the last two are for updating my Key Vault Secret in Azure with HTTP-calls. I’m also securing these values by turning on the “Secure Outputs” option settings.
You can read more details about how I’ve configured my Azure Key Vaults from my previous blog: Power Automate: Store your API Access tokens in Azure Key Vaults and automatically renew them! – recursion.no.
Note: These can be left out if you are not using the Azure Key Vault feature for client ID & client secret values.
Manipulating the Power Automate trigger schema
Add an “Update Flow” action outside of the scope
Flow Definition Code:
Now run the flow once! We want to fetch the Power Automate Schema!
Congratulations! We’re now done configuring the recurrence manipulation!
All we need to do now is to run it!
Now navigate back to the “Edit” mode of the flow!
E voilà, amici miei! Your interval has changed for the next upcoming run! And the flow is still the same! 😎🙌
We’ve learned how to automate your Power Automate flow’s runtime schedule by making it automatically update its own recurrence values. Using the “Power Automate Management” connectors and specific actions like “Get Flow” and “Update flow,” you can manipulate the flow application using its schema. With a dedicated SharePoint list and a basic understanding of JSON and Logic Apps Schemas, you can create a dynamic trigger for your flow based on its own value fetched from other services. By using these features, you’ve also secretly learned how to easily backup your Power Automate flows in a SharePoint list in the future! Props to you for making it this far! 🥳
Below is the entire flow in recap: