Alerts are special transactional emails that notify your users of content on your site that matches certain custom criteria.
For example, if you are an e-commerce site, a user may want to be notified whenever certain types of products in certain price ranges are released. Or if you are a news site, a user may want to be notified about articles about certain topics.
Sailthru Alerts provides an engine to track these user preferences and easily send these notifications.
Alerts come in two basic types: realtime alerts and summary alerts. You may use either or both.
In general, there are four steps to setting up alerts:
Decide what you want users to be able to filter alerts by. You might have a simple system where you match against tags, or you might want a variety of pieces of metadata.
For the sake of the example, let's suppose we're a clothing retail website and we want users to be able to filter by price (a number), brand (a string), and tags (an array of strings). In addition, all products will have a description which users won't filter by.
Set up templates for your alerts. You should have at least one template for realtime alerts, and at least one template for summary alerts. You can use any number of different templates.
Realtime alerts can use any variables you intend to pass in for your content. Let's say we create a template called alert_realtime that looks like this:
<p>The following product matches your criteria:</p>
{foreach content as c}
<h2><a href="{c.url}">{c.title}</a></h2>
<div>${number(c.price/100,2)}</div>
<p>{c.description}</p>
{/foreach}
Summary alerts expect a variable called content to contain an array of the matching pieces of content. Let's say we create a template called alert_daily that looks like this:
<p>Here's your daily roundup of products:</p>
{foreach content as c}
<div><a href="{c.url}">{c.title}</a> (${number(c.price/100,2)})</div>
{/foreach}
Build a user preferences page that allows users to customize their alerts settings and calls the alert API call to set those preferences on Sailthru side.
See the documentation for the alert API call for all the details – for now let's set up a simple example. Let's say we want realtime alerts on anything Prada that is $300 or less in price:
email=example@example.com type=realtime template=alert_realtime match[brand]=Prada max[price]=30000
And a daily summary every day at 6pm of all products tagged handbag:
email=example@example.com type=daily template=alert_daily when=6pm tags=handbag
You need to push content to Sailthru whenever it is published so that matching realtime alerts can be triggered. Content will also be automatically stored on Sailthru-side for the summary alerts.
The best way to achieve this is make your content management system execute the content API call when a piece of content is first made live.
All content must have a title, url, and date, may contain any number of tags, and and may have any number of custom vars. If you don't pass a date, it will use the current timestamp.
An example content push that would match both filters:
title=New Prada Handbag url=http://example.com/prada-handbag-23 tags=handbag,designer vars[price]=23999 vars[brand]=Prada vars[description]=A great Prada handbag for a reasonable price!