> For the complete documentation index, see [llms.txt](https://docs.rulecube.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rulecube.com/v2.5/how-to-guides/ruleset-development/generate-alerts.md).

# Generate Alerts

## Introduction

This guide explains how to create an alert for a ruleset.&#x20;

**Alerts** are a special type of rule that allows you to check whether the input or a calculated result meets business rule conditions. For example, if the age of a new subscriber must be 18 or older, you can have an alert checking the age and signaling a message if the applicant is too young.

## Procedure

Let's work the '18 or older'-rule out into an alert. To do so, you'll first create a rule that calculates the age and then an alert that checks the age:

1. Create a ruleset named `AgeCheck`.

2. Create an input named `DateOfBirth` with **Type** = `date`.

3. Click the **+** sign behind **Rules** from the left menu.\
   ↳ The **Rule details** page opens.

4. In the **Name** field, enter the name for the rule. For example, `SubscriberAge`.

5. In the **Expression** field, enter the following code to calculate the age:<br>

   ```javascript
   AGE(DateOfBirth)
   ```

6. Click **Save**.

7. Click the **+** sign behind **Rules** again to create the alert.

8. In the **Name** field, enter the name for the rule. For example, `AgeCheck`.

9. In the **Expression** field, enter the following code to calculate the age:<br>

   ```javascript
   SubscriberAge < 18
   ```

   \
   ↳ This code refers to and uses (the result of) the `SubscriberAge` rule.<br>

10. Select the **Generate alerts** checkbox.\
    ↳ Rulecube adds the **Alert settings** section to the page.

11. In the **Alert type** list, select **Error**.

12. In the **Title** field, enter `Too young to subscribe`.

13. Select the **Enable expression** checkbox.

14. In the **Message** field, enter the following expression:<br>

    ```javascript
    `The subscriber is ${SubscriberAge} years old and should be 18 or older.`
    ```

    \
    Notice the backticks as the expression is template literal.<br>

15. Click **Save** followed by **Try it out!** to open the sandbox for the ruleset.

16. In the DateOfBirth input, enter a birthdate younger than 18.

17. Click **▸Execute.** \
    ↳ The **Results** section shows an alert like this:<br>

    <figure><img src="/files/afcw1FxAi7171WcYHCbu" alt=""><figcaption></figcaption></figure>

18. Now, try the ruleset with a valid birthdate.


---

# 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 dynamically by asking a question.

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

```
GET https://docs.rulecube.com/v2.5/how-to-guides/ruleset-development/generate-alerts.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.
