> For the complete documentation index, see [llms.txt](https://doc.moost.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.moost.io/platform-manual/rules/rule-language/syntax.md).

# Syntax

In this example we see already all core elements of the language.&#x20;

In the following chapters you see many more examples, and all details about what kind of functions and operations exist, and how you can compose the data.

Example of a condition term:

<pre class="language-java" data-overflow="wrap" data-full-width="false"><code class="lang-java"><strong>$GridPowerConsumption > 500 AND ($CarChargingMode = 0 OR $CarChargingMode = 4) AND $IsLowTariffHours = 0
</strong></code></pre>

Example of a message term:

{% code overflow="wrap" fullWidth="false" %}

```java
"Sie beziehen aktuell " + ($GridPowerConsumption / 1000) + "kW vom Netz."
```

{% endcode %}

Following syntax base components exist:

## Literals

### Variables

#### Example

```java
$GridPowerConsumption
```

Example of a variable referring to the dataset with name "PowerConsumption"

### Values

#### Example

```java
1.5
```

Example of a *number* value&#x20;

```java
"it is cold"
```

Example of a *text* value&#x20;

```java
30min
```

Example of a *timespan* value

```java
now
```

Example of a time value

## Functions

#### Example

```java
AVG($PowerConsumption)
```

Example for calculating the average

## Operations

#### Example

```java
1.2 * 42
```

Example for multiplying two numbers

## Brackets

Brackets may be needed to control the resolution order of the terms in the expression. \
This is very familiar to us of course in mathematical terms:

#### Example

```java
((4 + 0.5) / (4 - 0.5)) * 2
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://doc.moost.io/platform-manual/rules/rule-language/syntax.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
