Key words and terms

These are the building blocks to perform basic operations.

When writing your automation, there are certain keywords that you'll frequently utilize. These are the building blocks to perform basic operations.

If you feel like you are running into grammar issues for a phrase you feel should be expected, feel free to reach out to Kognitos directly at [email protected], or post your feedback in the Discussions section of the documentation.

get Keyword

This is used to retrieve different objects used in an automation. For example, retrieving files to be used in a subsequent loop. In the process, it would look like this:

get the document's fields
get the first line in the document

This term is also used to obtain values from a document. For example, once you’ve obtained a document as a scanned document, you could get the date from the document, like this:

get the attachment as a scanned document
get the document's "date"

If the date is not found, an exception will result.


the Keyword

We use the quite often in Kognitos to convey a new object we will be working with. We continue using the to denote the words immediately after are an object that we are referencing.

get the document's fields as the fields

When we use the keyword the, Kognitos knows to expect an object we are going to work with.


imagine Keyword

This is used to declare a variable as a placeholder. For example: (need to find good real world example)


imagine a ___________

add the _____ to the _____

It’s worth noting that use of imagine is not always required. This is very handy when you need to create a list of items, and is often used with the keyword “add”, as shown above.


process each x as follows Keyphrase

Description:

The action "process each x as follows" outlines a sequential method to handle each instance of 'x' (where 'x' is a variable representing a specific element, object, or item) through a series of predefined steps. This iterative process ensures each 'x' undergoes the same treatment, manipulation, or evaluation, making it a crucial action in workflows where consistency and thorough examination or modification of multiple items are necessary.


Usage:

This action is typically used in scenarios requiring batch processing, lists or where each item of a particular type needs to be individually addressed through a consistent procedure. It's common in data processing, document handling, and operations on collections of objects.

process each page as follows
  get the page's classification marker
  add the above to the jobnumbers


add Keyword

This operation is employed when you intend to integrate one set of data into another. Using 'add', you can accumulate or amalgamate specific segments of data, such as pages in a document, under one manageable variable. This is particularly helpful when you need to group or categorize data individually.

For instance, if your task involves identifying and organizing a series of identification documents from multiple pages, you can leverage 'add' to streamline this process.

Here's a syntax illustration:

imagine the ids
process each attachment as follows
	get the attachment as a scanned document
  process each page
  get the page
		if the classification is "id" then
			add the page to the ids

In this context, 'add' operation assists in aggregating all the pages marked as "id" under the 'ids' variable, facilitating swift classification and convenient access to the identified document pages.

use Keyword

What It Does:

Specifies an item to be utilized or acted upon in the given context or process.

Usage:

"Use" is employed when a specific entity, like a document, variable, or data point, needs to be identified and operated on within a procedure or operation.

Example - Processing Purchase Orders (POs):

When processing each new PO, follow these steps:

  • Use the new PO as the PO: This means taking the new purchase order that has come in and making it the current focus for any subsequent actions or processing steps.
process each new po as follows  
    use the new po as the po  
    get the po as a text

set Keyword

This keyword is used to set the value of a variable. Regardless of what the variable contains, this keyword will assign whatever value to the variable. For example, if you have “the variable” set to “some string” and you want to set it to [1,2,3], this can be accomplished by:

use "the wingnut" as the variable`

`set the variable to "[1,2,3]"`

remove Keyword

This keyword can be used to remove specific words or characters from a given variable. For example, if you want to remove “the” from a variable, you would do this:

use "the wingnut" as the variable

remove "the" from the variable <----output is " wingnut"

convert Keyword

This word is used primarily to convert specific data from one form to another. Here is an example of how to use this term to convert a written date to a date format:

the date is "July 14 2017"  
the format is "%d/%m/%Y"  
convert the date to the format

Convert can also be used to convert files from one format to another. Here is an example of how you would convert a picture file (png / jpg) to a pdf:

convert a file to a pdf file with
  the file is the picture

merge(Document) Keyword

On occasion, it will be necessary to combine multiple PDFs into a single document. Here is an example where all input files are merged into a single file:

get the attachments  
get the above as the scanned documents
merge the scanned documents into a single document where\`
`the document name is "statements.pdf"

send an email Key term

This is a key term that has several nuances and options. For this reason, this term has it’s own page that can be found here.

stop and terminate Key term

