Overview
Working with message templates saves time for both developers and marketers. This article shows how to add default syntax for creating inbox, in-app, and extension and data templates for mobile apps. You can create multiple templates for each type of message.
Device type/OS(s) |
Template type |
Description |
Available default templates |
Android and iOS |
Inbox templates |
An inbox template determines the fields that are displayed during the creation of an inbox message. |
Traditional Create an HTML inbox message visible in the user's mobile app inbox. Video Create an inbox message containing a video visible in the user's mobile app inbox. Image Create an inbox message containing an image visible in the user's mobile app inbox. |
Android and iOS |
In-app templates |
An In-app template determines the fields displayed during the creation of an in-app message. |
Bottom banner Create an in-app message that appears on the bottom of the mobile app. Top banner Create an in-app message that appears on the top of the mobile app. Image Create an in-app message that contains an image and appears within the mobile app. Video Create an in-app template that contains a video and appears within the mobile app. |
Android and iOS |
Extension and data templates |
An Extension and data template determines the fields that are displayed during the creation of an extension or data message. |
Watch Create a message for an extended device, e.g. smartwatch. Sample data Create a data message that sends data to the mobile app. |
Create the template
Select any template from the New template menu on the Inbox, In-app, Extensions and data tabs. Templates are available in the send experience after you create and save them.
- Hover over Mobile app.
- Navigate to Developer resources >Templates.
- Click New template to insert the default syntax.
Set up the inbox message template
Validate the inbox template.
- Name: required, not empty
- Type: required, not empty, only "inbox" - Note: You could type "inApp" as the template type in the inbox template, but you may receive an error saying that "inApp JSON is invalid" as the inbox template does not have rules array.
- Platforms: must be a non-empty array of values "ANDROID" or "IOS" or both
- Payload:
- Required, not empty
- 'template' attribute: required, not empty
- Sections: any variable (${variableName}) reference in the 'payload' content should be defined in sections
- For each 'section' object:
- Must have a non-empty label
- customProperties: For each custom property:
- 'id' attribute: required, not empty
- 'type' attribute: required, not empty
- 'inputRequired' attribute: required, true/false
- 'htmlContent' type (allowed, but can ONLY be null); note that we disregard "inputRequired" value for "htmlContent" type.
Note: If 'inputRequired' attribute is set to 'false', the value must be provided in the template when the template is created. The provided value will be used in messages that use that template, and marketers will not be provided with an option to change the value. If 'inputRequired' attribute is set to 'true', 'placeholder' attribute must be non-empty string.
Set up the in-app message template
The items numbered on the template are defined in the In-app template JSON mapping and are customizable.
Validate the in-app template.
-
- Name: Required, not empty (Possible Defect: Adding numbers like 12345 without the quotes for name shows no error message and saves the template name as String "12345". Similar issue with boolean types, which are saved as "true" or "false" strings.)
- Type: Required, "inApp"-- Please note: You could type "inbox" as the template type in the inApp template, and it will be saved as inbox template. If you go to the page again, you would see this template in the inbox templates area.
- Platforms: Must be a non-empty array of values "ANDROID" or "IOS" or both
- Payload:
- Required, not empty
- 'template' attribute: required, not empty
- 'content' attribute: required, not empty
- 'rules' attribute: must be an array - today it could be empty, but will probably result in some errors in the app itself
- Sections: Any variable (${variableName}) reference in the 'payload' content should be defined in sections.
For each 'section' object:
- Must have a non-empty label
- customProperties:
For each custom property:
- 'id' attribute: required, not empty
- 'type' attribute: required, not empty
- 'inputRequired' attribute: required, not empty
Note: If 'inputRequired' attribute is set to 'false', we do type checks: Boolean, Number,, String (can be empty), Object (cannot be empty), htmlContent (NOT allowed), any other type not allowed;
If 'inputRequired' attribute is set to 'true', 'placeholder' attribute must be non-empty string.
Set up extensions and data template
The items on the template are defined in the Extensions and data template JSON mapping. There are currently two predefined templates to choose; watch and sample data.
Here is an example of how the watch template displays in Send Experience based on the JSON mapping of the template under the Development tab. The text that is highlighted in the JSON sample below is included for reference and is not a part of the payload.
Example of extensions & data JSON mapping
[
{
'name': 'Watch', --> Determines the name of the template that will display in the picker.1
'type': 'watch',
'platforms': [ --> Determines which platforms this template will be available for.
'IOS',
'ANDROID'
],
'label': 'Apple Watch',
'description': 'Opens notification in watch', --> Determines the description of the template that will display in the picker.
'payload': {
'title': {
'text': '${title}',
'color': 'F8E71C'
},
'body': { 3
'text': '${body}',
'color': 'ffffff'
},
'header': {
'src-42': 'http://i.imgur.com/yBui16E.png',
'src-38': 'http://i.imgur.com/yBui16E.png'
},
'map': {
'lat': '${latitude}',
'long': '${longitude}'
},
'background': {
'src-42': 'http://i.imgur.com/yBui16E.png',
'src-38': 'http://i.imgur.com/yBui16E.png'
}
},
'pushTypes': [ --> Determines which push types the template will be available for.***
'simple',
'data'
],
'expirationDateRequired': true, --> Determines if this template requires an expiration date.
'sections': [
{
'label': 'Title',
'customProperties': [
{
'id': '${title}', 2
'inputRequired': true,
'type': 'string',
'placeholder': 'Title',
'value': 'Welcome to NYC'
},
{
'id': '${body}',
'inputRequired': true,
'type': 'string',
'placeholder': 'Body',
'value': 'Thanks for using Rent A Car. Your rental is ready. Enjoy!'
},
{
'id': '${latitude}', 4
'inputRequired': true,
'type': 'number',
'placeholder': 'Latitude',
'value': 23.343
},
{
'id': '${longitude}', 5
'inputRequired': true,
'type': 'number',
'placeholder': 'Longitude',
'value': -73.342
}
]
}
]
},
]
Validate the data and extension template:
- Name: required, not empty (Possible Defect: Adding numbers like 12345 without the quotes for name shows no error message and saves the template name as String "12345". Similar issue with boolean types, which are saved as "true" or "false" strings.)
- Type: required
- pushTypes: required
- Platforms: must be a non-empty array of values "ANDROID" or "IOS" or both
- Payload:
- 'template' attribute: not required
- 'content' attribute: not required
- 'rules' attribute: not required; must be an array - today it could be empty, but will probably result in some errors in the app itself.
- Sections:
For each 'section' object:
- must have a non-empty label
- customProperties:
For each custom property:
- 'id' attribute: required, not empty
- 'type' attribute: required, not empty
- 'inputRequired' attribute: required, not empty
Note: If 'inputRequired' attribute is set to 'false', we do type checks: Boolean, Number,, String (can be empty), Object (cannot be empty), htmlContent (NOT allowed), any other type not allowed. If 'inputRequired' attribute is set to 'true', 'placeholder' attribute must be non-empty string.