Why Fallbacks Are Important
Imagine you’re sending a personalized message two customers who have placed an order with you through Shopify and the trigger is the creation of the order and you are sending the message 20 days after the purchase :
''Hey {{1}}, We hope you're enjoying your purchase of {{2}}''
Where {{1}} is the contact's name with the parameter syntax as ''{{contact.firstname}}'', and {{2}} is the name of the product purchased ''{{trigger.name}}''.
If a contact doesn’t have a first name in your system, the message is going to fail and it will look something like this, because of the parameter of first name coming up as missing when the automation looks for it before it can send the next message in the flow.
To handle such cases where flow might break, Spur allows you to define fallback values, ensuring that your messages still make sense and the flow doesn't break.
How to Add Fallbacks in Spur
Here’s how to set up a fallback for any missing parameter:
Identify the parameter you’re using, such as {{contact.firstname}}.
Add a fallback to the parameter this way: {{contact.firstname||"there"}}
Where contact.firstname : the original parameter.
|| : indicates the fallback separator.
"there" is the fallback value.
In this example, it will display "there" if {{contact.firstname}} is missing.
In the flow, the message would look like:"Hey {{contact.firstname||"there"}}, , We hope you're enjoying your purchase of {{2}}."
If {{contact.firstname}} exists, the message will use the first name (e.g., "Hey Lenny"). If it doesn’t, the fallback will be used (e.g., "Hey there"). This ensures that the message gets sent in situations where there is no number on record for that person, but at the same time also still makes sense for the end user to read.
Examples of Fallbacks in Use
1. Greeting Messages:
Automation Input:"Hey {{contact.firstname||"there"}}, welcome to Spur!"
Output When First Name Exists:"Hey Lenny, welcome to Spur!"
Output When First Name Is Missing:"Hey there, welcome to Spur!"
2. Product-Specific Messages:
Automation Input:"Hi {{contact.firstname||"there"}}, we see you’re interested in {{product||"our services"}}."
Output When Parameters Exist:"Hi Lenny, we see you’re interested in TVs."
Output When Parameters Are Missing:"Hi there, we see you’re interested in our services."
Best Practices for Fallbacks
Be Generic Yet Friendly: Choose fallback values that still sound engaging, such as "there" or "friend."
Double-Check Variables: Ensure that all placeholders in your message include a fallback to avoid any gaps in communication.
Test Your Automations: Before going live, test your flow to ensure the fallbacks behave as expected.
By adding fallbacks, your automations remain professional and functional, even when data is incomplete. This ensures a seamless experience for your customers and avoids any flow failures.