# Time Restrictions

## Overview

This document provides an overview of the **Time Restrictions** feature within the **Datacake Rule Engine**. This feature allows users to specify time frames during which particular actions within a rule are permitted to trigger. If an action's associated time restriction is not met, the action will not execute, even if the rule's conditions are satisfied.

### Practical Use Cases

* **Work Shift Notifications**: Set up rules to notify specific team members based on shift times.
* **Off-Hours Monitoring**: Limit notifications to business hours or specific time frames to reduce unnecessary alerts outside working hours.
* **Daily or Weekly Alerts**: Schedule notifications or actions to occur only on certain days, for example, to align with weekly reporting needs.

### Video-Guide

{% embed url="<https://www.loom.com/share/2f6ccd54c537488ead2a5402126d728f>" %}

## Setting Up Time Restrictions

### **Create a Rule**

* Begin by selecting the **product** for which you want to create a rule. This rule will apply to all devices within that product.
* Choose a **trigger** condition (e.g., when a new measurement is received).
* Set the rule’s conditions, such as “temperature is less than 10°C.”

**Select an Action**

* Choose an action type (e.g., **Email**, **Webhook**, **SMS**, or **Downlink**) to execute when the rule’s conditions are met.
* Customize the action details, such as the recipient for an email.

### **Configure Time Restrictions**

<figure><img src="https://2221155863-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LNA8_b8wmabHgJ0QXoJ%2Fuploads%2FIqlJA7VPDDSCT6xbnXRk%2FCleanShot%202024-10-29%20at%2015.27.28%402x.png?alt=media&#x26;token=0c8eb1d0-43ca-4f85-b9dd-3df6cc46bc4f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2221155863-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LNA8_b8wmabHgJ0QXoJ%2Fuploads%2FwOvIucYWuBr7PF6hDiv5%2FCleanShot%202024-10-29%20at%2015.29.51%402x.png?alt=media&#x26;token=08fbd9c8-34af-4b17-9df6-36460aed6331" alt=""><figcaption></figcaption></figure>

* In **Advanced Settings**, enable **Time Restrictions**.
* Define the time frame for the action, specifying:
  * **Days of the Week**: Select specific days (e.g., Monday through Friday).
  * **Time Range**: Set the start and end times for each selected day.
* Example: Configure an email notification to send only from **12 a.m. to 8 a.m., Monday through Friday**. Notifications outside this period will not be sent.

### **Multiple Time Frames**

* For actions requiring more complex schedules, you can add multiple time restrictions. For example, create multiple time ranges within the same day.

### Using Multiple Actions with Individual Time Restrictions

The Time Restrictions feature allows you to configure different time frames for each action within a single rule:

* **Example**: Set an **Email** action to trigger only during a specified night shift (e.g., 12 a.m. to 8 a.m.) and a **Webhook** action to trigger at any time.
* This is ideal for workflows involving **shift-based alerts** or **targeted notifications** based on time-sensitive needs.
