Create Message Templates

Templates provide a way to personalize messages with information specific to each member of your audience, like first name, flight number, or order status. You can even pass complicated variables to your template.

When you create a template, you can use handlebars and merge fieldsA variable in your message or template that you want to populate with a personalized value for each member of the audience. Merge fields are wrapped in double curly braces — {{merge_field}}. to insert Dynamic ContentVariable message content using handlebar syntax that you populate at send time. Use dynamic content to personalize messages for each member of your audience. and personalize messages for each individual member of the audience. The Airship interface guides you through the process to create or edit your template much like creating a standard message.

When you’re done, you can reference your template when you create:

  • Automations for app, email, SMS, or open channels, using the Custom Event trigger in the dashboard or with the /pipelines API.
  • Messages for email, SMS, or open channels, using the Upload Users Audience option in the dashboard, or using the /create-and-send API.
 Tip

To use email templates for commercial messages, you must include an unsubscribe link. If you do not include an unsubscribe link in your template, your message must have the Transactional option selected.

After you select a template, you can click and then select Custom HTML to add or remove unsubscribe links to support your message.

  1. Go to Messages » Templates.

  2. Click Create Template.

  3. Select the Template Type. The App type represents push notifications for App and Web channels, and the Message Center type represents message center messages for your app channel.

     Note

    The App template type applies to both your app and web channels and represents the Push Notification message type for app channels.

  4. Enter a Name and a brief Description to help you identify the template in lists, and click Save and continue.

  5. Click Add to populate the different fields in your template.

    1. Enter information for the field, including variables and [Dynamic ContentVariable message content using handlebar syntax that you populate at send time. Use dynamic content to personalize messages for each member of your audience. ].

       Note

      When using handlebars to reference variables, you should define default values for your variables with {{else}}. The preview represents variables without default values as blank spaces, mimicking the behavior your audience will experience if they receive messages with unpopulated variables.

    2. Click Save after you populate each field.

    3. Repeat this step until you have populated all fields in the template.

  6. Click Save Template.

Use the Email WYSIWYG Editor

When creating an email template, you can write your own HTML, or build your email with the WYSIWYG editor.

Airship’s drag-and-drop WYSIWYG editor helps you assemble HTML emails and templates for email without having to write HTML yourself. The editor produces HTML that is compatible with any email client that accepts HTML emails, making sure that your audience sees the best version of your message. As new versions of Outlook and other clients are released, we make sure both your templates will work with them too.

You can choose one of Airship’s default email templates to get started, or you can create your own design using a Blank Template. Default templates are fully editable.

When creating an email template, you can create an HTML template by clicking Add for HTML Body.

  1. Select a default layout, or select Blank Template to design your own layout.

  2. (Optional) Style the template Body — the width, font, and background color — of your email.

  3. Click and drag Content or Block elements into your template. Click elements in your template to style them. See the WYSIWYG Editor Reference for details. Click to duplicate an element or to delete it.

    • Blocks: Blocks are single- or multi-column rows, synonymous with content columns. You might use blocks to organize the message layout before inserting content elements.
    • Content: Add columns, buttons, dividers, HTML, images, and text to a row in the layout.
  4. Style the elements in your template, then click Done.

You must fill out the rest of the template fields before you can save it.

Adding Merge Fields and Dynamic Content

You can add merge fields, conditionals, and looping fields in the WYSIWYG editor, making it easier to take advantage of dynamic content.

There are three types of merge fields.

  • Standard fields (with the type set to None) apply to text blocks; when you send a message based on the template, Airship replaces your merge field with the appropriate value.

  • Looping and Conditional fields apply to rows of content in your template. When you send a message, Airship evaluates the condition and determines whether or not to insert or repeat a row of content.

 Tip

