Mobile Commons
Resolution Summary
Provided Information on the Liquid basics
Details
Liquid is a powerful template language that will help you enhance your mobile conversations with highly personalized responses. For full functionality please view our Liquid Templates Page. Be sure to check out our attached webinar deck, as well as our recording from our Liquid Webinar-also, at the bottom of this page.
Please note that using Liquid Language will change character counter performance. Insertion of profile field values will automatically drop the counter down by 5 characters, however, you should be sure to account for the length denoted on our mail merge page. When using liquid to build out multiple different messages the character counter will not provide any estimate as the messages can only be counted upon processing. Please be sure to count out your message lengths before inserting them into the Mobile Commons platform. Make sure you use the Liquid tester and test on your phone whenever you use liquid.
- Terms & Basic Functions
- Comparing Strings or Variables
- Liquid Markup
- Working with Outputs
- Working with Tags
Terms & Basic Functions
- Mail Merging Fields: Default Fields: Custom Fields
- Output or Mail Merge: Liquid that displays text for a user. Will always use {{…}}
- Tags: Liquid to set conditions. Is not exposed to end user. Always uses {% … %}
- Filters: perform equations or commands within tags. You can use if, elsif, else and endif
- Operators: used to make logical comparisons. Works with tags. You can use ==, !=, <, >, and, or
Compare strings or variables using the following
- == When something must EXACTLY match, IS Case Sensitive
- != When something shouldn’t match, IS Case Sensitive
- > Greater than (or is_after for dates); works with numeric values
- < Less than (or is_before for dates); works with numeric values
- >= Greater than, or equal to; works with numeric values
- <= Less than or equal too; works with numeric values
- or One or the other
- and Combining 2 variables
- has like ==, NOT Case Sensitive
- contains match
Liquid Markup
There are two types of markup in Liquid: Output and Tag.
Output Markup (which may resolve to text) is surrounded by: {{…}} matched pairs of curly brackets
Tag Markup (which cannot resolve to text) is surrounded by: {%...%} matched pairs of a curly bracket and percent sign
Working with Outputs
You can insert any default profile field or custom field using a double curly bracket {{...}}. By using these curly brackets a profile's stored value for a custom field or default field will be inserted in the message back to the user.
- Always use double curly brackets {{…}}
- Replace all spaces in your field name with underscores; first name becomes first_name. The liquid tester will show you the appropriate formatting underneath the field name.
- Always test in the Liquid Tester! *the liquid tester can accommodate both normal, 160 character messages, and longer messages of more than 160
- Reformat date & times, create stand-ins for blank values. Examples: {{dob | date: ‘%m,%d’}} or {{first_name | default: ‘friend’}} For more on this please view our Liquid Templates Page.
In platform.
In Liquid Tester.
On a subscriber's phone.
Working with Tags
- Sets Conditions
- Always use {%...%}
- Supports comparisons (i.e. greater than, equal to, before)
- May be nested for multiple conditions
- Allows for different conversations
- Not exposed to end user
- Examples: {% if email == null %} Can we get your email? {% else %} We’ll email you! {% endif %} or {% if age < 18 %} Sorry kid! Adults only here. {% else %} Welcome in, adult! {% endif %}
With tags we can further personalize the output name example. For this example we're trying to capture email from those subscribers whose email we do not yet have. For those subscribers whose email we do have we want to let them know we're going to be sending them an email soon. In both of these messages we'll want to insert the subscribers first name if we have it, or 'buddy' if we don't have it.
Here is the broadcast message being built out. We're saving the response as e-mail because for some of our subscribers we'll be asking for email.
- First we'll use a simple output phrase {{first_name | default: 'buddy'}} will insert a subscriber's first name if we have it, if we do not have a first name it will insert our default name, buddy, instead
- Next we'll use tags to build out different content based on conditions to be met. We'll use {% if email %} and then write our content for subscribers whose email we do have.
- Then we'll create a condition for any other scenario, {% else %}, and write out our content for subscribers whose email we don't have
- Finally, we'll close our liquid tags with {% endif %}. This lets the platform know to stop looking for and meeting conditions-that we're done for this conversation
Here is how we tested all the different permutations of this message. Always test using the Mobile Commons Liquid Tester (and your phone!). For more templates and examples please visit our Liquid Templates page
A user with NO email and NO first name. To test we've deleted the default values for first_name and email in the tester.
Next, we'll test for a user with a name value, but no email:
Then we'll test for having an email and having a first name:
Finally, no name and no email:
Here is how it would look on a user's phone who has a first name and an email:
Internal Information
Resolution Category