Personalizing Automations Using Custom Events

You can trigger automated messages from custom events, and you can personalize these messages with values from the custom event that triggered the message.

You can insert Dynamic Content Variable message content using handlebar syntax that you populate at send time. Use dynamic content to personalize messages for each member of your audience. in any automation when you configure the Custom Event trigger.

Custom events help you track user activities and conversions from your app, website, etc. You can use Airship's handlebar syntax to populate automated messages with values from custom events, so that your automated messages are relevant to each individual in your audience.

Accessing Custom Event Properties in a Message

Start by creating an automation using the Custom Event trigger, and select one or more custom events (or event properties) to trigger the automation. Custom events are associated with a channel or a named user; when the event occurs, Airship sends the associated user a message.

When writing your message, you can reference properties in the events that trigger your automation in the $data.events.[0].properties namespace. For example, you might reference an event property called "items_purchased" at {{$data.events.[0].properties.items_purchased}}.

If you reference a property that is not in an event, is null, or empty, and you do not set a default value for that property, the reference will be empty at send time, and your message may not make sense. Make sure you use event properties that you know will be present and populated, and set default values to ensure that your message makes sense if variables are empty or absent.

 Tip

Use the $def handler to specify a default value, to make sure that your message makes sense even if a property or value does not exist. For example, {{$def $data.events.[0].properties.name "you"}} would insert you in the message if the custom event that triggers your message does not have a name property.

Templates for Automated Messages

You can create templates for automated SMS, MMS, email, and Open Channel messages, so you can store and reuse automated messages with custom events. Templates for automated messages use handlebar Airship's message personalization syntax using double curly braces ({{handlebars}}). You can use handlebars to insert variables and conditional logic in messages and templates. syntax, and expect to access event properties in the $data.events.[0].properties namespace.

 Tip

Label your automation templates to differentiate them from non-automation templates. Because you personalize automated messages with variables in a different namespace than non-automated messages, you wouldn't want to reuse a template designed for automation in a standard message.

Personalized Automation Example

For example, if you have a custom event representing a purchase, you can send an automated message confirming the purchase and providing information about what the user bought.

Custom Event

{
   "occurred": "{{event_time}}",
   "user": {
      "named_user_id": "user"
   },
   "body": {
        "name": "purchase",
        "subscribe": true,
        "properties": {
            "customer_name": "user",
            "total": "$48",
            "units": "USD",
            "items": [
                "MLB regulation baseball", "Louisville Slugger"
            ]
        }
    }
}

Message Content

Hi {{$def $data.events.[0].properties.customer_name "valued customer"}}!

Thanks for ordering:
{{#each $data.events.[0].properties.items}} 1x {{.}}\n{{/each}}
total: {{$data.events.[0].properties.total}}{{$data.events.[0].properties.units}}

We'll message you again when it ships!