You can also take advantage of looping (#each), conditional (#if), and other advanced handlebarsAirship’s message personalization syntax using double curly braces ({{handlebars}}). You can use handlebars to insert variables and conditional logic in messages and templates. within HTML blocks to show or repeat content within a block. However, you cannot apply conditional or looping logic to block-level elements in your template without adding merge fields to your template.

  1. In the editor for your template, click {+}.

  2. Click Create Field to add a new field or to edit an existing field.

  3. Enter a Field Name. This is the friendly name for this merge field that you’ll see in the visual editor.

  4. Enter the Key Path. This is the location of the merge field using JSON notation. If this template is for automation or journeys triggered by a custom event, your Key Path begins at $data.events.[0].properties. For example, the key path for a top-level name property would be $data.events.[0].properties.name.
  5. Select the merge Field Logic. Field logic determines both how you use the field and the conditional options you have when you apply the field.

    • None: Insert the value of the Key Path. You can insert this value into any text block in a template.
    • Conditional: Display a content block if the Key Path is populated (true) or not (false).
    • Loop: Repeat a content block for each item in an array, or display the block depending on whether or not an array is populated.
  6. Click Save.

When you’re done creating merge fields, click to return to the template editor.

Using Merge Fields in your WYSIWYG Template

The way you use a merge field is dependent on the field type. You can insert standard merge fields (with Field Logic set to None) into any text field in your template.

  1. In your template, select HTML Body.

  2. Select the text field that you want to add your merge field to.

  3. In the text tools, click Merge Fields and select your field. If you don’t see your merge field in the drop-down, you may need to create a new merge field with the Field Type set to None.

Airship adds your merge field with the correct syntax in your text.

Using Looping and Conditional Fields in your WYSIWYG Template

Conditional and Looping merge fields apply at the row level: you use the merge field to determine whether you want to show, hide, or repeat a block of content.

While conditions apply at the row level, you can still use merge fields within your conditional block. If you want to use a field both as a block-level condition and as a value within a block, you should save two merge fields: one to represent the conditional usage of the field, and one with Field Logic set to None.

When you apply a looping merge field to a content block, you can reference the current instance of the loop with the this context. For example, if looping through an array of products in your audience’s shopping cart, you might reference the price for each product in the loop with {{this.price}}.

  1. In your template, select HTML Body.

  2. Select the row you want to apply conditional or looping logic to and click .

  3. Select the merge field that you want to apply, and then select the logic.

    For conditional merge fields
    • Show if condition is false: Shows the block if the field does not exist, is empty, or is null.
    • Show if condition is true: Shows the block if the field exists and is not an empty string or null value.
    For looping merge fields
    • Repeat for each: Repeat this block for each item in an array.
    • Show if there are none: Show this block if the key path is empty or does not exist.
    • Show if there are any: Show this block if the key path exists and has at least one item in the array.

  4. Click Select.

Creating a Message Center Template

You can create your own full HTML message center templates for custom event-driven automation rules. When creating a template, you can paste or upload your HTML to add templates. You can also use HandlebarsAirship’s message personalization syntax using double curly braces ({{handlebars}}). You can use handlebars to insert variables and conditional logic in messages and templates. within your HTML to personalize messages for your audience.

  1. Go to Messages » Templates.

  2. Click Create Template.

  3. Select Message Center for the Template Type.

  4. Enter a Name and a brief Description to help you identify the template in lists, and click Save & Continue.

  5. Click Add to populate the Title of your template. This is not an HTML field but does support handlebars.

  6. Click Add to populate your template’s HTML Body.

  7. Upload your HTML file or paste your HTML in the editor.

     Note

    When using handlebars to reference variables in your HTML, you should define default values for your variables with {{else}}. The preview represents variables without default values as blank spaces, mimicking the behavior your audience will experience if they receive messages with unpopulated variables.

  8. Click Save Template.

Preview and Test Templates

You should test your templates to make sure that messages using the template make sense to your audience. When creating or editing a template containing handlebar syntax, you can enter JSON data representing a member of your audience to test template and any dynamic content statements in it without having to send test messages.

When creating or editing a Custom HTML template:

  1. Click Preview with sample values.

  2. Enter a JSON object representing a member of your audience. The message preview will show you what your message will look like when populated with data.

  • For non-Automation Templates: Enter a JSON object representative of an audience member. Click Example to see a sample object that can help you format your JSON data. This object mirrors the create_and_send audience object.
  • For Automation Templates: Enter custom event properties representative of an audience member, beginning with $data. The object you provide within properties should mirror the properties object in a custom event.

Automation Template Sample JSON

{
   "$data": {
      "events": [
         {
            "properties": {
               "total": 48,
               "cost_units": "USD",
               "purchase": [
                  {
                    "qty": 4,
                    "item": "MLB regulation baseball",
                    "per": "$12",
                    "total": "$48"
                  }
               ]
            }
         }
      ]
   }
}

Send a Templated Message

You can use a template in your email, SMS, or Open Channel message when you select the Upload Users option in the Audience step. The Upload Users option lets you upload a CSV containing the merge fieldA variable in your message or template that you want to populate with a personalized value for each member of the audience. Merge fields are wrapped in double curly braces — {{merge_field}}. values you want to populate for each member of your audience.

When you send a message using the /create-and-send API, you can specify a template_id to base your message on an existing template. Your template_id ID must correspond to the message type you want to send (i.e. you cannot use an SMS template to send an MMS message). You can find the template_id in the ID field in Messages » Templates.

Manage Templates

Messages » Templates lists your templates. Templates marked Empty do not have message content; you cannot use Empty templates in messages until you edit and populate them.

  1. Go to Messages » Templates.

  2. Find the template you want to manage. You can search by name, type, or ID.

  3. Click an icon to edit, delete, or copy a template.

  • to Delete a template.
  • to Edit a template.
  • to Duplicate a template.