Hi - I have another question about automations, sp...
# ask-community
m
Hi - I have another question about automations, specifically state change automations. When creating the hook through the API using the mutation "create_flow_run_state_changed_hook_input", it says that if you leave the states argument empty in the mutation, all states will trigger the hook. However, I've done this and then looked at the hook from the API and I don't see any states. When I create the automation through the UI for all states, and then I look at the hook in the API, all the states are populated.
as a work around, I'm just adding all states into my code:
Copy code
states = [
            "Failed",
            "Pending",
            "Scheduled",
            "Retrying",
            "Resume",
            "Queued",
            "Submitted",
            "Paused",
            "Running",
            "Finished",
            "Success",
            "Cancelled",
            "Cached",
            "TriggerFailed",
            "Skipped",
            "TimedOut",
            "Mapped",
            "Looped"
          ]
z
Hi Mark, when you leave the states argument empty are you seeing the hook triggered?
m
no, it won't trigger
z
I'll look into this and get back to you
Could you share the mutation you're calling when leaving the states argument empty?
m
Copy code
mutation {create_flow_run_state_changed_hook(input: {                                                       flow_group_ids: [list of flow group ids], 
                                                        action_id: "{action_id}"}) 
                                                        {id}}
I've got it working how I want by providing the list of states, so it's good enough for now. Thanks for your help
👍 1
I've also tried providing an empty list as the states value
so like:
Copy code
mutation {create_flow_run_state_changed_hook(input: {
states: [],                                                       flow_group_ids: [list of flow group ids], 
                                                        action_id: "{action_id}"}) 
                                                        {id}}
z
Indeed it should be the case that an empty set of states will trigger the hook on any state, I'm not sure why that wouldn't work -- we can look into it on our end.
upvote 1
m
thanks!
z
Hey @Mark McDonald, I'm having trouble replicating the issue when I omit
states
from the mutation (like below)
Copy code
mutation {create_flow_run_state_changed_hook(input: {flow_group_ids: [list of flow group ids], action_id: "{action_id}"}) 
{id}}
Were you calling the mutation from the Interactive API in the UI?