Appearance
What are RoboDocs?
RoboDocs are just templates. We don't call them templates because templates mean different things to different people so we just decided to rename them to a cool name of RoboDocs.
TIP
A "parser" is a software tool that can search and locate a word or character inside other text. Templates have marker words in them and parsers can find those markers and replace them with new words, number, whatever.
What is a Template?
A template is a text document that has formated sections within it that are place markers for a parser to read and replace the markers with new text or data. For example, the following template has the marker {$var1} which tells a parser to replace the marker with the value of variable var1.
The total number of cats in the house is {$var1}.If the variable var1 is 12, then the resulting string would be:
The total number of cats in the house is 12.RobotAgentz uses the powerful template engine called Latte. To read more about the awesome things that you can do with Latte checkout the following website Latte Guide
Some More Examples
The following are some examples of how to use the RoboDocs.
API Result Parsing
Lets say that we want to get the some information from an API. We could use the API block to request the information from the API and place it into a variable called var1. Here is a possible API response:
{
"first":"Anakin",
"last":"Skywalker",
"nickname":"Darth Vader",
"occupation":"Sith Lord",
"family":
{
"mother":"Shmi",
"father":null,
"wife":"Padme Amidala",
"children":["Luke","Leia"]
}
}We could parse this JSON response above and place into a document that we can then email. The following would be the RoboDoc text:
We found that the character {$var1->nickname}
has the legal name of {$var1->first} {$var1->last}. The
character has the occupation of {$var1->occupation}.The resulting text would be:
We found that the character Darth Vader
has the legal name of Anakin Skywalker. The
character has the occupation of Sith Lord.Building a JSON Object or Array
Sometimes we have variables with single values that we need to assemble into a JSON array or object. For example, lets say we have the following variables in the mission:
var1 = 30
var2 = 2
var3 = 15We can construct a JSON array using the task block RoboDoc to Variable using the following RoboDoc:
[{$var1},{$var2},{$var3}]If we place the result in variable var4 the result would be:
[30,2,15]