# Setting Timers

The [Timer](../../actions/the-start-timer-action) Action can be used to run Action Chains at designated times. Timers have the capability to run at a specified time and also have options to be [TCPA](../../security-and-compliance/tcpa) compliant as well.  For example, a Timer can be set to send a reminder to a customer 5 minutes before their selected call time.

![organizing info](https://4185914948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSItjRhbHaLQ4ar3DUljt%2Fuploads%2Fgit-blob-8bab89db841f98447c31dc156ce1e3a3b71986d6%2Fsetting-timers-v181-0.png?alt=media)

But sometimes, that reminder may be set to send outside of TCPA compliant hours. In order to comply by TCPA restrictions, Timers have the option to pass in a TCPA compliant [Availability Schedules](../../studio/builder-bar/schedules-builder) from the customer's timezone and send the reminder in the previous/upcoming available window.&#x20;

![organizing info](https://4185914948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSItjRhbHaLQ4ar3DUljt%2Fuploads%2Fgit-blob-29c17c452ae25086b54d83456acfc2225b39e264%2Fsetting-timers-v181-1.png?alt=media)

## Best Practices using Timers

* When using Timers for customer reminders, it is always good practice to comply by TCPA restrictions. Check out [How to enforce TCPA](../../security-and-compliance/tcpa) for more information.
* Timer Keys are required to be unique across the application when creating timers.
* It is good practice to use the [Stop Timer action](../../actions/the-stop-timer-action) when the Timer is no longer needed in the customer journey. Don't rely on session management to cancel the timers.
* Build out Timers that are tied to events. This enables you to have full control over the inputs and management of your Timers.
* Timers only have access to data that is tied to the client state. If a Timer is created on an event, data cannot be passed from the event namespace to an action in the timer. If passing data from the event namespace, data must be stored in a temporary variable and then pass the temporary variable to the actions associated with the timer.

## Augmenting Timers based on Availability Schedules

Like mentioned above, Timers have the ability to run based off of a specified [Availability Schedule.](../../studio/builder-bar/schedules-builder) This section will walk through how to set up a timer to execute 5 minutes before a selected appointment time and comply with TCPA restrictions.&#x20;

1. Create a timer in the Action tab of the control. This example will be adding it to the value changed of the [Scheduler Web Control](../../web-controls/scheduler-web-control), but Timers can be created in many other events as well.&#x20;

![organizing info](https://4185914948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSItjRhbHaLQ4ar3DUljt%2Fuploads%2Fgit-blob-04c9145b1d175fca344b44d2451b517abd39d879%2Fsetting-timers-v181-2.gif?alt=media)

2. In the Start Timer configuration, you can either specify a time or add a custom expression. To schedule a Timer to run based off the selected time slot, a [DateTime](../../variable-data-types/the-datetime-variable-data-type) has to be passed in as a custom expression and then modified using the [SUBTRACT\_FROM\_DATETIME](../../airscript-expressions/datetime-functions/subtract_from_datetime) function. In the Custom Expression, enter the following Airscript expression:

```javascript
SUBTRACT_FROM_DATETIME(event.value.start_time, 5, "m")
```

This will pass the start\_time and subtract 5 minutes. The output of the time will be the time that the timer executes. &#x20;

![organizing info](https://4185914948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSItjRhbHaLQ4ar3DUljt%2Fuploads%2Fgit-blob-09eb147f4a15141f14a97a46512cb5bff41a92ab%2Fsetting-timers-v181-3.png?alt=media)

3. Once the execution time is defined, then determine if the Timer requires any restrictions to be TCPA compliant.  Select a calendar and choose what action to take if the time is not available or within the calendar window. You can choose from the following:
   * Don't Schedule and cancel
   * Use next available time
   * Run in previous available window
   * Schedule anyway

![organizing info](https://4185914948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSItjRhbHaLQ4ar3DUljt%2Fuploads%2Fgit-blob-73d4c07244e9e54371662ce176ff2473023c85eb%2Fsetting-timers-v181-4.png?alt=media)
