Hi all - if I set a task to manual trigger only, i...
# ask-community
b
Hi all - if I set a task to manual trigger only, is there a way of triggering it programmatically? I know that sounds counterintuitive, but we have a task which we want to pause and wait on a particular task until a manual process takes place on another system. We then want to trigger the workflow to continue from that system. It would be more elegant than having the task sleeping and polling. Can we use a mutation query against the cloud API to do it?
j
Hi @Ben Collier I’ve not tried it but I believe other users have done this through the cloud API. You’d need to use the set_state mutation and set the state to resume. I’m on mobile right now but can send an example version later if you need it.
b
Hi Jenny, thanks! That would be enormously useful, saves me having to figure out how to send a resume mutation.
j
Copy code
mutation {
  set_task_run_states (input: {states: {task_run_id: "TASK RUN ID", version: 3, state: {type: "Resume", message: "YOUR MESSAGE"}}}) {
    states {
      id
    }
  }
}
Should do it. The state input is JSON so you may need to format them. The version is how many times the task run has changed state - I believe that should be in context.
b
Can I ignore version entirely if I’m setting a mutation? Or is it better to do a query and figure out what the current state is?
(Thanks for this)
j
I believe it's required but you shouldn’t need another query, you should have it in the prefect.context.
Oh… just realized you're doing this from another flow? Context won't help there 🤦‍♀️