Using Conditional Logic for Smarter Messaging
Related Basics:
- For a quick overview on basic Snippets, check out this doc!
- For info on using Custom Snippets, check out this doc!
Jump to:
- What Are Advanced Snippets?
- Where Do I Find Them?
- How Do I Use Them?
- Blank Fallbacks
- Dynamic (Text or Other Snippet) Fallbacks
- Letter Case and Pluralization Snippets
- Current Time Snippets
- Custom Date Snippets
- Advanced Use
What are Advanced Snippets?
In a nutshell, advanced snippets allow for limited conditional logic within a message, that utilize the presence or absence of a value for a snippet. This means that you have two options for a part of an email, depending on whether or not a contact or account has a value for a snippet. If that is confusing, don't worry, seeing some examples will clear it up!
Where are Advanced Snippets found?
You'll find these with your basic and custom snippets, when editing an email or an email template:
How do you use Advanced Snippets?
Let's start with a basic example - the opener in an email. Let's say you want to greet someone by their first name to start. Using a basic snippet you'd use "Hi {{first_name}}," - which, if the contact you're sending to has a first name stored in Apollo, would populate there, so if this was sending to John Smith, it'd read "Hi John,"
However, what if this email was sent to a user who was, for whatever reason, lacking a value for first name? If you were only using a basic snippet, the email would not be sent, and it'd end up in your Not Sent folder, and you'd have to follow these instructions to fix it. However, this is where advanced snippets can streamline things.
Snippets With an Empty Fallback
If we were to use the first example, we'd input "Hi {{#if first_name}}{{#endif}}," - in essence this is saying "If the contact has a first name stored use that, otherwise leave things blank." Now, if this was sent to John Smith it'd come through the same way, as "Hi John," - however, if this contact was missing a first name, we'd not send any value, only the "Hi,". So this snippet is helpful if you want to only send something if there's a value, and otherwise send nothing there.
More helpful though is the more advanced version of this same snippet, where we have fallback text.
Snippets With a Dynamic Fallback
Let's try "Hi {{#if first_name}}{{first_name}}{{#else}}there{{#endif}}," - While this seems complex, once you understand what each part is doing, so let's go over each part one by one.
- {{#if first_name}}{{first_name}} - this is the start of the logic, this is saying "If there is a value for first name, then input that first_name value.
- {{#else}}there - this is saying that, if no first name value exists for this contact, then use the text "there" instead
- {{#endif}} - this just is how we denote the end of the logic
So putting that all together, lets look at what would happen in two cases.
- The contact is John Smith again - so since he has a "first_name" value, we will use that value (the {{#if first_name}}{{first_name}} part), so it'd say "Hi John,"
- The contact is missing a first name - so since there is no "first_name" value we would use the fallback (the {{#else}}there part), so it'd end up as "Hi there,"
Since you can use advanced snippets along with any basic or custom attribute, these can be extremely powerful (we'll show a much more advanced example later!). Keep in mind the initial value and the fallback can be whatever you wish- other snippets, plain text, sentences, etc.
Using Operator Snippets
The next part of advanced snippets are the operators, which take a value and make changes to it. This is useful both for cleaning up data you send out and manipulating that data.
Letter Case and Pluralization Operators
These will take the value of some field, and make changes to the value for that field (note this will only work on string type fields (text)). Let's look at some examples:
- {{title->lowercase}} will take the value of a contact's title, and make sure every letter in it is lowercase. For example, let's say the title was "Engineering manager" - this would become "engineering manager"
- {{title->capitalize_each_word}} would become "Engineering Manager"
- {{title->plural}} would become "Engineering managers"
- You can even combine these, so {{title->capitalize_each_word->plural}} would first capitalize, then pluralize - "Engineering Managers"
Now-date/time Operators
These will take the current date and manipulate it in various ways (note this will only work on date-type fields). Let's look at a few examples:
- {{now_month->plus_1}} will take the current month and move forward any insert the next month. So if it's March when the email sends, this will input "April" - note that you can use any number between 1 and 11 here.
- {{now_day->minus_2}} will take the current day and move back 2 days. So if it's the 6th when the email sends, this will input "4"- note that you can use any number here.
- {{now_time_of_day}} will use the current time of day (morning, evening, afternoon)
- You can also use "now_year" in either direction
Custom date operators
These will take a custom date field and manipulate it in various ways (note this will only work on custom date-type fields). Let's look at a few examples, using a custom date field called "Your Custom Date" (which would contain a month, day, and year) - let's say, for these examples the value is May 4th, 2018:
- {{your_custom_date->day}} will take that custom date and extract the day, which would be "4" - you can also do this with month and year, which would be "May" and "2018" in this example
- {{your_custom_date->weekday}} will take the actual day of the week, so May 4th, 2018 is a Friday, so it would be "Friday"
Advanced Use of Advanced Snippets
Now that we have something to base a real-life example off of, let's try one out!
"We know many companies like {{#if industry = Marketing}}Sparks, Jumpshot, and Deepcrawl{{#else}}{{#if industry = Big Data}}Heap Analytics, Palantir, and KeenIO{{#else}}Snowflake Computing, Uber, and Lyft{{#endif}}{{#endif}} are looking for new tools to implement for {{now_year->plus_1}}, and we'd like to walk you through our platform to have a good understanding of our full capabilities. Does {{now_weekday->plus_2}} or {{now_weekday->plus_3}} {{now_time_of_day}} work for you?"
Let's go through this piece by piece:
Nested Snippets Pointing to Specific Field Values
- {{#if industry = Industry Marketing}}Sparks, Jumpshot, and Deepcrawl - This is saying if the contact's account's Industry field is Marketing then use "Sparks, Jumpshot, and Deepcrawl".
- {{#else}}{{#if industry = Big Data}}Heap Analytics, Palantir, and KeenIO - However, if the Industry is not Marketing then check if the Industry is Big Data, and if so use "Heap Analytics, Palantir, and KeenIO".
- {{#else}}Snowflake Computing, Uber, and Lyft - This is your fallback, if the Industry is something other than Marketing or Big Data then use "Snowflake Computing, Uber, and Lyft"
- {{#endif}}{{#endif}} - Since we have nested "if statements" we need to end both of them. The rule of thumb is for each {{#if}} you need an {{#endif}}
Now-Time Snippets
- looking for new tools to implement for {{now_year->plus_1}} - This will always evaluate to the coming year, so it prompts them to plan ahead
- Does {{now_weekday->plus_2}} or {{now_weekday->plus_3}} {{now_time_of_day}} work for you? - This is a great way to personalize the request for a meeting, it'll end up saying something like "Does Wednesday or Thursday afternoon work for you?"
Comments
0 comments
Please sign in to leave a comment.