Prompts

Wait for a response from an operator before continuing
Workflows can easily gather input from operators using prompts. Each prompt contains a parameter form, similar to what you see when executing a task or runbook. When a prompt is created, the workflow run pauses⁠ and waits for a response⁠ before continuing. Prompts allow you to specify reviewers with Approvals to build dynamic approval flows.

Dry runs

A common use-case for prompts is to perform dry-runs. Let's look at an example:
typescript
Copied
1
import airplane from "airplane";
2
3
export default airplane.workflow(
4
{
5
/* ... */
6
},
7
async () => {
8
// Perform a dry-run and show the output to the operator with a display.
9
const dryRun = await airplane.execute("my_task_slug", {
10
dry_run: true,
11
});
12
await airplane.display.json(dryRun.output);
13
14
// Ask the operator if we should continue.
15
const ok = await airplane.prompt.boolean("Continue?", {
16
default: true,
17
description: `Review the dry-run output above. If it looks correct, click continue to apply the changes.`,
18
});
19
if (!ok) {
20
return;
21
}
22
23
// If confirmed, we can re-run:
24
const run = await airplane.execute("my_task_slug", {
25
dry_run: false,
26
});
27
28
return run.output;
29
}
30
);
If you've done UNIX scripting before, you have likely seen this pattern using the read command -- e.g.
bash
Copied
1
# perform a dry-run...
2
3
read -p "Continue? [yN] " -n 1 -r
4
echo
5
if [[ $REPLY =~ ^[Yy]$ ]]
6
then
7
# apply!
8
fi
Compared to the classic shell script, prompts offer a few compelling advantages:
  • Notifications: Users are automatically notified when prompted.
  • Parameters: Prompts can ask for arbitrary parameters with validation.
  • Durability: The workflow can sleep until a response is provided⁠—there's no busy waiting nor risk of data loss from the script exiting before a user responds.
  • Slack: Prompts can be responded to directly from Slack. [Coming soon!]

Usage

To get started with prompts, see one of our SDK-specific guides: