Prompts
Example: dry runs
typescriptCopied1import airplane from "airplane";23export default airplane.task(4{5slug: "task_dryrun",6},7async () => {8// Perform a dry-run and show the output to the operator with a display.9const dryRun = await airplane.execute("my_task_slug", {10dry_run: true,11});12await airplane.display.json(dryRun.output);1314// Ask the operator if we should continue.15const { ok } = await airplane.prompt(16{ ok: "boolean" },17{18description: `Review the dry-run output above. If it looks correct, select OK to apply the changes.`,19}20);21if (!ok) {22await airplane.display.text("Exiting due to bad dryrun");23return;24}2526// If confirmed, we can re-run:27const run = await airplane.execute("my_task_slug", {28dry_run: false,29});3031return run.output;32}33);
javascriptCopied1import airplane from "airplane";23export default airplane.task(4{5slug: "task_dryrun",6},7async () => {8// Perform a dry-run and show the output to the operator with a display.9const dryRun = await airplane.execute("my_task_slug", {10dry_run: true,11});12await airplane.display.json(dryRun.output);1314// Ask the operator if we should continue.15const { ok } = await airplane.prompt(16{ ok: "boolean" },17{18description: `Review the dry-run output above. If it looks correct, select OK to apply the changes.`,19}20);21if (!ok) {22await airplane.display.text("Exiting due to bad dryrun");23return;24}2526// If confirmed, we can re-run:27const run = await airplane.execute("my_task_slug", {28dry_run: false,29});3031return run.output;32}33);
pythonCopied1import airplane234@airplane.task()5def task_dryrun():6# Perform a dry-run and show the output to the operator with a display.7dry_run = airplane.execute(8"my_task_slug",9{10"dry_run": True,11},12)13airplane.display.json(dry_run.output)14# Ask the operator if we should continue.15airplane.prompt(16description=(17"Review the dry-run output above. If it looks correct, "18"click OK to apply the changes."19),20)21# If confirmed, we can re-run:22run = airplane.execute(23"my_task_slug",24{25"dry_run": False,26},27)
read
command --
e.g.bashCopied1# perform a dry-run...23read -p "Continue? [yN] " -n 1 -r4echo5if [[ $REPLY =~ ^[Yy]$ ]]6then7# apply!8fi
- Notifications: Users are automatically notified when prompted.
- Parameters: Prompts can ask for arbitrary parameters with validation.
- Slack: Prompts can be responded to directly from Slack.
Parameters
Short text

typescriptCopied1const { email } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ email: "shorttext" }4);5// or6const { email } = await airplane.prompt({7// Mapping of slug -> parameter definition8email: {9type: "shorttext",10name: "Email address",11// ...12},13});
javascriptCopied1const { email } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ email: "shorttext" }4);5// or6const { email } = await airplane.prompt({7// Mapping of slug -> parameter definition8email: {9type: "shorttext",10name: "Email address",11// ...12},13});
pythonCopied1values = airplane.prompt(2# Mapping of slug -> parameter definition3{"email": str}4)5# Access prompt value via values['email']67# or8values = airplane.prompt(9{10# Mapping of slug -> parameter definition11#12# More details about inline parameter configuration can be found here:13# https://docs.airplane.dev/tasks/python-config#additional-configuration14#15# `Annotated` must be imported from the `typing` module in Python 3.9+ or16# from the `typing_extensions` module in Python 3.8 and below.17"email": Annotated[18str,19airplane.ParamConfig(20name="Email address",21# ...22),23]24},25)26# Access prompt value via values['email']
Long text

typescriptCopied1const { reason } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ reason: "longtext" }4);5// or6const { reason } = await airplane.prompt({7// Mapping of slug -> parameter definition8reason: {9type: "longtext",10name: "Refund reason",11// ...12},13});
typescriptCopied1const { reason } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ reason: "longtext" }4);5// or6const { reason } = await airplane.prompt({7// Mapping of slug -> parameter definition8reason: {9type: "longtext",10name: "Refund reason",11// ...12},13});
pythonCopied1values = airplane.prompt(2# Mapping of slug -> parameter definition3{"reason": airplane.LongText}4)5# Access prompt value via values['reason']67# or8values = airplane.prompt(9{10# Mapping of slug -> parameter definition11#12# More details about inline parameter configuration can be found here:13# https://docs.airplane.dev/tasks/python-config#additional-configuration14#15# `Annotated` must be imported from the `typing` module in Python 3.9+ or16# from the `typing_extensions` module in Python 3.8 and below.17"reason": Annotated[18airplane.LongText,19airplane.ParamConfig(20name="Refund reason",21# ...22),23]24},25)26# Access prompt value via values['reason']
SQL

typescriptCopied1const { query } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ query: "sql" }4);5// or6const { query } = await airplane.prompt({7// Mapping of slug -> parameter definition8query: {9type: "sql",10name: "SQL query",11// ...12},13});
javascriptCopied1const { query } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ query: "sql" }4);5// or6const { query } = await airplane.prompt({7// Mapping of slug -> parameter definition8query: {9type: "sql",10name: "SQL query",11// ...12},13});
pythonCopied1values = airplane.prompt(2# Mapping of slug -> parameter definition3{"query": airplane.SQL}4)5# Access prompt value via values['query']67# or8values = airplane.prompt(9{10# Mapping of slug -> parameter definition11#12# More details about inline parameter configuration can be found here:13# https://docs.airplane.dev/tasks/python-config#additional-configuration14#15# `Annotated` must be imported from the `typing` module in Python 3.9+ or16# from the `typing_extensions` module in Python 3.8 and below.17"query": Annotated[18airplane.SQL,19airplane.ParamConfig(20name="SQL query",21# ...22),23]24},25)26# Access prompt value via values['query']
Float

typescriptCopied1const { cost } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ cost: "float" }4);5// or6const { cost } = await airplane.prompt({7// Mapping of slug -> parameter definition8cost: {9type: "float",10name: "Amount to charge",11// ...12},13});
javascriptCopied1const { cost } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ cost: "float" }4);5// or6const { cost } = await airplane.prompt({7// Mapping of slug -> parameter definition8cost: {9type: "float",10name: "Amount to charge",11// ...12},13});
pythonCopied1values = airplane.prompt(2# Mapping of slug -> parameter definition3{"cost": float}4)5# Access prompt value via values['cost']67# or8values = airplane.prompt(9{10# Mapping of slug -> parameter definition11#12# More details about inline parameter configuration can be found here:13# https://docs.airplane.dev/tasks/python-config#additional-configuration14#15# `Annotated` must be imported from the `typing` module in Python 3.9+ or16# from the `typing_extensions` module in Python 3.8 and below.17"cost": Annotated[18float,19airplane.ParamConfig(20name="Amount to charge",21# ...22),23]24},25)26# Access prompt value via values['cost']
Integer

typescriptCopied1const { count } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ count: "integer" }4);5// or6const { count } = await airplane.prompt({7// Mapping of slug -> parameter definition8count: {9type: "integer",10name: "Record count",11// ...12},13});
javascriptCopied1const { count } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ count: "integer" }4);5// or6const { count } = await airplane.prompt({7// Mapping of slug -> parameter definition8count: {9type: "integer",10name: "Record count",11// ...12},13});
pythonCopied1values = airplane.prompt(2# Mapping of slug -> parameter definition3{"count": int}4)5# Access prompt value via values['count']67# or8values = airplane.prompt(9{10# Mapping of slug -> parameter definition11#12# More details about inline parameter configuration can be found here:13# https://docs.airplane.dev/tasks/python-config#additional-configuration14#15# `Annotated` must be imported from the `typing` module in Python 3.9+ or16# from the `typing_extensions` module in Python 3.8 and below.17"count": Annotated[18int,19airplane.ParamConfig(20name="Record count",21# ...22),23]24},25)26# Access prompt value via values['count']
Boolean

typescriptCopied1const { ok } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ ok: "boolean" }4);5// or6const { ok } = await airplane.prompt({7// Mapping of slug -> parameter definition8ok: {9type: "boolean",10name: "Countinue",11// ...12},13});
javascriptCopied1const { ok } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ ok: "boolean" }4);5// or6const { ok } = await airplane.prompt({7// Mapping of slug -> parameter definition8ok: {9type: "boolean",10name: "Countinue",11// ...12},13});
pythonCopied1values = airplane.prompt(2# Mapping of slug -> parameter definition3{"reason": airplane.LongText}4)5# Access prompt value via values['reason']67# or8values = airplane.prompt(9{10# Mapping of slug -> parameter definition11#12# More details about inline parameter configuration can be found here:13# https://docs.airplane.dev/tasks/python-config#additional-configuration14#15# `Annotated` must be imported from the `typing` module in Python 3.9+ or16# from the `typing_extensions` module in Python 3.8 and below.17"reason": Annotated[18airplane.LongText,19airplane.ParamConfig(20name="Refund reason",21# ...22),23]24},25)26# Access prompt value via values['reason']
Date

typescriptCopied1const { date } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ date: "date" }4);5// or6const { date } = await airplane.prompt({7// Mapping of slug -> parameter definition8date: {9type: "date",10name: "Start date",11// ...12},13});
javascriptCopied1const { date } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ date: "date" }4);5// or6const { date } = await airplane.prompt({7// Mapping of slug -> parameter definition8date: {9type: "date",10name: "Start date",11// ...12},13});
pythonCopied1values = airplane.prompt(2# Mapping of slug -> parameter definition3{"date": datetime.date}4)5# Access prompt value via values['date']67# or8values = airplane.prompt(9{10# Mapping of slug -> parameter definition11#12# More details about inline parameter configuration can be found here:13# https://docs.airplane.dev/tasks/python-config#additional-configuration14#15# `Annotated` must be imported from the `typing` module in Python 3.9+ or16# from the `typing_extensions` module in Python 3.8 and below.17"date": Annotated[18datetime.date,19airplane.ParamConfig(20name="Start date",21# ...22),23]24},25)26# Access prompt value via values['date']
Datetime

typescriptCopied1const { timestamp } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ timestamp: "datetime" }4);5// or6const { timestamp } = await airplane.prompt({7// Mapping of slug -> parameter definition8timestamp: {9type: "datetime",10name: "Incident start",11// ...12},13});
javascriptCopied1const { timestamp } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ timestamp: "datetime" }4);5// or6const { timestamp } = await airplane.prompt({7// Mapping of slug -> parameter definition8timestamp: {9type: "datetime",10name: "Incident start",11// ...12},13});
pythonCopied1values = airplane.prompt(2# Mapping of slug -> parameter definition3{"timestamp": datetime.datetime}4)5# Access prompt value via values['timestamp']67# or8values = airplane.prompt(9{10# Mapping of slug -> parameter definition11#12# More details about inline parameter configuration can be found here:13# https://docs.airplane.dev/tasks/python-config#additional-configuration14#15# `Annotated` must be imported from the `typing` module in Python 3.9+ or16# from the `typing_extensions` module in Python 3.8 and below.17"timestamp": Annotated[18datetime.datetime,19airplane.ParamConfig(20name="Incident start",21# ...22),23]24},25)26# Access prompt value via values['timestamp']
File

typescriptCopied1const { photo } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ photo: "upload" }4);5// or6const { photo } = await airplane.prompt({7// Mapping of slug -> parameter definition8photo: {9type: "upload",10name: "Receipt photo",11// ...12},13});
javascriptCopied1const { photo } = await airplane.prompt(2// Mapping of slug -> parameter definition3{ photo: "upload" }4);5// or6const { photo } = await airplane.prompt({7// Mapping of slug -> parameter definition8photo: {9type: "upload",10name: "Receipt photo",11// ...12},13});
pythonCopied1values = airplane.prompt(2# Mapping of slug -> parameter definition3{"photo": airplane.File}4)5# Access prompt value via values['photo']67# or8values = airplane.prompt(9{10# Mapping of slug -> parameter definition11#12# More details about inline parameter configuration can be found here:13# https://docs.airplane.dev/tasks/python-config#additional-configuration14#15# `Annotated` must be imported from the `typing` module in Python 3.9+ or16# from the `typing_extensions` module in Python 3.8 and below.17"photo": Annotated[18airplane.File,19airplane.ParamConfig(20name="Receipt photo",21# ...22),23]24},25)26# Access prompt value via values['photo']
Config variables
Examples
Multi-parameter forms

typescriptCopied1const {amount, reason} = await airplane.prompt(2// Mapping of slug -> parameter definition3{ reason: "shorttext" }4{ amount: "float" }5);6// or7const {amount, reason} = await airplane.prompt({8// Mapping of slug -> parameter definition9reason: {10type: "shorttext",11name: "Refund reason",12// ...13},14amount: {15type: "float",16name: "Refund amount",17// ...18},19});
javascriptCopied1const {amount, reason} = await airplane.prompt(2// Mapping of slug -> parameter definition3{ reason: "shorttext" }4{ amount: "float" }5);6// or7const {amount, reason} = await airplane.prompt({8// Mapping of slug -> parameter definition9reason: {10type: "shorttext",11name: "Refund reason",12// ...13},14amount: {15type: "float",16name: "Refund amount",17// ...18},19});
pythonCopied1values = airplane.prompt(2# Mapping of slug -> parameter definition3{"reason": str}4{"amount": float}5)6# Access prompt value via values['reason'], values['amount']78# or9values = airplane.prompt(10{11# Mapping of slug -> parameter definition12#13# More details about inline parameter configuration can be found here:14# https://docs.airplane.dev/tasks/python-config#additional-configuration15#16# `Annotated` must be imported from the `typing` module in Python 3.9+ or17# from the `typing_extensions` module in Python 3.8 and below.18"reason": Annotated[19str,20airplane.ParamConfig(21name="Refund reason",22# ...23),24],25"amount": Annotated[26float,27airplane.ParamConfig(28name="Refund amount",29# ...30),31],32},33)34# Access prompt value via values['reason'], values['amount']
Confirmation

typescriptCopied1// Convenience helper for prompts with no parameters2await airplane.prompt.confirm({ description: "## Please review run before continuing." });34// Equivalent to5await airplane.prompt({}, { description: "## Please review run before continuing." });
javascriptCopied1// Convenience helper for prompts with no parameters2await airplane.prompt.confirm({ description: "## Please review run before continuing." });34// Equivalent to this5await airplane.prompt({}, { description: "## Please review run before continuing." });
pythonCopied1airplane.prompt(description="## Please review run before continuing.")
Select options

typescriptCopied1const users = [2{ name: "Colin", id: "usr1" },3{ name: "Lee", id: "usr2" },4];5const user = await airplane.prompt.select("User", users, {6optionToLabel: (user) => user.name,7});
javascriptCopied1const users = [2{ name: "Colin", id: "usr1" },3{ name: "Lee", id: "usr2" },4];5const user = await airplane.prompt.select("User", users, {6optionToLabel: (user) => user.name,7});
pythonCopied1values = airplane.prompt(2# Mapping of slug -> parameter definition3#4# More details about inline parameter configuration can be found here:5# https://docs.airplane.dev/tasks/python-config#additional-configuration6#7# `Annotated` must be imported from the `typing` module in Python 3.9+ or8# from the `typing_extensions` module in Python 3.8 and below.9"user": Annotated[10str,11airplane.ParamConfig(12options=[13airplane.LabeledOption(label="usr1", value="Colin"),14airplane.LabeledOption(label="usr2", value="Lee"),15]16),17]18);19# Access prompt value via values['user']
Background prompts
prompt.background
. When used in combination with the
Submit Prompt API endpoint, you are able to able to programatically
submit prompts from outside of Airplane's runtime.typescriptCopied1// Create a prompt in the background to get an ID.2const myPrompt = await airplane.prompt.background({ deploy_succeeded: "boolean" });34// Start a downstream processes and pass a reference to the prompt via its ID.5await airplane.rest.request("deploy_resource", "POST", "/startDeploy", {6body: { promptID: myPrompt.promptID },7});89// In this case, the request from the downstream processes would look like10// curl https://api.airplane.dev/v0/prompts/submit \11// -X POST \12// -H "X-Airplane-API-Key: $AIRPLANE_API_KEY" \13// -d '{14// "id": "pmt20221122zyydx3rho2t",15// "values": {16// "deploy_succeeded": "true",17// }18//}'1920// Wait on the downstream process to submit the prompt via the Airplane API.21const { deploy_succeeded } = await myPrompt.wait();
javascriptCopied1// Create a prompt in the background to get an ID.2const myPrompt = await airplane.prompt.background({ deploy_succeeded: "boolean" });34// Start a downstream processes and pass a reference to the prompt via its ID.5await airplane.rest.request("deploy_resource", "POST", "/startDeploy", {6body: { promptID: myPrompt.promptID },7});89// In this case, the request from the downstream processes would look like10// curl https://api.airplane.dev/v0/prompts/submit \11// -X POST \12// -H "X-Airplane-API-Key: $AIRPLANE_API_KEY" \13// -d '{14// "id": "pmt20221122zyydx3rho2t",15// "values": {16// "deploy_succeeded": "true",17// }18//}'1920// Wait on the downstream process to submit the prompt via the Airplane API.21const { deploy_succeeded } = await myPrompt.wait();
pythonCopied1# Create a prompt in the background to get an ID.2my_prompt = airplane.prompt({"deploy_succeeded": bool}, background=True)34# Start a downstream processes and pass a reference to the prompt via its ID.5airplane.rest.request(6"deployResource",7"POST",8"/startDeploy",9body={"promptID": my_prompt.prompt_id},10)1112# In this case, the request from the downstream processes would look like13# curl https://api.airplane.dev/v0/prompts/submit \14# -X POST \15# -H "X-Airplane-API-Key: $AIRPLANE_API_KEY" \16# -d '{17# "id": "pmt20221122zyydx3rho2t",18# "values": {19# "deploy_succeeded": "true",20# }21# }'2223# Wait on the downstream process to submit the prompt via the prompts submit endpoint.24values = my_prompt.wait()
API reference
Defines the parameter form as a mapping of slug to parameter. The values will be returned as an object that maps the parameter slug to the corresponding value. To learn more about parameters, see the Parameter documentation.
For details on parameter configuration in TypeScript, see parameter configuration.
Optionally restrict who can submit this prompt. See Approvals.
Text of the confirmation button on the prompt dialog.
Text of the cancellation button on the prompt dialog.
Prompt description to display. Supports markdown.
Defines the parameter form as a mapping of slug to parameter. The values will be returned as an object that maps the parameter slug to the corresponding value. To learn more about parameters, see the Parameter documentation.
For details on parameter configuration in JavaScript, see parameter configuration.
Optionally restrict who can submit this prompt. See Approvals.
Text of the confirmation button on the prompt dialog.
Text of the cancellation button on the prompt dialog.
Prompt description to display. Supports markdown.
Defines the parameter form as a mapping of slug to parameter. The values will be returned as an object that maps the parameter slug to the corresponding value. To learn more about parameters, see the Parameter documentation.
For details on parameter configuration in Python, see parameter configuration.
Reviewers that are allowed to approve the prompt. If no reviewers are provided, anyone that can see the active run is allowed to approved.
Text of the confirmation button on the prompt dialog.
Text of the cancellation button on the prompt dialog.
Prompt description to display. Supports markdown.
If true, the prompt will be created in the background and a
Prompt
object will be returned. To wait for the prompt to be submitted,
call prompt.wait()