Hi - I'm adding an automation to some of my flows ...
# ask-community
m
Hi - I'm adding an automation to some of my flows using your api, immediately after I've deployed the flow. I'm calling the "create_flow_run_state_changed_hook_input" mutation to create a new hook each time with the complete list of flow_group_ids. Is this the best way to do it? In other words, I'm looking to confirm that there is no way to update the hook with a new list of flow_group_ids and that I have to create a new hook each time with the updated list of flow_ids and then delete the old hook.
k
Hi @Mark McDonald, I think that’s right. Could you give me more details on the use case here? Would like to learn more about why you’re doing this.
m
@Kevin Kho We use the state change events to trigger webhooks, that are received by our own API. We take these state change payloads and forward them on to DataDog for monitoring. I want to add certain flows to certain hooks when the flows get deployed. So ideally, there would be an update hook mutation that would allow me to alter the flow_group_ids list
but I can also just search for the existing hook, create a new one with the list of flow group ids that I need using
create_flow_run_state_changed_hook_input
, then delete the old one
I would then update my action to use this new hook_id, I think
currently we do this with cloud_hooks and the process is a bit simpler. I just add a cloud_hook to each flow if that hook does not already exist. However I like that automations allows you to have a templated payload
k
Ok.I will raise this issue to the team 🙂
s
@Kevin Kho @Jenny Could you explain how I could formulate a query for existing
flow_run_state_changed_hook
’s based on
flow_group_id?
j
Hi @Sean Harkins - you'd need to do a nested query based on the event tag flow group id. Let me check and do an example for you.
Does this work for you? (xxxx is your flow group id)
Copy code
query {
  hook (where: {event_tags: {_contains: {flow_group_id: ["xxxxxxxx"]}}}){
    id
    event_type
  } 
}
s
Thanks @Jenny that works perfectly 🙇 .