trigger

Triggers receive and react to events from the system or the Event API. They contain the Zephyr logic as well as the email actions and user updates that you want to occur as a result of the specific event received.

Transactional Triggers must be associated with a specific template. They can be configured to react to any of the following events associated with a transactional send of the template: a send, open, click, purchase, or cancel. Global Triggers allow you to react to any user behavior (for example, an action on your site) that you've sent using the Event API or Purchase API. Note that as an alternative to using triggers, all of the above events can start flows in Lifecycle Optimizer, which you can configure through a visual interface rather than programmatically.

Endpoint URL: https://api.sailthru.com/trigger


Transactional Triggers

Transactional triggers are specific to a template and event type. For each, in addition to the template name and event type, you will specify a relative time and any Zephyr code to run. For example, this trigger will accomplish the following: When the "purchase receipt" template is sent, wait one day and six hours time, then run the Zephyr to send a follow-up template:

Copy
{    
 "event" : "send",    
 "time" : "+1 day 6 hours",    
 "template" : "purchase receipt",    
 "zephyr" : "{api_send({'template':'post-purchase follow up'})}" 
}

Global Triggers

Global triggers are initiated by the Event API and are associated with a specific event type. For example, each time a user favorites an item on your site, you can make an Event API call with the event name "favorite" along with any user-specific data, and any trigger listening for the event name "favorite" will run. Global triggers require an event name, relative time, and zephyr code. For example:

Copy
{    
    "event" : "will_attend_concert",    
    "time" : "-1 day",    
    "zephyr" : "{api_send({'template':'reminder','vars':event.vars})}"}

There is no need to pre-establish an event name in the system--simply submit an event by a consistent name when it occurs. No action will be taken unless a trigger, Smart Strategies, or Lifecycle Optimizer, has been configured to listen for that event name. You may want to begin sending events as a first step prior to programming the actions that should be taken upon their receipt.

Custom Zephyr Scripts as Actions

The zephyr parameter is used for a custom Zephyr script. A trigger's possibilities are immensely increased when used with a Zephyr custom script. There are two special functions you can include with a trigger:

  • api_user - For updating user profiles
  • api_send - For sending transaction email

Making use of profile and message objects along with Zephyr can be quite powerful.

GET Mode

Optional Parameters

Parameter Description Example
template Name of the template welcome
trigger_id Trigger ID 4e2f17e46803fa2847000000
event Event Name user.register

Pass any of the above parameters to query your triggers by them, or pass no parameters and get all the triggers in the system.

Return Value

Field Description Example
template Name of the template welcome
triggers List of trigger items
Each trigger item has the following structure:
FieldDescriptionExample
trigger_idTrigger ID4e2f17e46803fa2847000000
timeTrigger timesomething like 10 mins 2 days 75 minutes
eventEvent - can occur on click, open, send, purchase or cancelclick
zephyrZephyr Syntax{api_send("template_name")}

POST Mode

Create a trigger

Required Parameters

ParameterDescriptionExample
templateName of the templatewelcome
timeTrigger time, must be integer value10
time_unitTrigger time unit - can be minutes, hours or daysminutes
eventEvent - set to occur on click, open, send, purchase or cancelsend
zephyrZephyr syntax{api_send("template_name")}
OR
ParameterDescriptionExample
eventName of the eventuser.register
timeTrigger time, must be integer value10
time_unitTrigger time unit - can be minutes, hours or daysminutes
zephyrZephyr syntax{api_send("template_name")}

Return Value

Same as GET mode

DELETE Mode

Delete single trigger or all triggers that exist on a template

ParameterDescriptionExample
templateName of the templatewelcome

Optional Parameters

ParameterDescriptionExample
trigger_idTrigger ID4e2f17e46803fa2847000000

If trigger_idparameter is not present, all triggers associated with the template will be deleted

Return Value

Same as of GET mode