# Keywords

### 1. `the` Keyword

Introduces a new object, concept, or data element.

**Example**

In this example, we are introducing a **file** to Kognitos.

```undefined
the file
```

### 2. `get` Keyword

Used 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.

```undefined
get the document
get the document's "id"
get the document's "date"
```

### 3. `find` Keyword

Used to search for and obtain details from a document.

**Example**

Here, we are searching for a document's `date` and `invoice number`.

```undefined
find the document's "date"
find the document's "invoice number"
```

### The difference between `get` and `find`

Both `get` and `find` can be used to obtain information from a document:

```undefined
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.

<figure><img src="https://files.readme.io/4d70dcb-Screenshot_2024-07-02_at_1.54.55_PM.png" alt=""><figcaption></figcaption></figure>

### 4. `use` Keyword

Use the `use` keyword to reassign a data element, which **copies the reference** to the original data value:

```
use <data value> as the <data name>
```

{% hint style="warning" %}

#### Warning: Overwriting Data

Updating a referenced data element can overwrite previous data — see Example 2 for more details.
{% endhint %}

#### Examples

1. In this example, the **registration date** is reassigned the value `11-05-2024`.

```undefined
use "11-05-2024" as the registration date
```

2. In this example, **the order name** is assigned a copy of the reference to **the last name**, meaning it will point to the same value.

```undefined
use the last name as the order name
```

If the last name changes, the order name will also change, because it references the same value. When the last name changes to `Smith-Brown` (line #3), the order name also changes (line #4):

{% code lineNumbers="true" %}

```
the last name is "Smith"
use the last name as the order name
the last name is "Smith-Brown"
the order name
```

{% endcode %}

### 5. `say` Keyword

Outputs the value of a data element or text.

**Examples**

```undefined
say "Hello World!"
```

```undefined
say the name
```

### 6. `stop` Keyword

Halts a run or process from progressing further.

**Example**

```undefined
say "Hello!"
stop
say "Goodbye!"
```

In this example, `say "Goodbye!"` will not run.

### 7. `imagine` Keyword

The `imagine` keyword is used to declare a data element as a placeholder.

**Example**

```undefined
imagine a value
imagine templates
```

### 8. `set` Keyword

Assigns a specific value to a data element.

**Example**

```undefined
set the name to "John Smith"
```

In the example above, `the name`is assigned the value `John Smith`.

### 9. `remove` Keyword

Used to delete specified elements, such as characters, words, or items, from a variable or dataset.

**Example**

```undefined
remove punctuation from the text
```

### 10. `convert` Keyword

Transforms data from one format to another.

**Example**

```undefined
convert the file to a gif file
```

### 11. `add` Keyword

The `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.

```undefined
add 10 and 5
```

**Date and Time Addition**

Used to add a specified time duration to a given date.

```undefined
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.

```undefined
add a column to the table
```

### 12. `contains` Keyword

Used 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!"
```

**Example 2: Sets**

In this example, `contains` is used to check if **oranges** is present in the set of values.

```undefined
the values are "apples", "bananas", "oranges"
if the values contain "oranges" then
    say "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**

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**.

```undefined
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

The `ask` keyword is used to ask a question to the user. The question will be raised as a [custom exception](/legacy/legacy-experience/exception-handling/using-ask-with-custom-exceptions.md). Additionally, you can specify answers as a set of choices.

#### Examples

```undefined
ask "What is your age?"
```

```undefined
ask "The access code"
```

```undefined
ask "When does the flight depart?"
  the choices are "Morning", "Afternoon", "Evening"
```

```undefined
ask "preferred language"
  the choices are "English", "Spanish", "Hindi", "French"
```

### 14. `the above` Keyphrase

When a data element's value is set to `the above`, Kognitos makes a **copy of the value** from the previous lines in the automation:

```
<data name> is the above
```

#### Examples

1. In this example, **the backup email** is assigned the value `john@example.com`.

```
the customer email is "john@example.com"
the backup email is the above
```

2. Here, **the invoice total** is assigned the value `150`.

```
the order total is 150
the invoice total is the above
```

3. In this example, **the file** is assigned a copy of the above file in the automation.

```
the file is the above
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kognitos.com/legacy/legacy-experience/writing-automations/automation-basics/keywords.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
