Sailthru Alerts

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.

  • Realtime alerts are sent immediately after a piece of content is published. A realtime alert will contain a notification about a single piece of content.
  • Summary alerts are sent either daily or weekly. It will contain a roundup of all the pieces of content over the that were published over the specified time period. If there is no content that matches the alert criteria, the summary will not send.

In general, there are four steps to setting up alerts:

  1. Design what criteria you want to set up
  2. Create templates for your alert emails
  3. Integrate with your user preferences and the alert API call to set up alerts according to user preferences
  4. Integrate with your content management system to use the content API call to push content when it is published

Step 1: Design Criteria

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.

Step 2: Create Templates

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}

Step 3: Integrate Alert Management

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

Step 4: Integrate Content Pushing

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!
 
/var/www/docs.sailthru.com/htdocs/data/pages/alerts.txt · Last modified: 2011/01/18 12:11 by Ian White
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki