Menu
 

Invite Emails

Introduction

Does your app allow people to invite friends? If so, you’ll likely want to contact those invited people—but they’re not yet in your Customer.io database. In this recipe, we’ll walk you through setting up a basic invitation email campaign to send messages such as:

Hi Ivana,

Johann just invited you to try out an awesome new app!

Sign up here!

Ingredients

  • Basic understanding of Liquid tags
  • A terminal window and basic knowledge of cURL (or a friendly developer)
  • Your site ID and API key

Method

The easiest way to send invite emails is with events. When a user invites someone new, you can send Customer.io an event, which includes data about the invited person. You can then use that data to get in touch with them.

Send the event

In this example, we’ll use an event called invited_friend. This event is associated with one of your existing users. So when Jóhann invites his friend Ivana, his action sends the event but the event contains contact information for Ivana. You’ll send that contact information as the event data, like this:

{
    friend_name: "ivana",
    friend_email: "ivana@customer.io"
}

To send the event and associate it with the inviter, you’ll want to hit the following endpoint:

https://track.customer.io/api/v1/customers/CUSTOMER_ID_HERE/events

The CUSTOMER_ID should match the id attribute of the customer sending the invite. So if Jóhann’s id in Customer.io is 12345, that’s what we would use there.

Send the event with curl

You can send your event to Customer.io by firing up a Terminal and using this code (with your adjustments, of course):

curl -i https://track.customer.io/api/v1/customers/CUSTOMER_ID_HERE/events  \
-X POST \
-u YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE  \
-d name=invited_friend \
-d data[friend_name]=FRIEND_NAME  \
-d data[friend_email]=FRIEND@EMAIL

After that, the event (and its data) will be available in Customer.io, associated with Jóhann. Here’s what his activity log would look like:

We have more in-depth API information here, should you need it.

Set up your campaign

Use your event as the campaign trigger

Now that you have invitee data moving into Customer.io, let’s put it to use! Set up an event triggered campaign, with invited_friend as the trigger:

Add your email

In your workflow, create the email that you’d like to send:

Put your data to work!

Remember the event attributes we sent as part of invited_friend? This is where we’ll use them. You don’t want to contact the customer who triggered the event, but the invitee email that they sent as part of it.

Click Customize in the To field and use a Liquid tag {{event.friend_email}} to get the invitee’s email:

I’ve also used the tag {{event.friend_name}} to greet them, and added a link. But you can customise this however you like!

Before you save, you can also check out the Preview to make sure all your tags are working as expected:

Wrap Up

Events and event data are a good way of getting in touch with people not yet in your Customer.io and kicking off new relationships with them! If this approach doesn’t work for you, though, or you need help getting it set up, send us a message!