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.
- Go to the Interactive API tab in the Prefect UI
- Get the flow group ID of the flow that clears the KV:
query {flow_group {
id,
flows {
id,
name
}
}}
- 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
}
}
- Now you can set the new action as an Automation.