Upon Flow failure, use an Automation to start another Flow

So you probably noticed that in the UI you can create an automation to trigger a flow on cancellation, but only for the same flow. Even though it’s not surfaced in the UI, it is possible to create a trigger for a different flow by using the API.

  1. Go to the Interactive API tab in the Prefect UI
  2. Get the flow group ID of the flow that clears the KV:
query {flow_group {
  id,
  flows {
    id,
    name
  }
}}
  1. Create a new action that runs the flow:
mutation {
  create_action(input: {
    name: "Clear KV Store",
    config: {create_flow_run: {
      flow_group_id: "UUID-GOES-HERE"
    }}}) {
    id
  }
}
  1. Now you can set the new action as an Automation.
1 Like