Automation Basics
Learn the essential keywords, terms, and concepts for building automations.
Keywords
This section outlines the basic keywords in Kognitos, their usage, and examples.
1. the
Keyword
the
KeywordIntroduces a new object, concept, or fact.
Example
In this example, we are introducing a file to Kognitos.
the file
2. get
Keyword
get
KeywordUsed to retrieve objects or to obtain values from a document.
Example
In these examples, we are first retrieving a document, and then retrieving the id
and date
values from the document.
get the document
get the document's "id"
get the document's "date"
3. find
Keyword
find
KeywordUsed to search for and obtain details from a document.
Example
Here, we are searching for a document's date
and invoice number
.
find the document's "date"
find the document's "invoice number"
The difference between get
and find
get
and find
Both get
and find
can be used to obtain information from a document:
get the document's phone number
find the document's phone number
The difference between the two is how they handle exceptions when a specified item is not found in the document:
- The
get
keyword raises a Question and pauses execution. - The
find
keyword returns Not Found and continues execution.
4. use
Keyword
use
KeywordThe use
keyword specifies an item to act upon in a given context or process.
use the email address
It can also redirect the system to take an existing item and use it for further actions or assignments.
In this example, this system is instructed to use the email address as the contact email for any subsequent processing steps.
use the email address as the contact email
5. say
Keyword
say
KeywordOutputs the value of a fact or text.
Examples
📝 Example 1
say "Hello World!"
📖 Result
Hello World!
📝 Example 2
say the name
📖 Result
John Smith
6. stop
Keyword
stop
KeywordHalts a run or process from progressing further.
Example
say "Hello!"
stop
say "Goodbye!"
In this example, say "Goodbye!"
will not run.
7. imagine
Keyword
imagine
KeywordThe imagine
keyword is used to declare a fact as a placeholder. It will create a blank variable with the provided name.
Example
imagine a value
imagine templates
8. set
Keyword
set
KeywordAssigns a specific value to a variable.
Example
set the name to "John Smith"
9. remove
Keyword
remove
KeywordUsed to delete specified elements, such as characters, words, or items, from a variable or dataset.
Example
remove punctuation from the text
10. convert
Keyword
convert
KeywordTransforms data from one format to another.
Example
convert the file to a gif file
11. add
Keyword
add
KeywordThe add
keyword is used to combine, extend, or append data to an existing set or structure. This includes both mathematical addition and data aggregation in various formats.
Arithmetic Addition
Used to add two numerical values to produce a single sum.
add 10 and 5
Date and Time Addition
Used to add a specified time duration to a given date.
the date is "2024-11-01"
add two days to the date
Data Aggregation
Used to expand datasets by adding new items, rows, or entries.
add a column to the table
add the invoice as a row in the worksheet
12. contains
Keyword
contains
KeywordUsed to check if a string, list, or dataset includes a specific value.
Example 1: Strings
In this example, contains
is used to check if the surname Smith is present in the full name John Smith.
the full name is "John Smith"
if the full name contains "Smith" then
say "The surname is correct!"
Result:
The surname is correct!
Example 2: Sets
In this example, contains
is used to check if oranges is present in the set of values.
the values are "apples", "bananas", "oranges"
if the values contain "oranges" then
say "The oranges are available."
Result:
The oranges are available.
Example 3: Tables
The contains
keyword can be used with tables to retrieve rows whose columns include a specific value.
Example Table
Consider the following table that lists various zoo animals, their ages, and their favorite foods.
Animal | Animal Age | Favorite Food |
---|---|---|
🦁 Lion | 7 years | Meat |
🐘 Elephant | 10 years | Fruits |
🦓 Zebra | 3 years | Grass |
🦒 Giraffe | 7 years | Leaves |
🐒 Monkey | 4 years | Fruits |
The contains
keyword is used to retrieve the rows where the Favorite Food column includes the value Fruits.
get the table's rows whose Favorite Food contains "Fruits"
Result
Animal | Animal Age | Favorite Food |
---|---|---|
🐘 Elephant | 10 years | Fruits |
🐒 Monkey | 4 years | Fruits |
13. ask
Keyword
ask
KeywordThe ask
keyword is used to ask a question to the user. The question will be raised as a custom exception. Additionally, you can specify answers as a set of choices.
Examples
ask "What is your age?"
ask "The access code"
ask "When does the flight depart?"
the choices are "Morning", "Afternoon", "Evening"
ask "preferred language"
the choices are "English", "Spanish", "Hindi"
Facts
In Kognitos, a fact is an object defined for reference. Facts can be text, numbers, tables, or even objects like documents. This concept is similar to defining variables in software development.
Fact Definition
In this example, the name is defined as a fact. It is assigned the value John Smith.
the name is "John Smith"
Facts Can Have Adjectives
Facts can be defined with adjectives or descriptive words:
The primary customer name is "Smith"
Facts can be Plural
Facts can represent multiple values by listing them together, separated by commas.
the coupon codes are "SAVE20", "SALE2024" and "JUST4U"
John's email addresses are "[email protected]", "[email protected]" and "[email protected]"
Assigning Values to Facts
Text and Date Values
When assigning text or date values to facts, enclose them within double quotes (""
).
-
Text
the customer name is "Alice"
the message is "Welcome to Kognitos!"
-
Date
the due date is "2024-11-05"
Numeric Facts
Numeric facts can be defined for values like age, balance, rates, etc.
John's age is 21
Sam's bank balance is $120.20
the interest rate is 1.25
Renaming and Reassigning Facts
You can rename or assign a value to a fact by using as the
or is the
.
Example 1
In this example, the registration date is reassigned the value 11-05-2024.
use "11-05-2024" as the registration date
Example 2
In this example, the order name is assigned the value of the customer's last name.
the order name is the customer's last name
Example 3
In this example, the meeting date is assigned the value of tomorrow.
use tomorrow as the meeting date
Looping Through Data
A loop allows you to repeat actions for multiple items. In Kognitos, you can create a loop using process each x as follows
, where x
represents the item in a set.
Loops are especially useful for batch processing, where you need to handle multiple items in a consistent manner.
Syntax
To start a loop, use:
process each {item} as follows
{actions to perform on each item}
By indenting the lines after process each {item} as follows
, Kognitos will know which instructions to follow for each item.
Indentation is Key
It is very important to remember to indent when looping through objects in your automation!
Example
process each document as follows
get the document's invoice number
get the document's fields
Decision Logic
Kognitos allows your automations to make decisions based on logic. The keywords if
, then
, and else
help control how your automation behaves in different scenarios, enabling dynamic workflows.
if / then Syntax
The basic syntax for a conditional decision is:
if {condition} then
{do an action}
Example
if the number of team members < 10 then
send "Let's have lunch outside!" to the team members
if / then / else Syntax
To add more flexibility, you can use an else
statement to specify an alternative action when the condition is not met:
if {condition} then
{do an action}
else
{do a different action}
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!"
Nested if / then / else statements
You can nest if / then / else statements to add more layers of logic for more complex conditions:
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
Don't Forget to Indent
Proper indentation is crucial when writing if / then / else statements, especially when nesting them. It ensures the automation logic is clear, easy to follow, and runs as expected.
Need Additional Assistance?
If you run into any grammar issues or need assistance with your automations, don't hesitate to reach out! You can contact Kognitos directly via our Support AI Agent Chat (preferred) or at [email protected].
Updated about 2 months ago