Human Input
Some steps need a person: a decision, or a review before the run goes on. action: human.task pauses the run and asks for it in a form. The run shows Waiting until someone completes the task.
Watch it run
In this recording, the person picked production, so deploy printed Deploying 1.4.0 to production.
The workflow
Create a workflow named tutorial-09-human-input and paste this YAML into it (how).
# Dagu tutorial, lesson 9: https://docs.dagu.sh/tutorial/human-input
steps:
- id: build
run: echo "Built release 1.4.0"
- id: choose_target
action: human.task
with:
prompt: Check the build, then choose where release 1.4.0 goes
form:
type: object
properties:
environment:
type: string
enum: [staging, production]
required: [environment]
depends: build
- id: deploy
run: echo "Deploying 1.4.0 to ${steps.choose_target.outputs.environment}"
depends: choose_targetprompt is the text the person sees. Human tasks are also how a person reviews work before a run continues: put the review instructions in the prompt.
form describes the fields as a JSON schema; here environment must be staging or production. Every form field becomes an output of the task, so ${steps.choose_target.outputs.environment} reads the answer. deploy depends on choose_target.
Run it yourself
- Select Start at the top right, then select Start in the dialog.
buildruns, then the run shows Waiting. - Select Open actions on the canvas, or open Activity → Actions.
- Pick an environment and select Complete task.
deployruns and prints the environment you picked.
A waiting run holds no process or worker slot, so it can wait as long as the person needs.
Try it
- Start a run and leave it Waiting. Stop
dagu start-allwithCtrl+C, start it again, and open the run. What state is it in? - Add a boolean form field
notifywith defaulttrueand print it indeploy.
Answers
- It is still Waiting. Complete the task and the run continues.
- Add
notifyunderpropertiesand reference it indeploy:
steps:
- id: build
run: echo "Built release 1.4.0"
- id: choose_target
action: human.task
with:
prompt: Check the build, then choose where release 1.4.0 goes
form:
type: object
properties:
environment:
type: string
enum: [staging, production]
notify:
type: boolean
default: true
required: [environment]
depends: build
- id: deploy
run: echo "Deploying 1.4.0 to ${steps.choose_target.outputs.environment}, notify=${steps.choose_target.outputs.notify}"
depends: choose_target
