Skip to main content

Customer.io

Customer.io is a platform for automated messages to customers. Its campaigns have the Send and receive data block — a webhook whose method, headers and body you set yourself. Pointed at the Flows address, it sends the events of your campaigns into flows: an order is placed or paid, a cart is left, a form is filled in — and a flow takes it from there with Viber, SMS, waiting and reminders. To send SMS directly from Customer.io, see Customer.io.

Written from Customer.io documentation

This page is written from the public documentation of Customer.io and has not been checked on a live account yet.

What you need​

  • A Customer.io workspace with campaigns. The page of the action does not name a plan.
  • Nothing else: the block takes any method, headers and body.
  • One address for all campaigns: the event is written in the body.

Step 1. Create a connection​

  1. Open Flows → Connections, press Connect a system and choose Customer.io.
  2. Press Copy address. It looks like https://events.alphasms.net/hooks/<TOKEN> — keep it secret.

Step 2. Add the block to a campaign​

  1. Open the campaign (workflow), drag the Send and receive data block to the place where the event should go and press Add Request.
  2. Method — POST (set by default). URL — the address from the cabinet.
  3. Headers — Content-Type: application/json is already there. No authorization: the secret is in the address.
  4. Body — paste the body below. Change order_paid in event to the event of this campaign (see Events).
  5. Sending behavior — Send automatically. The default is Draft.

The body (Liquid; the json filter puts the quotes and escapes the value itself):

{
"event": "order_paid",
"message_id": "cio:{{delivery_id}}",
"contact": {
"external_id": {{ customer.id | default: '' | json }},
"phone": {{ customer.phone | default: '' | json }},
"email": {{ customer.email | default: '' | json }}
},
"traits": { "first_name": {{ customer.first_name | default: '' | json }} },
"properties": {
"order_id": {{ event.order_id | default: '' | json }},
"total": {{ event.total | default: 0 | json }}
},
"context": { "source": "customer_io", "campaign_id": {{ campaign.id | json }} }
}
  • {{delivery_id}} is the id of this message for this person. Customer.io retries with the same id, so a retry is not recorded twice.
  • {{customer.id}} is usually the id of the customer in your own system — that is how Customer.io identifies people. If your workspace identifies people by email, remove external_id.
  • {{event.*}} variables exist only in campaigns started by an event. In a campaign started by a segment they give the error "undefined variable" — remove the properties block there, or keep the default filter on each.
  • To pass the time of the event, add the line below. That Customer.io gives this time in UTC is not confirmed by the documentation; without the line the time of the event is the time AlphaFlow receives it.
"occurred_at": "{{ event_timestamp | date: '%Y-%m-%dT%H:%M:%SZ' }}",

Step 3. Send a test​

The preview on the right renders the body on a sample profile ({{delivery_id}} shows unsent there). Then run the campaign on your own profile with a phone. The event appears in Flows → Connections → Event journal within seconds. The connection shows Recognised: Customer.io.

Events​

What starts the campaignAlphaFlow eventProperties
An order is placedorder_createdorder_id, total
An order is paidorder_paidorder_id, total
A cart is left without an ordercart_updatedthe properties you add
A form is filled inform_submittedthe properties you add

Put order_paid only into a campaign whose trigger is the payment itself or whose trigger filter checks a paid status. A campaign on any order sends order_created, and one on any change of an order — order_status_changed with status: otherwise an unpaid order reaches the customer as "paid".

You choose the name of the event from the list of AlphaFlow. AlphaFlow takes the body as it is: the contact is the phone, the email and your customer id from contact, the first name comes from traits. Nothing has to be mapped. The names of the events are the ones the ready-made templates expect — see Recommended events.

Good to know​

  • Customer.io waits 16 seconds for the answer. On a timeout, 408, 409, 429 and 5xx it retries up to 11 times within about an hour. A manual retry from the Sent tab takes fresh data.
  • Customer.io adds the headers X-CIO-Signature, X-CIO-Timestamp and X-CIO-Idempotency-Key itself. The signature is optional — the secret in the address is enough. To check it, copy a key from Webhook signing keys (Settings → Workspace Settings → API & Webhook Credentials) into the connection as its secret.
  • A person without a phone in Customer.io comes with the email and the id only: a message in Viber or SMS reaches them only if AlphaFlow already knows their phone.
  • The address always answers 200. Above the daily event limit the event is refused in AlphaFlow with quota_exceeded and shown in the journal; the campaign in Customer.io keeps running.

Customer.io documentation​