Filters
Filters can be used to augment fields.
They are referenced inside of fields using the following format:
{{ field_name | FILTER }}They can be chained together if needed:
{{ field_name | FILTER1 | FILTER2 }}Some filters accept parameters. In that case, you can use the following syntax:
{{ field_name | FILTER: PARAMETER }}Filter example
Section titled “Filter example”If you would like to give a 3-hour time window to your clients in the message based on the start time, then you could use the following as your template:
Your installer will be arriving between {{ event.start_time | time }} and {{ event.start_time | add_minutes: 180 | time }}In the above example, the first field uses the time filter to change the event.start_time from something that looks like 2016-06-06 14:00:00 -0700 to 2:00 PM. The second field uses the add_minutes filter to add 180 minutes to the start time and then output the time — in this case, 5:00 PM. The result would be:
Your installer will be arriving between 2:00 PM and 5:00 PM
The Liquid templating language comes with a set of filters out of the box (see the Liquid filter reference). Apptoto adds and enhances some of the filters.
Date Filters
Section titled “Date Filters”The following filters are designed to work specifically with the {{ event.start_time }} and {{ event.end_time }} fields.
| Filter | Description |
|---|---|
date | Apptoto enhances this filter by properly formatting the date based on your locale. If you use the %A format, it will say “Sunday” if your locale is set to English, and “Domingo” if your locale is set to Spanish. The locale is set on your Account tab. (Localized) |
date_full | Date format filter that changes the date to say “Tuesday, October 15th”. (Localized) |
date_and_time_full | Date format filter that changes the date to say “Tuesday, October 15th at 2:00pm”. (Localized) |
date_phrase | Date format filter that changes the date to say “6/21”. (Localized) |
date_with_year | Date format filter that changes the date to say “6/21/1977”. (Localized) |
day_with_date | Date format filter that changes the date to say “Wednesday the 30th July 2012”. (Localized) |
time | Date format filter that changes the date to say “3:00pm”. |
time_24 | Date format filter that changes the date to say “15:00”. |
day_and_time | Date format filter. Results in “tomorrow at 8:00am” if the date is tomorrow or “on Saturday, November 23rd at 2:00pm” if the date is after that. |
tomorrow | Advances the date forward one day. e.g. {{event.start_time | tomorrow | date_full}} would result in “Wednesday, October 16th”. |
yesterday | Retreats the date backward one day. e.g. {{event.start_time | yesterday | date_full}} would result in “Monday, October 14th”. |
beginning_of_week | Finds the Monday immediately before the date provided. |
add_minutes | Advances the time forward by N minutes. e.g. {{ event.start_time | add_minutes: 30 | date: "%l:%M %p"}} would result in “4:30 pm” if the start time of the appointment was at 4:00pm. |
browser_time | Shows the time to the user in the time zone of the browser. This is only available on the Appointment Page. e.g. {{ event.start_time | browser_time }} would show the time to the client in their time zone. |
browser_date_and_time | Same as browser_time except it includes the date. |
String Filters
Section titled “String Filters”| Filter | Description |
|---|---|
default | Allows you to specify a default for a field. e.g. {{ event.data.service | default: 'Haircut' }} would result in “Haircut” being used in the message if the event didn’t have the service specified. This is applicable for all types of data (not just strings), but is mostly used for strings. |
everything_before | Extracts everything before a character in a string. e.g. if you put “haircut – fred” in the title and want Apptoto to include everything before the ”-” in the message, then you could use: {{ event.title | everything_before: "-" }}. |
everything_after | Same as everything_before but includes everything after. |
say_digits | Tells the text-to-speech engine to say individual digits, not whole numbers. e.g. {{ participant.phone | say_digits }}. |
capitalize | Capitalizes the string by making the first letter of the first word uppercase. |
line_after | Finds the line after a string. e.g. {{ event.content | line_after: 'Send To:' }}. |
lines_after | Finds N lines after a string. e.g. {{ event.content | lines_after: 'Send To:', 2 }} would find the 2 lines after the line containing “Send To”. |
play_mp3 | Calls only. Plays whatever MP3 file you link to during the call. e.g. {{ 'https://api.twilio.com/cowbell.mp3' | play_mp3 }}. |
pause | Calls only. Pauses for X seconds. e.g. {{ '3' | pause }} will pause for 3 seconds. |
html_to_text | Converts HTML to text. |