# Reminders for multiple upcoming trips

## Introduction[](#introduction)

This recipe is useful for multiple upcoming trips but you can also adapt it for these use cases:

*   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.

The idea is that sometimes people can have multiples of one thing - trips, carts, coupons, and job applications - and you may want to target a specific trip, cart, etc during a campaign. This recipe helps you do that!

We’ll create a campaign that reminds people to book a hotel for their upcoming trip. Since a customer can have multiple upcoming trips, we’ll make sure the reminder is about the correct trip and sent at the correct time.

## Ingredients[](#ingredients)

*   Basic knowledge of liquid
*   Ability to send events to Customer.io

## Method[](#method)

This recipe will create two campaigns, one triggered by a `trip_booked` event and another by a `hotel_booked` event. You’ll store an attribute on people’s profiles, `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[](#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[](#send-the-event)

You’ll want to send an event into [Customer.io](http://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](/integrations/api/track/#operation/track).

#### Create the campaign[](#create-the-campaign)

Now that the event is sending to Customer.io, you can use it to trigger a campaign.

1.  Go to **Campaigns**.
2.  Click **Create Campaign**.
3.  Click **Choose trigger**.
4.  Select **Event** and choose `hotel_booked`.

[![multiple_reminders__hotel-booked-event](https://docs.customer.io/images/multiple_reminders__hotel-booked-event-1.png)](#dffa8bf35588639dfbffed065a2fb959-lightbox)

#### The workflow[](#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`.

Drag a [**Create or update person** action](/journeys/create-update-person) into your workflow. Click it then choose **Add details**.

[![multiple_reminders__attribute-update-hotel-booked](https://docs.customer.io/images/multiple_reminders__attribute-update-hotel-booked-1.png)](#3ab8a283c3c27147f8184b8784599891-lightbox)

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.

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.

[![multiple_reminders__campaign1-workflow](https://docs.customer.io/images/multiple_reminders__campaign1-workflow.png)](#1ac3efd69e7a87c79001c393b23e4935-lightbox)

### Campaign 2: Trip is initially booked[](#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[](#send-the-event-1)

Just like the first campaign, you’ll want to send an event into [Customer.io](http://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](/integrations/api/track/#operation/track).

#### Create the campaign[](#create-the-campaign-1)

Now that the event is sending to Customer.io, you can use it to trigger a campaign.

1.  Go to **Campaigns**.
2.  Click **Create Campaign**.
3.  Click **Choose trigger**.
4.  Select **Event**.

[![multiple_reminders__trip-booked-event](https://docs.customer.io/images/multiple_reminders__trip-booked-event-1.png)](#38683fde2f654186963894b43214921e-lightbox)

#### The workflow[](#the-workflow-1)

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.

[![multiple_reminders__delay](https://docs.customer.io/images/multiple_reminders__delay.png)](#9f839a89b74be1bd49efb7e1e9d5e62b-lightbox)

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.

[![multiple_reminders__add-attribute-condition](https://docs.customer.io/images/multiple_reminders__add-attribute-condition-1.png)](#dc9aad2aab9215d8dfccba104d04b6e3-lightbox)

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.

[![multiple_reminders__event-attribute](https://docs.customer.io/images/multiple_reminders__event-attribute-1.png)](#b1832e1fb7b8443b10b2327204379533-lightbox)

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](/integrations/api/track/#section/Track-API-limits). To do this, add a **Create or update person** action to the True branch.

[![multiple_reminders__campaign2-workflow](https://docs.customer.io/images/multiple_reminders__campaign2-workflow.png)](#d58d51d63ca7cb289b327195db6de3d8-lightbox)

This should update the `trips_with_hotel_booked` attribute by removing it from the list. Here’s the liquid for this update:

```fallback
{% 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[](#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.

[![multiple_reminders__email](https://docs.customer.io/images/multiple_reminders__email-1.png)](#c1b3c7c950e9888ac838e62727081ed5-lightbox)

#### The final workflow[](#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:

[![multiple_reminders__campaign2-final-workflow](https://docs.customer.io/images/multiple_reminders__campaign2-final-workflow.png)](#701e38c5bfa84d4411cd407a0eb89b9f-lightbox)

## Wrap Up[](#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!