Inputs allow you to make your flows more dynamic and reusable.
Instead of hardcoding values in your flow, you can use inputs to make your workflows more adaptable to change.
How to retrieve inputs
Inputs can be accessed in any task using the following expression {{ inputs.input_name }}
.
Defining inputs
Similar to tasks
, inputs
is a list of key-value pairs. Each input must have a name
and a type
. You can also set defaults
for each input. Setting default values for an input is always recommended, especially if you want to run your flow on a schedule.
To reference an input value in your flow, use the {{ inputs.input_name }}
syntax.
id: inputs_demo
namespace: company.team
inputs:
- id: user
type: STRING
defaults: Rick Astley
tasks:
- id: hello
type: io.kestra.plugin.core.log.Log
message: Hey there, {{ inputs.user }}
Try running the above flow with different values for the user
input. You can do this by clicking on the Execute
button in the UI, and then typing the desired value in the menu.
The plural form of defaults
rather than default
has two reasons. First, default
is a reserved keyword in Java, so it couldn't be used. Second, this property allows you to set default value for a JSON object which can simultaneously be an array defining multiple default values.
Here are the most common input types:
Type | Description |
---|---|
STRING | It can be any string value. Strings are not parsed, they are passed as-is to any task that uses them. |
INT | It can be any valid integer number (without decimals). |
BOOLEAN | It must be either true or false . |
Check the inputs documentation for a full list of supported input types.
Parametrize your flow
In our example, we will provide the URL of the API as an input. This way, we can easily change the URL when calling the flow without having to modify the flow itself.
id: getting_started
namespace: company.team
inputs:
- id: api_url
type: STRING
defaults: https://dummyjson.com/products
tasks:
- id: api
type: io.kestra.plugin.core.http.Request
uri: "{{ inputs.api_url }}"
To learn more about inputs, check out the full inputs documentation.
Was this page helpful?