Templates
Overview
Templates provide a way to reuse objects within the Intelligent Automation Cloud. Almost every object within the Intelligent Automation Cloud, including Tasks and BPs, is based on Templates.
To start managing Templates, go to Advanced > Templates, where you can apply the following actions:
- create/edit
- copy
- export/import
- delete
- filter Templates by type

Create / Edit Template
While editing or creating a Template, you can access the following tabs:
Content
You can write plain text, XML, HTML, CSS, JavaScript, and FreeMarker directives in the Template Content box and save the result.
You can also modify the Template Type.

History
The History tab displays all saved versions of a particular Template along with the author names and modification dates.
To view the template code, click on the appropriate link in the Template Name column – the code is displayed under the grid.

To compare two different template versions, tick the appropriate checkboxes and click on the Compare button. The selected two versions are displayed under the grid with all their differences highlighted.

Usage
The Usage tab displays all Use Cases (for Base, Base_Machine) or Tasks (all other) that use this particular Template.

If a Template is used for a Task or Use Case, a clickable plus (+) icon is shown under the Template name in the grid.

Copy Tasks with and without Templates
When copying Tasks, you have the option of creating a copy of the existing Template, or creating a link to it that will enable changes to propagate when either Task is modified.
When copying Templates, changes made to the new Task will not affect the original Task and its associated Template, while changes made to a Task with a linked Template will.

tip
See the Copy Task and Copy Business Process sections for detailed info.
Template Variables
Refer to FreeMarker engine variables.
To use an object in code, you need put it inside a <#if ??> tag:
<#if worker??>
Worker Name: ${worker.firstName}
</#if>
You can also create a hidden answer and pass some info into it to view it on Results > Data. For example, this code snippet submits the Worker ID in a separate column:
Pass Worker ID to Task results
<#list questions as question>
<input type="hidden" name="${question.identifier!}_worker_id_skipCheck"/>
<script type="text/javascript">
$(document).ready(function() {
$("input[name=${question.identifier!}_worker_id_skipCheck]").val($('#workerId').val());
});
</script>
<#if run??>
<@input type="hidden" name="_sys_executorId" value="${workerId!}:${run.questionUUID}" question=question answer=false class="executorId"/>
<@input type="hidden" name="_sys_human_task_title" value="${run.question.title}" question=question answer=false class="humanTaskTitle"/>
</#if>
</#list>
You can use the following variables in all Templates, except Machine and Base_Machine.
| Variable | Type | Description |
|---|---|---|
questions | list of object | Questions list usually used in the following form: Variable Usage Example <#list questions as question> Question text:Field #1: ${question.data.field1}Field #2: ${question.data.field2}<@answers question=question/> </#list> |
question | object | class: com.freedomoss.appliance.model.QuestionDTO |
question.data | map | Main data. Can be used in the form: question.data.column_name |
question.isGold | boolean | Is the gold question |
question.order | number | Question order |
question.answers | list of objects | Question answers |
submissionUUID | string | UUID of Task's submission |
workerId | string | Worker ID assigned on the endpoint |
worker | object | Object with the current worker info. Can be empty (null) when a worker is previewing the Task and has not accepted it yet. class: com.freedomoss.worker.model.Worker |
worker.id | number | Worker ID in the WorkFusion database |
worker.uuid | string | Worker UUID |
worker.nativeWorkerId | string | Same as workerId (see above) |
worker.firstName | string | First name |
worker.lastName | string | Last name |
worker.nickname | string | Nickname |
worker.creationDate | datetime | Worker's registration datetime. |
worker.country.name | string | Worker's country (can be empty if the worker's country cannot be determined) |
worker.lastActivity | datetime | Worker's last activity datetime |
countryCode | string | Worker's country code (if detected) |
assignmentId | string | Assignment ID |
mturkExternalSubmit | string | URL to submit Task form (for unsecure submit through http) |
secureMturkExternalSubmit | string | URL to submit Task form (for secure submit through https) |
hitTypeId | string | Hit type ID (as defined by the endpoint) |
Template Types
Macro
Macro Templates (MT) are libraries that contain custom tags used to build the Task and Base Templates. They contain necessary imports, scripts, structure, and styling.
Macro Templates can have the following extensions:
- ftl – used in Task Code Editor
- css – for answer type styling
- js – answer behavior
Update Macro Template
There are two ways to update Macro Template:
- Go to System Settings > Advanced and click on the Install Macro Templates Version button.
- Automatic update: Automatic update is executed on the application startup for each new revision.
Manual modification of MT through the Control Tower UI is strictly forbidden.
important
If you need to make changes to Macro Templates, add a feature request or create a bug ticket to the WorkFusion dev team. Mind that WorkFusion tracks the history of Template updates, so if needed, Template content can be restored.
List of Basic Macro Templates
| # | Name | Description |
|---|---|---|
| 1 | html.ftl | Base Template which converts data, scripts, and formatting to html |
| 2 | answers.ftl | Contnains macros for all defined Answer Types |
| 3 | extras.ftl | Includes gold and training macros |
| 4 | answer_information_extraction.ftl | Used to render Information Extraction Answer Type |
Base ( + Base_Machine)
WorkFusion's Use Cases are based on this type of Template. These Templates contain the code for the Task Design including the Instructions, Questions, and Answer choices if any.
They specify the format of the input file. Designed into the application by default.
When you create a Task using a Base Template, a copy of the Template is created and linked to that Task. Duplication of the Base Template ensures that the original Template will remain consistent and will not be altered unless required.
As Tasks are created, a new copy of the Base Template will be associated with the new Task. The following graphic illustrates this inherent design:

Task
Every time a new Task is created or copied, a Template for that Task is created. This Template contains the code for the Task Design including the Instructions, Questions, and Answer choices if any.
It also handles the passing of information such as the input data for the Task and the answer data entered from workers.
FreeMarker code of a Task is available in Task Code Editor.
Task Templates have "include" links to .ftl files (extras, html, answers) - Macro Templates.
Machine
Bot config XML code written using Web-Harvest language.
Availability
Availability Templates allow you to define an alternative UI for the Task when the Task is not available for execution.
An example scenario for implementing this Template would be when time constraints exist within the timing of a Task. If a Task is set up to call a business, you might require the Task to only run during normal business hours. This Template controls the Task timing.
Notify, Crowd_Notification
Notification Template used to communicate with workers concerning Tasks.
Text message when new Tasks are available for Workers. Set in Task Advanced Options > Notifications.

Accept/Reject
Notification Template used to convey to a worker that a Task has been accepted/rejected.
Message text sent to Worker when HIT is accepted/rejected. Set in Task Advanced Options > Notifications.
Example - Accept Template
Your Task is approved:
<#if (data.approved?size > 0) >
<#list data.approved as assignment>
Assignment[${assignment_index}]:
Title: ${data.question.title}
Reward: ${data.question.amount}
</#list>
</#if>