Sometimes, in a procedure you may want the automation to stop working on a specific item in the batch based off a condition. You can do that by simply saying stop.

if the partner is unknown then
  stop

If you want the computer to stop the entire automation and not just the specific item being processed in the batch,  use terminate.

if the partner is unknown then
  terminate

Calculating

Kognitos can be used to calculate various amounts of information in a workflow. All you need to do is tell it what to calculate using plain english.


Kognitos can be used to calculate various amounts of information in a workflow. All you need to do is tell it what to calculate using plain english.


John's salary is 150000\*1.2+1000  
send "Your new salary is {John's salary}" to John

\-1.3\_((10_3)\*2.1/3.4)^2.3  
say the answer


Converting a thing to another form (as a Y)

get the file as a scanned document
the file is a scanned document
use the answer as a date

In the above examples the file is converted (or attempted to be converted to) a scanned document and the answer is converted to a date. The Kognitos brain knows how to convert between common types but can be easily taught to convert between new types.

Comparison facts

andy's age is 21
john's age is 22
jim's age is 20
the people are andy, john and jim

age is how old or how young something is

the youngest person out of the above
the oldest person out of the people

Kognitos knows how to compare some common types. However, if a custom comparison is needed to be taught, it can be done as above. In the above example it learned that it needs to look at the ageproperty of things to figure out if they are younger or older than each other.


Looping Through Data

When building an automation, you may run into a scenario where you want to repeat similar behavior for multiple items; we call that sequence of instructions a loop. So when you process each item in a set, we call that looping through a set.

Some examples of when we would need a loop are when we want to processes attachments in an email, convert the total amount for each line in a list of line items to a new currency, or loop through all the different names of recipients for an email. To process each item, we want to tell the automation "complete the following actions for each object".

To instruct the automation we are starting a loop, we follow the structure of using the keywords process and as follows.

The key phrase we would write in Kognitos to start a loop is:

process each XXXXX as follows

So we could write this as:

process each document as follows
process each file as follows
process each word as follows

Then once we have declared we are starting a loop, any instruction we would like our automation to follow for each item we are loping through, we would write underneath and indent each line.

For example:

process each document as follows
	get the document's invoice number
	get the document's fields

By indenting the lines after process each document as follows, Kognitos will know which instructions to follow for each item.

It is very important to remember to indent when looping through objects in your automation!

And again, in Playground, it will be formatted in a way to make it very clear which instructions relate to looping through the items:


Decision Logic

Your automations can also make decisions based on logic. The words ifthen, and else are important in commanding the automation how to make decisions in workflows. See examples in more detail below.

if then Logic

To write a decision point in your automation we use the format:

if CONDITION then
  TAKE THE ACTION

So for example:

if the number of team members < 10 then
	send "Let's have lunch outside!" to the team members

Here are some other examples of possible conditions:

if the name is bob then
  ...
if the employee's address contains "USA" then
  ...
if the amount * 1.2 > 5000 then
  ...
if the amount is the balance due then
  ...
if the employee's age >= 18 then
  ...
if the employees's age >= 18 then
  ...
if the loan amount > 100000, the maximum loan amount, or 1.2 * the bank balance then
  ...
if the loan amount < 200000 and the maximum loan amount then
  ...
if the loan amount and the bank balance < 20000 then
  ...
if the name is "mary" or "bob" then
  ...
if (the name is not "mary" or "bob") and (the address contains "USA") then
  ...
if the employee's address is unknown then
  ...
if the employee is angry then
  ...

if then else

If then statements allow you to say "if this condition is met, do this", using an else statement can increase your options when the automation is running. For example:

if the number of team members < 10 then
  send "Let's have lunch outside!" to the team members
else
  send "Meet you in the cafeteria!"

In this example, the automation reads "If the number of team members is less than 10, then send 'Let's have lunch outside'. But if the number of team members is 10 or more, send them 'Meet you in the cafeteria'". Else allows you to add a condition of what to do if the condition is NOT met.

Nesting if then Statements

More levels of business logic complexity can be handled:

if the partner is "partner a" then
  use 0.1 as the rate
else
  if the partner is "partner b" then
    use 0.2 as the rate
  else
    use 0.4 as the rate

Note that else is optional can be omitted if not needed.

👍

Just like with loops, remember to indent your actions following an if then statement