Using Task Input Templates
Task input templates are default parameters included in a task definition that will be applied to all instances of the task. Whenever the task is used in a workflow, the template values are automatically supplied to the task configuration. These values can be overridden in the workflow using task input parameters.
Configuring task input template
Task input templates are part of a task definition, and you can create them when you define the task.
To create a task definition:
- Go to Definitions > Task from the left menu on your Conductor cluster.
- Select an existing task definition or create a new task using (+) Define task.
- Configure the required task parameters.
- In Task input template, select + Add parameter.
- Enter the template parameters as key-value pairs.
- In Type, select the parameter type. Supports string, number, boolean, null, and object/array.
- Select Save > Confirm Save.
// Example of a task input template in a task definition JSON
"inputTemplate": {
"key": "value"
},
Adding task input templates in workflow definitions
To include a task input template in a workflow:
- Go to Definitions > Workflow from the left menu on your Conductor cluster.
- Select an existing task definition or create a new task using (+) Define workflow.
- Configure the required workflow parameters.
- In your workflow, select the (+) icon and add a task that uses the definition you created earlier, such as a Worker task. There are two ways to add this task.
- Select the (+) icon and search for your task using its task name (created previously) and add it.
- Add a Simple task and search for your task name (created previously) in the Task Definition field. This will add your task definition to the workflow.
When a task definition is added to the workflow, the parameters supplied via the task input template are automatically included.
If you provide the same value as an input parameter to the task, the template values get overridden by the task input parameter.
For example, a parameter key
with the value value
has been supplied through a task input template. If the same key
is defined as input parameters to the task, those values override the ones from the template.
Use the Override All button to replace the task input parameters with the template's parameters.
Task input templates are only part of the task definition and will not appear in the workflow definition JSON. However, the values are passed into the workflow during execution.
Examples
Using task input templates in a workflow
To illustrate the use of task input templates in a workflow definition, let’s create a task definition.
To create a task definition:
- Go to Definitions > Task from the left navigation menu on your Conductor cluster.
- Select + Define task.
- In the Code tab, paste the following code:
{
"name": "sample-task",
"description": "Sample task for demonstrating the use of task input templates",
"retryCount": 3,
"timeoutSeconds": 3600,
"inputKeys": [],
"outputKeys": [],
"timeoutPolicy": "TIME_OUT_WF",
"retryLogic": "FIXED",
"retryDelaySeconds": 60,
"responseTimeoutSeconds": 600,
"concurrentExecLimit": 0,
"inputTemplate": {
"someKey": "someValue"
},
"rateLimitPerFrequency": 0,
"rateLimitFrequencyInSeconds": 1,
"pollTimeoutSeconds": 3600,
"backoffScaleFactor": 1,
"totalTimeoutSeconds": 0,
"enforceSchema": false
}
- Select Save > Confirm Save.
This creates the task definition with the following task input templates.
Next, create a workflow definition containing a Worker task that uses the task definition you just created.
To create a workflow definition:
- Go to Definitions > Workflow from the left navigation menu on your Conductor cluster.
- Select + Define workflow.
- In the Code tab, paste the following code:
{
"name": "SampleWorkflow",
"description": "Sample workflow demonstrating the use of task input templates",
"version": 1,
"tasks": [
{
"name": "sample-task",
"taskReferenceName": "simple_ref",
"type": "SIMPLE"
}
],
"inputParameters": [],
"outputParameters": {},
"schemaVersion": 2,
"restartable": true,
"workflowStatusListenerEnabled": false,
"timeoutPolicy": "ALERT_ONLY",
"timeoutSeconds": 0,
"failureWorkflow": ""
}
- Select Save > Confirm.
When a task definition is added to the workflow, the parameters supplied via the task input template are automatically included in the workflow.
This ensures that whenever you need specific parameters for a task, they can be already defined using the task input template, and consistently applied without requiring you to re-enter them each time you use the same task definition. This helps you save time and reduce errors when reusing tasks across workflows.