# Content templates

Use content templates 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.

## About content templates

You can create content templates for all messaging channels:

* App — For [Push Notification](https://www.airship.com/docs/reference/glossary/#push_notification), [Message Center](https://www.airship.com/docs/reference/glossary/#message_center), and [In-App Automation](https://www.airship.com/docs/reference/glossary/#iaa), follow the steps on this page. Templates for In-App Automation can be used for [modal and fullscreen styles](https://www.airship.com/docs/guides/features/messaging/in-app-automation/#styles) only.
* Web
* SMS/MMS
* Email
* Open channel

After creating content templates, you can select them in the Content step in a composer or reference them with the `template` property in the API. In-App Automation is not supported for API use.

In the composers, for App, Web, SMS/MMS, and Open channels, the template content replaces your message content as is and cannot be edited. For Message Center, In-App Automation, and Email, you can edit your message content after selecting the template.

You can assign keywords to your templates so they are easily found in search.

> **Tip:** * Name your templates according to the sources they use for personalization, so it's clear when and where you can reuse your template.
> * For reusable message designs for [Scenes](https://www.airship.com/docs/reference/glossary/#scene), see [Create custom content layouts](https://www.airship.com/docs/guides/messaging/in-app-experiences/configuration/content/#create-custom-content-layouts) in *Configuring Scene content*.


### Content template format

A content template has a name, optional description, and fields that make up the viewable content in a message.

<div class="table-scroll-wrapper">
<table width="100%">
	<col style="width:20%">
   <col style="width:80%">
   <tr>
      <th>Template</th>
      <th>Fields</th>
   </tr>
   <tr>
      <td>App (Push notification)</td>
      <td><ul><li><b>Message text</b> — The text that will display in your push notification.</li><li><b>Title</b> — A heading that appears above the notification text when applicable.</li><li><b>Summary</b> — Supplemental text displayed with the notification.
         <ul>
            <li><b>iOS</b> — The summary appears below the push notification title.</li>
            <li><b>Android and Fire OS</b> — The summary appears below the main notification text in most cases. This is the only visible text other than the title when Android Picture is visible in expanded mode, as the main notification text is suppressed.</li>
         </ul>
      </li></ul></td>
   </tr>
   <tr>
      <td>Message Center</td>
      <td><ul><li><b>Title</b> — A heading that appears above the message and in the Message Center inbox.</li><li><b>Message body</b> — The HTML body of your message, created using the [Interactive Editor](https://www.airship.com/docs/reference/glossary/#interactive_editor).</li></ul></td>
   </tr>
   <tr>
      <td>In-App Automation</td>
      <td><ul><li><b>Message body</b> — The HTML body of your message, created using the [Interactive Editor](https://www.airship.com/docs/reference/glossary/#interactive_editor).</li></ul></td>
   </tr>
   <tr>
      <td>Web</td>
      <td> <ul><li><b>Alert</b> — The text that will display in your web push notification.</li><li><b>Title</b> — A heading that appears above the message.</li></ul></td>
   </tr>
   <tr>
      <td>SMS</td>
      <td><ul><li><b>Message text</b> — The text that will display in your SMS message.</li></ul></td>
   </tr>
   <tr>
      <td>MMS</td>
      <td><ul><li><b>Subject</b> — A meaningful subject to summarize your MMS message.</li><li><b>Message text</b> — The text that will display in your MMS message.</li><li><b>Fallback SMS text</b> — Fallback text version of your message, for use when MMS is unavailable.</li></ul></td>
   </tr>
   <tr>
      <td>Email</td>
      <td><ul><li><b>Subject</b> — A meaningful subject to summarize your email.</li><li><b>HTML body</b> — The HTML body of your email, created using the [Interactive Editor](https://www.airship.com/docs/reference/glossary/#interactive_editor).</li><li><b>Plain text body</b> — The plain-text version of your message, for use when HTML is unavailable.</li></ul></td>
   </tr>
   <tr>
      <td>Open channel</td>
      <td><ul><li><b>Alert</b> — The text that will display in your open channel message.</li><li><b>Summary</b> — Supplemental text displayed with the notification.</li><li><b>Title</b> — A heading that appears above the notification text when applicable.</li><li><b>Media attachment URL</b> — The URL for media you want to include in your message.</li></ul></td>
   </tr>
</table>
</div>

<!--

- add media requirements ^^ for open channels
- why are the fields labeled differently than in the composer? example: `Alert` for web notification instead of `Text`.

-->
#### Using the Interactive editor

When adding the email *HTML body*, or In-App Automation or Message Center *Message body*, you can use the [Interactive Editor](https://www.airship.com/docs/reference/glossary/#interactive_editor) to:

<ul>
<li>Paste or upload your own HTML.</li>
<li>Design using the <a href="https://www.airship.com/docs/guides/messaging/features/wysiwyg-editor/about/">WYSIWYG option</a>. You can start from a blank layout or select an Airship default layout or a <a href="https://www.airship.com/docs/guides/messaging/features/wysiwyg-editor/saving-layouts/">layout you saved</a>. The WYSIWYG editor supports <a href="https://www.airship.com/docs/guides/messaging/features/wysiwyg-editor/merge-fields/">[Merge Fields](https://www.airship.com/docs/reference/glossary/#merge_field)</a>, so you can personalize your message for your audience.</li>
</ul>

![Designing a Message Center template using the Interactive Editor](https://www.airship.com/docs/images/editor-interactive_hu_f3164c9db0a14a24.webp)

*Designing a Message Center template using the Interactive Editor*

### Personalizing content templates

You can use our built-in tool to insert merge fields and logic statements for the [Attributes](https://www.airship.com/docs/reference/glossary/#attributes) in your project. [Simplifying Handlebars expressions](https://www.airship.com/docs/guides/personalization/simplifying-handlebars/). You can also manually enter [Handlebars](https://www.airship.com/docs/reference/glossary/#handlebars). Both methods are available for all text fields in a template, including when you paste or upload HTML using the Interactive editor.

> **Important:** When using Handlebars to reference variables, you should define default values for your fields with `{{ $def field_name "default value" }}`. The template preview renders variables without default values as blank spaces, mimicking the behavior your audience will experience if they receive messages with unpopulated variables.


When personalizing messages in the **WYSIWYG editor**, you must define merge fields before you can use them to personalize blocks of content *unless* you write your own custom HTML blocks. (You can personalize custom HTML blocks using [Handlebars](https://www.airship.com/docs/reference/glossary/#handlebars) like you would any other message.) See [Merge fields in the WYSIWYG editor](https://www.airship.com/docs/guides/messaging/features/wysiwyg-editor/merge-fields/).

![Selecting the Merge Tags option for a content template](https://www.airship.com/docs/images/merge-tag_hu_6cef51c5d87a680d.webp)

*Selecting the Merge Tags option for a content template*

> **Tip:** You can also take advantage of looping (`#each`), conditional if/else statements, and other advanced [Handlebars](https://www.airship.com/docs/reference/glossary/#handlebars) inside custom HTML blocks. However, you cannot apply conditional or looping logic to block-level elements in your template without defining merge fields in the WYSIWYG editor first.


## Create a content template in the dashboard

Follow these steps to create a template in the dashboard:

1. Go to **Content**, then **Templates**
1. Select **Create template**.
1. Enter a name and a brief description to help you identify the template in lists (for example, "Holiday 2020"), and select the channel:
   * App — For [Push Notification](https://www.airship.com/docs/reference/glossary/#push_notification) content only
   * Message Center
   * In-App Automation — For use with modal and fullscreen [styles](https://www.airship.com/docs/guides/features/messaging/in-app-automation/#styles) only
   * Web
   * SMS/MMS
   * Email
   * Open channel

1. (Optional) Add keywords to help organize your templates. Enter a term in the search field and select from results, or select **Add keyword: <term>**. Select the X icon (
) to remove a keyword. You can add up to 10 keywords.

1. Select **Save and continue**.

1. Enter your content. The preview updates as you type. Open channel templates do not have a preview.

   Select **Add 
** and add content for each field, then select **Done**.

   For email *HTML body*, and Message Center and In-App Automation *Message body*, provide your HTML or design using the WYSIWYG editor.
   <ul>
   <li>For <strong>HTML</strong>, select the paste or upload option and add your HTML.</li>
   <li>For the <strong>WYSIWYG editor</strong>, first select a default or <a href="https://www.airship.com/docs/guides/messaging/features/wysiwyg-editor/saving-layouts/">saved layout</a>, or select <em>Blank Layout</em> to design your own. You can edit any layout after selecting. Then design your message. See: <a href="https://www.airship.com/docs/guides/messaging/features/wysiwyg-editor/about/">WYSIWYG editor</a>.</li>
   </ul>

   For email, in the WYSIWYG editor:
      * To [reduce the HTML size](https://www.airship.com/docs/guides/messaging/messages/content/email/email/#size-limit-and-html-minification), select **Settings** in the sidebar, and then enable **Minify HTML**.
      * After selecting **Done**, choose whether to save the HTML body only or [also generate the plain text body](https://www.airship.com/docs/guides/features/messaging/email/#plain-text-generation).
      
1. (Optional, for email only) [Preview your email](https://www.airship.com/docs/guides/messaging/messages/content/email/email/#inbox-previews) in different clients:
   <ol>
   <li>Click <strong>Inbox preview</strong>.</li>
   <li>Select from the lists of browser, desktop, and mobile clients, then click <strong>Generate previews</strong>.</li>
   <li>Click a thumbnail to see the full version. Click 
    to close and choose another preview.</li>
   <li>(Optional) To add/remove clients, click <strong>Reselect and generate previews</strong> and start over.</li>
   <li>When you are finished with inbox previews, click 
    to close the modal.</li>
   </ol>

1. Select **Save template** when you are done adding content.

## Creating content templates using the API

You can use the [Content API](https://www.airship.com/docs/developer/rest-api/ua/operations/content/) to create, list, retrieve, update, and delete content templates. For supported template `type` values and fields, see the [Content template object](https://www.airship.com/docs/developer/rest-api/ua/schemas/content-objects/#contenttemplateobject) schema in the API reference.

OAuth client credentials can include the Content scope for these endpoints. See [Content](https://www.airship.com/docs/developer/rest-api/ua/api-auth-reference/#content) in the *Airship API authorization reference*.

When you create or update a template, Airship validates it using the same rules as the dashboard, including [Handlebars](https://www.airship.com/docs/reference/glossary/#handlebars) syntax and reference checks. Invalid templates are not saved.

You can set an optional `external_id` on a template. The ID is a customer-defined string that is unique within a project. You can use it to look up or update a template using dedicated endpoints and to reference the template in send and push payloads where supported, as an alternative to the template UUID.

## Using content templates

In the dashboard, you can select a template in a composer's Content step:

* For In-App Automation, you must select Modal or Fullscreen in the Style step, then you will see the option to use a template in the Content step.
* For Message Center, In-App Automation, and Email, you can edit the HTML or WYSIWYG design in the Interactive editor after selecting a template.

For email templates, you can create a new message directly from your templates list. Go to **Content** and select **Templates**, then select the more menu icon () for an email template and then **Use template**. This will open the [Message composer](https://www.airship.com/docs/guides/messaging/messages/create/) with the Email channel enabled and the template preselected.

In the API, include a `template` object to use a content template or to personalize your message with [Handlebars](https://www.airship.com/docs/reference/glossary/#handlebars). See [Platform Overrides with Templates](https://www.airship.com/docs/developer/rest-api/ua/schemas/platform-overrides-with-templates/).

Reference a content template by its ID, a UUID returned from Content API responses. You can also reference by external ID when your payload and endpoint support it. In the dashboard, you can get IDs from [your list of templates](#managing-content-templates). Exact property names and formats appear in the schema for your channel and operation.

For push, specify the template on the [Notification object](https://www.airship.com/docs/developer/rest-api/ua/schemas/push/#notificationobject).

[In-App Automation](https://www.airship.com/docs/reference/glossary/#iaa) is not supported for API use.

## Managing content templates

Go to **Content** and select **Templates** to view the list of templates in your project. The list displays templates created in the dashboard or with the [Content API](https://www.airship.com/docs/developer/rest-api/ua/operations/content/).

You can sort the list by name or date modified, filter by channel or keyword, and search by name, ID, or keyword. Templates without message content are labeled "Empty" and cannot be used until you add content.

Select a template name to open a drawer where you can do the following:
   * For the ID, select the copy icon () to copy it to your clipboard.
   * Edit the name, description, and keywords. Select **Save** after making your changes.
   * Select **Edit** or **Duplicate**, which are the same as the actions available from the more menu icon (), as described in the table below.
   * View the names of [Snippets](https://www.airship.com/docs/reference/glossary/#snippet) or [External Data Feeds](https://www.airship.com/docs/reference/glossary/#external_feed) used in the template.
   * View the date and time when the template was created and last modified.

The following actions are available from the more menu icon () in the template list:

<div class="table-scroll-wrapper">
<table width="100%" class="reference-table">
  <col style="width:20%">
  <col style="width:40%">
  <col style="width:40%">
<thead>
  <tr>
    <th>Action</th>
    <th>Description</th>
    <th>Steps</th>
  </tr>
</thead>
<tbody>
  <tr>
    <td>Edit</td>
    <td>Open the template for editing. You can change the content, name, description, and keywords.</td>
    <td>Select the more menu icon (), then <b>Edit</b>, make your changes, and then select <b>Save template</b>.</td>
  </tr>
  <tr>
    <td>Duplicate</td>
    <td>Make a copy of the template in the current project or in a different project. You can only duplicate to projects that are configured for the template's channel. MMS templates are not supported.<p>If duplicating to a different project and the template has dependencies, they are listed along with whether each dependency is copied to the destination project.</td>
    <td>First, choose to copy to the current project or a different one, and update the name, description, and keywords. Then, select <b>Duplicate</b>.</td>
  </tr>
  <tr>
    <td>View information and access additional actions</td>
    <td>Open the same drawer as when you select a template name. For what you can do in the drawer, see the list above this table.</td>
    <td>Select the more menu icon (), then <b>View detail</b>.</td>
  </tr>
  <tr>
    <td>Delete</td>
    <td>Delete the template from your project. Deleting a template that is in use may impact messaging.</td>
    <td>Select the more menu icon (), then <b>Delete</b>.</td>
  </tr>
  <tr>
    <td>Copy ID to clipboard</td>
    <td>Copy the template ID to your clipboard.</td>
    <td>Select the more menu icon (), then <b>Copy ID to clipboard</b>.</td>
  </tr>
  <tr>
    <td>Create an email</td>
    <td>Create a new message in the <a href='https://www.airship.com/docs/guides/messaging/messages/create/'>Message composer</a> with the template preselected in the Content step.</td>
    <td>Select the more menu icon () for an email template, then <b>Use template</b>.</td>
  </tr>
</tbody>
</table>
</div>
