Reminders for multiple upcoming trips
UpdatedIntroduction
Sending one transactional message regarding one object in your app is easily accomplished with an event-triggered campaign. It gets more complicated when your users can have multiple instances of the same object concurrently. Huh?! Let’s talk reality. Here are some examples of cases where you might want to communicate about a single instance of a larger collection of objects:
- Encourage a shopper to purchase their abandoned cart even when it’s possible for the user to have multiple carts.
- Let a customer know that one of their many saved coupons is expiring soon.
- Notify users when one job of many they’ve applied for is closed.
In this recipe, we’ll walk through a fourth example— a trip booking service that would like to remind users to book a hotel for their upcoming trip. You guessed it, a customer using this app can have multiple upcoming trips, so they want to make sure the reminder is about the correct trip and sent at the correct time.
Ingredients
- Basic knowledge of Liquid tags
- Ability to send events to Customer.io
Method
This method will use 2 campaigns triggered by a trip_booked
event and a hotel_booked
event. You’ll use an attribute on the profile, trips_with_hotel_booked
, to track which trips already have a hotel booked. This way, you can ensure you only send the reminder to book a hotel for any trips not in that list.
Campaign 1: Hotel is booked
Since we want to send a reminder if a hotel has not been booked, we need to track which trips include hotels. This campaign will do nothing more than add the trip’s trip_id
to a comma separated list of ids in an attribute on the person’s profile indicating that they’ve booked the hotel— trips_with_hotel_booked
. This is the attribute that is checked prior to sending the reminder in the campaign we’ll build next.
Send the event
You’ll want to send an event into Customer.io for the user when they complete booking a hotel. In this example, we’re calling it hotel_booked
. The event can contain any information about the hotel that you wish to include for use in other messages (maybe a confirmation email) that are triggered by the same event instance, but for the purposes of this capability, the only necessary attribute is the trip_id
.
{
"trip_id": "123"
}
For more details on sending events into Customer.io see our API documentation.
Create the campaign
Now that the event is sending to Customer.io, you can use it to trigger the new campaign.
The workflow
The only item necessary in this workflow is an Attribute Update to add the trip_id
to the comma separated list of ids named, trips_with_hotel_booked
.
The Liquid for this update:
{% if customer.trips_with_hotel_booked != blank %}
{{customer.trips_with_hotel_booked}},{{event.trip_id}}
{% else %}
{{event.trip_id}}
{% endif %}
If the attribute doesn’t exist on the profile already, the Create or update person action will add it. Learn more about attribute updates here.
This is the only workflow item required to make this use-case work, but adding a confirmation email to this workflow would be an excellent way to manage the entire hotel booking process in one campaign.
Campaign 2: Trip is initially booked
You’ll create a campaign triggered by the initial booking event. This will be the campaign that sends the reminder message a specified amount of time after the initial booking.
Send the event
Just like the first campaign, you’ll want to send an event into Customer.io for the user when they complete booking their trip. In this example, we’re calling it trip_booked
. This event should contain any information about the trip that you care to include in the email reminding them to book their hotel. We’ve included destination, confirmation number, and trip_date. It also needs to include a unique identifier for the event. We’ve used trip_id
in this example:
{
"trip_id": "123",
"destination": "Melbourne, Australia",
"confirmation": "N35RTX",
"trip_date": "28-OCT-2020"
}
For more details on sending events into Customer.io see our API documentation.
Create the campaign
Now that the event is sending to Customer.io, you can use it to trigger the new campaign.
The workflow
The first item your workflow needs to contain is a delay set to the amount of time you’d like to wait before sending the reminder. In this case, we’ll remind them after 10 days.
Once someone waits 10 days and exits the delay, we want to check whether they’ve booked the hotel for this trip yet. If not, we’ll send them a reminder to do so. To create this logic, add a True/False Branch to the workflow. In this case, you want to check whether the trips_with_hotel_booked
attribute for this person contains the trip_id
for this event. To do this, use the ‘attribute condition’ in the True/False Branch.
Enter the attribute trips_with_hotel_booked
and then select the option to compare it to an event attribute.
And finally, enter trip_id
as the event attribute to check.
Note
This particular recipe used an ‘attribute condition’ in the True/False Branch to determine whether the profile attribute contains the event value. You can also do comparisons in the opposite direction to compare an event attribute to a profile attribute using the ’event attribute’ condition type.
If the hotel has been booked for this trip, we don’t need to send them a reminder, but we do want to clear the trip_id
from the trips_with_hotel_booked
to clean things up and make sure the attribute doesn’t hit length limits. To do this, add a Create or update person action to the True branch.
The Attribute Update will update the trips_with_hotel_booked
attribute by removing it from the list. The Liquid for this update:
{% assign trips = trips_with_hotel_booked | split: "," %}
{% assign updated_trips = "" %}
{% for trip in trips %}
{% if trip != "" and trip != event.trip_id %}
{% if updated_trips != blank %}
{% assign updated_trips = updated_trips | append: "," %}
{% endif %}
{% assign updated_trips = updated_trips | append: trip %}
{% endif %}
{% endfor %}
{{updated_trips}}
The reminder email
Now the fun part! With the data in the original trip_booked
event, you can craft a personalized email reminding and encouraging them to book their hotel for the trip.
The final workflow
To recap, this campaign will hold the person in a delay for 10 days after booking the trip. After 10 days have passed, it will check whether they’ve booked a hotel for the trip. If so, it will simply clean up the attribute tracking that hotel booking, but if not, it will send a reminder to book a hotel for that particular trip. The workflow should look something like this:
Wrap Up
Using profile attributes to store status of multiple active trips on the customer account is a great way to customize your messaging for each of those trips. If this approach doesn’t work for you, though, or you need help getting it set up, send us a message!