<@ULVA73B9P> In Prefect 3, how do I make sure that...
# ask-marvin
n
@Marvin In Prefect 3, how do I make sure that an event is triggered if a flow run has tag
A
and tag
B
AT THE SAME TIME? They both need to be present
m
thought for 178.5 seconds
Yes—use an Event automation and require both tags via match_related. In Prefect 3, multiple objects in match_related are combined with AND, so each listed tag must be present on the flow run. Quick UI guidance - Create a new automation with trigger type: Event - Events to expect: choose the flow-run event(s) you care about (e.g., when a flow run completes or enters a state) - Resource match: Resource ID = prefect.flow-run.* (matches all flow runs) - Related resources: add two entries, each with: - Resource role: tag - Resource ID: prefect.tag.A - Resource role: tag - Resource ID: prefect.tag.B This will only fire when the flow run has both A and B. YAML/JSON snippet for the trigger
Copy code
trigger:
  type: event
  posture: Reactive
  expect:
    - prefect.flow-run.Completed    # or the event(s) you want
  match:
    prefect.resource.id: prefect.flow-run.*
  match_related:
    - prefect.resource.id: prefect.tag.A
      prefect.resource.role: tag
    - prefect.resource.id: prefect.tag.B
      prefect.resource.role: tag
Notes - The “Flow run state change” template in the UI evaluates flow-run tags with OR logic; to require A AND B, use an Event trigger as shown above. - match_related is AND across items (each object must match), while multiple values inside a single object are OR. CLI (if you want to create from a file)
Copy code
prefect automation create --from-file automation.yaml
If you share your current automation JSON/YAML (minus secrets), I can patch it to require A AND B.