Skip to main content

Klaviyo

Klaviyo is an email and SMS marketing platform for online shops. The Webhook action of its flows sends a request with a body you write yourself. Pointed at the Flows address, it starts your flows: an order is placed, a checkout is started and left, an order is fulfilled — and the customer gets the right message in Viber or SMS.

Klaviyo's own SMS works only in a limited list of countries — the US, Canada, part of the EU, Australia and some others — and does not reach Ukraine. Flows send these messages in Viber and SMS instead.

Written from Klaviyo documentation

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

What you need​

  • Any Klaviyo plan: the Webhook action is not limited to one.
  • The role Manager, Admin or Owner, and two-step authentication for everyone who adds or edits a webhook.
  • A flow that starts on an event, a list, a segment or a date. Events that do not start flows, such as Unsubscribed from List, do not fit.
  • One address for all flows: the event is written in the body.

Step 1. Create a connection​

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

Step 2. Add the Webhook action​

  1. Open Flows and the flow. Drag the Webhook action from the left panel to the place where the event should go.
  2. URL — the address from the cabinet.
  3. + Add Headers — not needed: the secret is already in the address.
  4. Body — paste the body below. Change order_paid in event and in message_id to the event of this flow (see Events).
  5. Press Save — the webhook is on. Without two-step authentication Klaviyo asks for it first: Set Up Two-Step Authentication → Continue.

The body for a flow started by Placed Order with a trigger filter on paid orders — without the filter, put order_created (see Events):

{
"event": "order_paid",
"message_id": "klaviyo:order_paid:{{ person.KlaviyoID }}:{{ event|lookup:'$event_id' }}",
"contact": {
"external_id": "{{ person.id|default:'' }}",
"phone": "{{ person.phone_number|default:'' }}",
"email": "{{ email|default:'' }}"
},
"traits": { "first_name": "{{ first_name|default:'' }}" },
"properties": {
"total": "{{ event|lookup:'$value'|default:'' }}"
},
"context": { "source": "klaviyo" }
}

For a flow started by Started Checkout set "event": "cart_updated" and add the link to the checkout to properties:

"cart_url": "{{ event.extra.checkout_url|default:'' }}"
  • Check the variables in the action itself: View profile and event variables in a flow started by an event, View profile properties in a flow started by a list, a segment or a date.
  • {{ person.id }} is the unique id of the customer in your shop (the external id), so it goes to external_id. {{ person.KlaviyoID }} is the Klaviyo id and is used only in message_id.

Step 3. Send a test​

Klaviyo describes no test button for the action. Run the flow on your own profile with a phone: the result is shown in Webhook Analytics, and the event appears in Flows → Connections → Event journal within seconds. The connection shows Recognised: Klaviyo.

Events​

Klaviyo flow triggerAlphaFlow eventProperties
Placed Orderorder_created; order_paid only with a trigger filter on payment (see below)total
Started Checkoutcart_updatedcart_url
Fulfilled Orderorder_shipped—
Cancelled Orderorder_cancelled—
A subscription through a formform_submitted—

Placed Order is a placed order, not yet a payment. Send order_paid from it only if the flow has a trigger filter on a property of the event that says the order is paid — if your shop sends one; otherwise send order_created. Fulfilled Order and Cancelled Order are events of their own and need no filter.

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​

  • Klaviyo retries errors that can be retried, with a growing pause, and then puts the request into the failed queue of Webhook Analytics; other errors go to Skipped. A retry has the same message_id and is not recorded twice.
  • Klaviyo adds the header X-Klaviyo-Flow-ID with the id of the flow. There is no signature: the secret in the address is enough.
  • {{ event|lookup:'$event_id' }} is not in Klaviyo's reference. If it comes empty, the id becomes klaviyo:order_paid:<KlaviyoID>:, and the second order of the same person is taken for a repeat. Then remove message_id from the body: AlphaFlow accepts the event with the warning no_message_id.
  • Klaviyo's reference names no filter that escapes JSON: a quote in a name breaks the body (not confirmed by the documentation).
  • 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 webhook in Klaviyo stays on.

Klaviyo documentation​