Represent Bot Task as form
Bot Form (ETL) is a special Bot Config type intended for flexible re-using by defining all initial parameters (variables) through a UI form and not through direct code editing.
This feature allows business users to include Bot Configs into BPs and safely set their initial parameters and input/output data without editing the code.
Sample Form 1
Sample Form 2 
The goal of this topic is to convert simple Bot config to a user-friendly ETL form.

Bot code
Expand to see the code snippet
<?xml version="1.0" encoding="UTF-8"?>
<config>
<var-def name ="amount">
<#noparse>
<template>${{{input_column_name}}}</template>
</#noparse>
</var-def>
<var-def name ="output">
<template>Pass</template>
</var-def>
<case>
<#noparse>
<if condition="${Integer.valueOf(amount.toString()) >= {{amount_limit}}}">
<var-def name ="output">
<template>Fail</template>
</var-def>
</if>
</#noparse>
</case>
<export include-original-data="true">
<single-column name="{{result_column_name}}" value="${output}"/>
</export>
</config>
The Bot Configuration has the Input column, If statement, and Output column.
With the form, you can define the following:
- input column name {{input_column_name}}
- limit for <if> condition {{amount_limit}}
- output column name {{result_column_name}}
In above case user would specify input column that contains "number", specify the value "100", output column name = "result".
Convert basic Bot Configuration to form
Create a template. Go to Advanced > Templates, click Create, and add your existing Bot Configuration code to the created template.
In the Template Type fields, select BASE.
-
- Go to System Settings > Operations. Click Create Operation.
- On the Create Operation page, select an appropriate template and specify the operation's name.
- Set the operation's type to ETL.
- Go to Show Advanced Options and add an Answer:
- Input Column Name (input_column_name)
- Condition (amount_limit)
- Output Column Name (result_column_name)
- Edit the code for all the three settings from, for example, ${input_column_name} to:
- {{input_column_name}} to get the column name.
- ${{{input_column_name}}} to get the value of this column, not its name.
- Save the ETL config.
Add to BP
For instructions, refer to Add Bot Task to Business Process
Other form examples
Retrieve RSS feed

Bot code
Expand to see the code snippet
<?xml version="1.0" encoding="UTF-8"?>
<config>
<var-def name="selfossUrl">
<template>{{selfossurl}}</template>
</var-def>
<var-def name="mark_as_read_var">
<template>{{mark_as_read}}</template>
</var-def>
<script></script>
<while condition="true" index="idx" maxloops="40">
<var-def name="offset">
<script return="offset_result"></script>
</var-def>
<var-def name="itemsUrl">
<template>${selfossUrl}/items?items=200&offset=${offset}&
type={{type}}&topic={{topic}}&tag={{topic}}</template>
</var-def>
<var-def name="itemsJson">
<http url="${itemsUrl}" cookie-policy="browser" method="GET"/>
</var-def>
<script><![CDATA[
org.json.JSONArray jsonArr = new org.json.JSONArray(itemsJson.toString());
int jsonArrLength = jsonArr.length();
for (int i=0; i<jsonArrLength; i++) {
org.json.JSONObject jsonItem = jsonArr.getJSONObject(i);
String jsonItemContent = jsonItem.get("content");
String jsonItemSourceTitle = jsonItem.get("sourcetitle");
String jsonItemLink = jsonItem.get("link");
String jsonItemDateTime = jsonItem.get("datetime");
String jsonItemUid = jsonItem.get("uid");
String jsonTitle = jsonItem.get("title");
String itemId = jsonItem.get("id") != null ? jsonItem.get("id").toString(): "unknown" ;
Map exportItem = new HashMap();
exportItem.put("newsLink", jsonItemLink);
exportItem.put("sourceTitle", jsonItemSourceTitle);
exportItem.put("dateTime", jsonItemDateTime);
exportItem.put("feedUid", jsonItemUid);
exportItem.put("title", jsonTitle);
exportItem.put("feed_id", itemId);
uniqueMap.put(jsonItemContent, exportItem);
feedIds.add(itemId);
}
]]></script>
</while>
<var-def name="itemIds">
<script return="result"></script>
</var-def>
<case>
<if condition="${'${' + 'mark_as_read_var.toBoolean()' + '}'}">
<loop item="itemId">
<list>
<var name="itemIds"/>
</list>
<body>
<empty>
<var-def name="markResult">
<http url="${selfossUrl}/mark/${itemId}" cookie-policy="browser" method="POST"/>
</var-def>
</empty>
</body>
</loop>
</if>
</case>
<script></script>
<export include-original-data="false">
<multi-column list="${exportItems}">
<put-to-column-getter name="source" property="sourceTitle"/>
<put-to-column-getter name="feed_uid" property="feedUid"/>
<put-to-column-getter name="feed_link" property="newsLink"/>
<put-to-column-getter name="date_time" property="dateTime"/>
<put-to-column-getter name="feed_title" property="title"/>
<put-to-column-getter name="feed_id" property="feed_id"/>
</multi-column>
</export>
</config>
Look up SSI database

Bot code
Expand to see the code snippet
<?xml version="1.0" encoding="UTF-8"?>
<config charset="UTF-8">
<var-def name="db_name">{{db_name}}</var-def>
<var-def name="custodian_bank_swift"><template>${custodian_bank_swift}</template></var-def>
<var-def name="custodian_bank_name"><template>${custodian_bank_name}</template></var-def>
<var-def name="currency"><template>${currency}</template></var-def>
<var-def name="correspondent_bic"><template>${correspondent_bic}</template></var-def>
<var-def name="ssi_exists"><template>false</template></var-def>
<var-def name="ssi_document">
<datastore name="Custodian Banks Template">
{{check_query}}
</datastore>
</var-def>
<var-def name="ssi_exists">
<script return="result"></script>
</var-def>
<var-def name="jobUUID">
<script return="uuid"></script>
</var-def>
<export include-original-data="true">
<single-column name="ssi_exists" value="${ssi_exists}"/>
<single-column name="job_uuid" value="${jobUUID}"/>
</export>
</config>
Cut chapter from PDF

Bot code
Expand to see the code snippet
<?xml version="1.0" encoding="UTF-8"?>
<config>
<var-def name='toc_start'><template>${{{start_page}}}</template></var-def>
<var-def name='toc_end'><template>${{{end_page}}}</template></var-def>
<var-def name='document_link'><template>${{{pdf_document_link}}}</template></var-def>
<var-def name='offset'><template>${{{offset}}}</template></var-def>
<script></script>
<var-def name="cuttedDoc">
<s3 bucket='temp_bucket'>
<s3-put-public path='TR/OCR/split/${docUuid}.pdf' content-type="application/pdf" content-disposition="inline">
<script return="output.toByteArray()"/>
Skip escaping

Bot code
Expand to see the code snippet
<?xml version="1.0" encoding="UTF-8"?>
<config charset="UTF-8">
<var-def name="message">
<script return="result">
String result = org.apache.commons.lang3.StringEscapeUtils.unescapeJava("{{text}}");
</script>
</var-def>
<export include-original-data="true">
<single-column name="message" value="${message}" />
</export>
</config>