Scheduled Alerts Guide

Use Case: Subscription Expiration Reminder

You want to send out an automated email 30 days before a customer’s subscription to your service expires.

Step 1: Define Device Attributes

In your Device Type define an attribute called subscription-expiration. This attribute will store a timestamp indicating when the subscription expires. Your web application calculates the expiration timestamp and sets the value in the Arrayent Cloud. Next, define an attribute called subscription-reminder. This attribute will be used as the trigger to an email alert. When subscription-reminder equals 1, the Arrayent Cloud will send out an automated email to the user informing him that his subscription is soon to expire.

Step 2: Set Subscription Expiration

The subscription-expiration attribute stores a timestamp representing the date that the subscription expires. The timestamp must be formatted in UNIX time. Be careful when using UNIX time functions. Most of them return the current time in seconds, notmilliseconds (if your library returns values in seconds, just multiply the value by 1000 to convert it into milliseconds). How do you calculate a subscription expiration date? A subscription that started at 12:00AM GMT on Friday, 21 November 2014 would have the following timestamp in UNIX time:


Suppose the subscription expires after 1 year, which is equivalent to 31556926000 milliseconds. To calculate the subscription expiration timestamp, you just add 31556926000 to the subscription start date:

1416528000000 + 31556926000 = 1448084900000

When the end user subscribes to your service, your web application must set the value of subscription-expiration to the appropriate timestamp:

Step 3: Define Email Alert

Create an alert that is triggered when subscription-reminder is 1. For now just read on. This step will make more sense after you finish reading the next step.

Step 4: Define Scheduled Alert

Define your scheduled alert in the Arrayent Cloud. If we’re programmatically creating our alerts via the Arrayent Web Service API, then the alert definition looks like this:
"subscription-expiration","operation":"BEFORE", "thresholdValue":"2629743000”,

If we’re using the Utility application, then the alert definition looks like this:

The Arrayent Cloud checks if the current time is within 30 days of the expiration date. If so, then the scheduled alert is triggered and the cloud automatically sets subscription-reminder to 1. This triggers the email alert that we defined earlier.