> For the complete documentation index, see [llms.txt](https://docs.connectedyou.io/knowledge-base/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.connectedyou.io/knowledge-base/connectedyou-platform/user-guide/automation/rules.md).

# Rules

Automation is important for proactive monitoring & immediate actions. Users can create automation logic and monitor the history here.

Users can create rules here and enable/disable/delete them.

![](/files/N4RTm50Hrqe8WGGoygSF)

Basic table features&#x20;

* Search: for a rule applied on a specific SIM via EID/ ICCID of the SIM or via Tags&#x20;
* Filtering/Sorting: the table allows filtering/sorting where applicable and resetting of the filters&#x20;
* Column selection: select the columns to be displayed&#x20;
* Pagination: select how many rows of data should be displayed & navigate multiple pages

The Transactions detail summary table is explained below.

| Item          | Explanation                                                                                                                                                                |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Name          | Rule Name created by user                                                                                                                                                  |
| Event         | The event type triggered by the rule                                                                                                                                       |
| Target Count  | Count of SIMs/ Profiles targeted by the rule - either via ICCIDs or EIDs                                                                                                   |
| Actions       | Summary of actions to be executed by the rule, there can be multiple.                                                                                                      |
| Status        | Describes if the rule is currently Enabled or Disabled. ‘Completed’ indicates a rule that has been set to be executed only once and is now completed & therefore disabled. |
| Change Action | Users can toggle between enabling/ disabling a rule and can also delete a rule.                                                                                            |

Rules are a compilation of 4 elements along with some configurations.&#x20;

* Trigger
* Target&#x20;
* Setup
* Actions

## Header&#x20;

Header allows the user to create a rule with a Short name and description to identify the rule.

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

## Trigger

What triggers the rule? The available triggers in the platform are:&#x20;

* Usage Monitoring &#x20;
* Events&#x20;
  * IMEI change
  * Country change
* Service change
  * SIM profile state

### **Usage Monitoring**&#x20;

This trigger allows a user to select conditions for the usage type to have breached. These are broken down into the amount of usage and the period of the usage.

There are various combinations of periods the user can select - some are static (e.g. calendar month) and some are to monitor a moving period (past months).

![](/files/uKv8BvT0EczhcKOc3KIa)

**Important:**

Usage Monitoring is based on **Call Detail Records (CDRs)** received from the mobile network operator.

A CDR is **not generated while a data session is in progress**. Instead, it is typically generated **after the data session has ended**. Once the CDR has been generated, it is sent to the ConnectedYou Platform where it is processed and evaluated against any configured Usage Monitoring rules.

Under normal conditions, CDRs are typically received within **30 minutes** after the data session has ended. However, the exact timing depends on the mobile network operator and may occasionally take longer.

Because of this, Usage Monitoring is **not real-time**. Any actions configured using usage thresholds are triggered only after the relevant CDR has been received and processed.

#### Example

A rule is configured to **suspend a SIM when the usage is more than 500 MB of data**.

<table><thead><tr><th width="90.66668701171875">Time</th><th width="93" align="right">Usage</th><th>What happens</th></tr></thead><tbody><tr><td>10:00</td><td align="right">0 MB</td><td>Data session starts.</td></tr><tr><td>10:12</td><td align="right">500 MB</td><td>Threshold is reached, but the session is still active. No CDR has been generated yet.</td></tr><tr><td>10:18</td><td align="right">550 MB</td><td>Session ends. The network generates a CDR (CDR-A).</td></tr><tr><td>10:19</td><td align="right">550 MB</td><td>A new data session starts.</td></tr><tr><td>10:42</td><td align="right">650 MB</td><td>The ConnectedYou Platform receives the CDR (CDR-A), evaluates the rule, and suspends the SIM.</td></tr></tbody></table>

**Result**

Although the rule was configured for **500 MB**, the suspension was applied after the platform received and processed the CDR from the mobile network. As a result, the SIM consumed **650 MB** before the suspension took effect.

### **Events**

#### IMEI Change

This allows a user to select the “From” and “To” IMEI types with “Any” triggering the rule for any device change.

![](/files/cwC57OufmbglrvAvZvU0)

#### Country Change

This allows a user to select between entering/ leaving geofence or Any location changes for specified countries.

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

### Service Change

This allows a user to trigger a rule due to a SIM-profile (ICCID) state changing (to Active/ Suspended/ Terminated/ Any).&#x20;

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

## **Target**

The rule trigger will only happen for the SIMs/ Profiles (ICCIDs/EIDs) selected in the target section. User has a choice to select apply to all or a selected few.

![](/files/P6GqAzpYFjch74HaREpc)

The target options change between allowing EIDs or ICCIDs depending on the type of rule trigger.&#x20;

## Setup

The Setup information carries the following and can change in terms of options depending on the trigger type:&#x20;

* **Re-Evaluate**: This defines if the rule will run only once or forever. It is not applicable for certain triggers and is set to NEVER by default.&#x20;
  * **Always**: The rule will be evaluated each time it is triggered for the specified target indefinitely.&#x20;
  * **Begining of next calendar day**: If the rule has been evaluated in the calendar day (UTC), it will be disabled until the next calendar day starts when the rule will be evaluated again if triggered.
  * **Begining of next calendar month:** If the rule has been evaluated in the calendar month (UTC), it will be disabled until the next calendar month starts when the rule will be evaluated again if triggered.
  * **Never**: The rule will be marked as COMPLETED after one successful evaluation.&#x20;
* Enable/ Disable Status: Users can create rules in an Enabled (default) or disabled state.

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

## &#x20;**Actions**

A user can select up to 10 actions triggered for a rule. They will be triggered in the order created (if applicable).

The Action types available in the platform are:

* Email: user can enter up to 10 recipients in an email action

![](/files/xQMUqyHEqhmPWTT46K0h)

* Billing State Change: user can activate/ suspend/ terminate a SIM either of a particular connectivity profile profile or “Any”. (!!) Exercise caution in targeting the “Terminated” State with automation as this is an unrecoverable state.

![](/files/gk4fvvz2zwnoI3ql2iLx)

* Webhook: user can set up a webhook URL and optionally add header name and value for the action

![](/files/OWgpHCxd1CQ6X8BzMfJO)
